kalarm

alarmtimewidget.h

00001 /*
00002  *  alarmtimewidget.h  -  alarm date/time entry widget
00003  *  Program:  kalarm
00004  *  Copyright © 2001-2006 by David Jarvie <software@astrojar.org.uk>
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License along
00017  *  with this program; if not, write to the Free Software Foundation, Inc.,
00018  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef ALARMTIMEWIDGET_H
00022 #define ALARMTIMEWIDGET_H
00023 
00024 #include "buttongroup.h"
00025 #include "datetime.h"
00026 
00027 class RadioButton;
00028 class CheckBox;
00029 class DateEdit;
00030 class TimeEdit;
00031 class TimeSpinBox;
00032 
00033 
00034 class AlarmTimeWidget : public ButtonGroup
00035 {
00036         Q_OBJECT
00037     public:
00038         enum {       // 'mode' values for constructor. May be OR'ed together.
00039             AT_TIME      = 0x00,   // "At ..."
00040             DEFER_TIME   = 0x01,   // "Defer to ..."
00041             NARROW       = 0x02    // make a narrow widget
00042         };
00043         AlarmTimeWidget(const QString& groupBoxTitle, int mode, QWidget* parent = 0, const char* name = 0);
00044         AlarmTimeWidget(int mode, QWidget* parent = 0, const char* name = 0);
00045         DateTime         getDateTime(int* minsFromNow = 0, bool checkExpired = true, bool showErrorMessage = true, QWidget** errorWidget = 0) const;
00046         void             setDateTime(const DateTime&);
00047         void             setMinDateTimeIsCurrent();
00048         void             setMinDateTime(const QDateTime& = QDateTime());
00049         void             setMaxDateTime(const DateTime& = DateTime());
00050         const QDateTime& maxDateTime() const           { return mMaxDateTime; }
00051         void             setReadOnly(bool);
00052         bool             anyTime() const               { return mAnyTime; }
00053         void             enableAnyTime(bool enable);
00054         void             selectTimeFromNow(int minutes = 0);
00055         QSize            sizeHint() const              { return minimumSizeHint(); }
00056 
00057         static QString   i18n_w_TimeFromNow();     // text of 'Time from now:' radio button, with 'w' shortcut
00058         static QString   i18n_TimeAfterPeriod();
00059         static const int maxDelayTime;    // maximum time from now
00060 
00061     signals:
00062         void             anyTimeToggled(bool anyTime);
00063         void             pastMax();
00064 
00065     protected slots:
00066         void             slotTimer();
00067         void             slotButtonSet(int id);
00068         void             dateTimeChanged();
00069         void             delayTimeChanged(int);
00070         void             slotAnyTimeToggled(bool);
00071 
00072     private:
00073         void             init(int mode);
00074         void             setAnyTime();
00075         void             setMaxDelayTime(const QDateTime& now);
00076         void             setMaxMinTimeIf(const QDateTime& now);
00077 
00078         RadioButton*     mAtTimeRadio;
00079         RadioButton*     mAfterTimeRadio;
00080         DateEdit*        mDateEdit;
00081         TimeEdit*        mTimeEdit;
00082         TimeSpinBox*     mDelayTimeEdit;
00083         CheckBox*        mAnyTimeCheckBox;
00084         QDateTime        mMinDateTime;      // earliest allowed date/time
00085         QDateTime        mMaxDateTime;      // latest allowed date/time
00086         int              mAnyTime;          // 0 = date/time is specified, 1 = only a date, -1 = uninitialised
00087         bool             mAnyTimeAllowed;   // 'mAnyTimeCheckBox' is enabled
00088         bool             mMinDateTimeIsNow; // earliest allowed date/time is the current time
00089         bool             mPastMax;          // current time is past the maximum date/time
00090         bool             mMinMaxTimeSet;    // limits have been set for the time edit control
00091         bool             mTimerSyncing;     // mTimer is not yet synchronised to the minute boundary
00092 };
00093 
00094 #endif // ALARMTIMEWIDGET_H
KDE Home | KDE Accessibility Home | Description of Access Keys