2 * alarmtimewidget.h - alarm date/time entry widget
4 * Copyright © 2001-2011 by David Jarvie <djarvie@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef ALARMTIMEWIDGET_H
22 #define ALARMTIMEWIDGET_H
24 #include <kalarmcal/datetime.h>
27 class QAbstractButton
;
37 using namespace KAlarmCal
;
40 class AlarmTimeWidget
: public QFrame
44 enum Mode
{ // 'mode' values for constructor
45 AT_TIME
= 0x01, // "At ..."
46 DEFER_TIME
= 0x02, // "Defer to ..."
47 DEFER_ANY_TIME
= DEFER_TIME
| 0x04 // "Defer to ..." with 'any time' option
49 AlarmTimeWidget(const QString
& groupBoxTitle
, Mode
, QWidget
* parent
= Q_NULLPTR
);
50 explicit AlarmTimeWidget(Mode
, QWidget
* parent
= Q_NULLPTR
);
51 KDateTime
getDateTime(int* minsFromNow
= Q_NULLPTR
, bool checkExpired
= true, bool showErrorMessage
= true, QWidget
** errorWidget
= Q_NULLPTR
) const;
52 void setDateTime(const DateTime
&);
53 void setMinDateTimeIsCurrent();
54 void setMinDateTime(const KDateTime
& = KDateTime());
55 void setMaxDateTime(const DateTime
& = DateTime());
56 const KDateTime
& maxDateTime() const { return mMaxDateTime
; }
57 KDateTime::Spec
timeSpec() const { return mTimeSpec
; }
58 void setReadOnly(bool);
59 bool anyTime() const { return mAnyTime
; }
60 void enableAnyTime(bool enable
);
61 void selectTimeFromNow(int minutes
= 0);
62 void showMoreOptions(bool);
63 QSize
sizeHint() const Q_DECL_OVERRIDE
{ return minimumSizeHint(); }
65 static QString
i18n_TimeAfterPeriod();
66 static const int maxDelayTime
; // maximum time from now
69 void changed(const KDateTime
&);
70 void dateOnlyToggled(bool anyTime
);
75 void slotButtonSet(QAbstractButton
*);
76 void dateTimeChanged();
77 void delayTimeChanged(int);
78 void slotAnyTimeToggled(bool);
79 void slotTimeZoneChanged();
80 void slotTimeZoneToggled(bool);
81 void showTimeZoneSelector();
84 void init(Mode
, const QString
& groupBoxTitle
= QString());
86 void setMaxDelayTime(const KDateTime
& now
);
87 void setMaxMinTimeIf(const KDateTime
& now
);
89 ButtonGroup
* mButtonGroup
;
90 RadioButton
* mAtTimeRadio
;
91 RadioButton
* mAfterTimeRadio
;
92 CheckBox
* mAnyTimeCheckBox
;
93 KDateComboBox
* mDateEdit
;
95 TimeSpinBox
* mDelayTimeEdit
;
96 PushButton
* mTimeZoneButton
;
97 QWidget
* mTimeZoneBox
; // contains label and time zone combo box
98 CheckBox
* mNoTimeZone
;
99 TimeZoneCombo
* mTimeZone
;
100 KDateTime mMinDateTime
; // earliest allowed date/time
101 KDateTime mMaxDateTime
; // latest allowed date/time
102 KDateTime::Spec mTimeSpec
; // time spec used
103 int mAnyTime
; // 0 = date/time is specified, 1 = only a date, -1 = uninitialised
104 bool mAnyTimeAllowed
; // 'mAnyTimeCheckBox' is enabled
105 bool mDeferring
; // being used to enter a deferral time
106 bool mMinDateTimeIsNow
; // earliest allowed date/time is the current time
107 bool mPastMax
; // current time is past the maximum date/time
108 bool mMinMaxTimeSet
; // limits have been set for the time edit control
109 bool mTimerSyncing
; // mTimer is not yet synchronized to the minute boundary
112 #endif // ALARMTIMEWIDGET_H