Move unittestenv to correct location
[kdepim.git] / kalarm / recurrenceedit.h
blob85d344ff922ba1cda6f485b3bf71e320df1ac41c
1 /*
2 * recurrenceedit.h - widget to edit the event's recurrence definition
3 * Program: kalarm
4 * Copyright © 2002-2011 by David Jarvie <djarvie@kde.org>
6 * Based originally on KOrganizer module koeditorrecurrence.h,
7 * Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 #ifndef RECURRENCEEDIT_H
25 #define RECURRENCEEDIT_H
27 #include <kalarmcal/repetition.h>
29 #include <kdatetime.h>
31 #include <QFrame>
33 class KDateComboBox;
34 class QDate;
35 class QShowEvent;
36 class QStackedWidget;
37 class QGroupBox;
38 class QLabel;
39 class QListWidget;
40 class QAbstractButton;
41 class QPushButton;
42 class SpinBox;
43 class CheckBox;
44 class RadioButton;
45 class TimeEdit;
46 class ButtonGroup;
47 class RepetitionButton;
48 class Rule;
49 class NoRule;
50 class SubDailyRule;
51 class DailyRule;
52 class WeeklyRule;
53 class MonthlyRule;
54 class YearlyRule;
55 namespace KAlarmCal { class KAEvent; }
57 using namespace KAlarmCal;
59 class RecurrenceEdit : public QFrame
61 Q_OBJECT
62 public:
63 // Don't alter the order of these recurrence types
64 enum RepeatType { INVALID_RECUR = -1, NO_RECUR, AT_LOGIN, SUBDAILY, DAILY, WEEKLY, MONTHLY, ANNUAL };
66 explicit RecurrenceEdit(bool readOnly, QWidget* parent = Q_NULLPTR);
67 virtual ~RecurrenceEdit() { }
69 /** Set widgets to default values */
70 void setDefaults(const KDateTime& from);
71 /** Initialise according to a specified event */
72 void set(const KAEvent&);
73 /** Initialise with repeat-at-login selected, instead of calling set(). */
74 void setRepeatAtLogin();
75 /** Write recurrence settings into an event */
76 void updateEvent(KAEvent&, bool adjustStart);
77 QWidget* checkData(const KDateTime& startDateTime, QString& errorMessage) const;
78 RepeatType repeatType() const { return mRuleButtonType; }
79 bool isTimedRepeatType() const { return mRuleButtonType >= SUBDAILY; }
80 Repetition subRepetition() const;
81 void setSubRepetition(int reminderMinutes, bool dateOnly);
82 void setStartDate(const QDate&, const QDate& today);
83 void setDefaultEndDate(const QDate&);
84 void setEndDateTime(const KDateTime&);
85 KDateTime endDateTime() const;
86 bool stateChanged() const;
87 void activateSubRepetition();
88 void showMoreOptions(bool);
90 static QString i18n_combo_NoRecur(); // text of 'No recurrence' selection
91 static QString i18n_combo_AtLogin(); // text of 'At login' selection
92 static QString i18n_combo_HourlyMinutely(); // text of 'Hourly/Minutely'
93 static QString i18n_combo_Daily(); // text of 'Daily' selection
94 static QString i18n_combo_Weekly(); // text of 'Weekly' selection
95 static QString i18n_combo_Monthly(); // text of 'Monthly' selection
96 static QString i18n_combo_Yearly(); // text of 'Yearly' selection
98 public Q_SLOTS:
99 void setDateTime(const KDateTime& start) { mCurrStartDateTime = start; }
101 Q_SIGNALS:
102 void shown();
103 void typeChanged(int recurType); // returns a RepeatType value
104 void frequencyChanged();
105 void repeatNeedsInitialisation();
106 void contentsChanged();
108 protected:
109 void showEvent(QShowEvent*) Q_DECL_OVERRIDE;
111 private Q_SLOTS:
112 void periodClicked(QAbstractButton*);
113 void rangeTypeClicked();
114 void repeatCountChanged(int value);
115 void slotAnyTimeToggled(bool);
116 void addException();
117 void changeException();
118 void deleteException();
119 void enableExceptionButtons();
121 private:
122 void setRuleDefaults(const QDate& start);
123 void saveState();
125 // Main rule box and choices
126 QStackedWidget* mRuleStack;
127 Rule* mRule; // current rule widget, or 0 if NoRule
128 NoRule* mNoRule;
129 SubDailyRule* mSubDailyRule;
130 DailyRule* mDailyRule;
131 WeeklyRule* mWeeklyRule;
132 MonthlyRule* mMonthlyRule;
133 YearlyRule* mYearlyRule;
135 ButtonGroup* mRuleButtonGroup;
136 RadioButton* mNoneButton;
137 RadioButton* mAtLoginButton;
138 RadioButton* mSubDailyButton;
139 RadioButton* mDailyButton;
140 RadioButton* mWeeklyButton;
141 RadioButton* mMonthlyButton;
142 RadioButton* mYearlyButton;
143 RepeatType mRuleButtonType;
144 bool mDailyShown; // daily rule has been displayed at some time or other
145 bool mWeeklyShown; // weekly rule has been displayed at some time or other
146 bool mMonthlyShown; // monthly rule has been displayed at some time or other
147 bool mYearlyShown; // yearly rule has been displayed at some time or other
149 // Range
150 QGroupBox* mRangeButtonBox;
151 ButtonGroup* mRangeButtonGroup;
152 RadioButton* mNoEndDateButton;
153 RadioButton* mRepeatCountButton;
154 SpinBox* mRepeatCountEntry;
155 QLabel* mRepeatCountLabel;
156 RadioButton* mEndDateButton;
157 KDateComboBox* mEndDateEdit;
158 TimeEdit* mEndTimeEdit;
159 CheckBox* mEndAnyTimeCheckBox;
161 // Exceptions
162 QGroupBox* mExceptionGroup;
163 QListWidget* mExceptionDateList;
164 KDateComboBox* mExceptionDateEdit;
165 QPushButton* mChangeExceptionButton;
166 QPushButton* mDeleteExceptionButton;
167 CheckBox* mExcludeHolidays;
168 CheckBox* mWorkTimeOnly;
169 QList<QDate> mExceptionDates;
171 // Current start date and time
172 KDateTime mCurrStartDateTime;
173 RepetitionButton* mSubRepetition;
174 bool mNoEmitTypeChanged; // suppress typeChanged() signal
175 bool mReadOnly;
177 // Initial state of non-rule controls
178 QAbstractButton* mSavedRuleButton; // which rule button was selected
179 QAbstractButton* mSavedRangeButton; // which range button was selected
180 int mSavedRecurCount; // recurrence repeat count
181 KDateTime mSavedEndDateTime; // end date/time
182 QList<QDate> mSavedExceptionDates; // exception dates
183 Repetition mSavedRepetition; // sub-repetition interval & count (via mSubRepetition button)
184 bool mSavedExclHolidays; // exclude holidays
185 bool mSavedWorkTimeOnly; // only during working hours
188 #endif // RECURRENCEEDIT_H
190 // vim: et sw=4: