Diffstat (limited to 'korganizer/koeditorrecurrence.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditorrecurrence.h | 321 |
1 files changed, 321 insertions, 0 deletions
diff --git a/korganizer/koeditorrecurrence.h b/korganizer/koeditorrecurrence.h new file mode 100644 index 0000000..4f0f0b2 --- a/dev/null +++ b/korganizer/koeditorrecurrence.h | |||
@@ -0,0 +1,321 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2000-2003 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | #ifndef _KOEDITORRECURRENCE_H | ||
24 | #define _KOEDITORRECURRENCE_H | ||
25 | |||
26 | #include <qframe.h> | ||
27 | #include <qlabel.h> | ||
28 | #include <qcheckbox.h> | ||
29 | #include <qpushbutton.h> | ||
30 | #include <qgroupbox.h> | ||
31 | #include <qlineedit.h> | ||
32 | #include <qcombobox.h> | ||
33 | #include <qmultilineedit.h> | ||
34 | #include <qlistview.h> | ||
35 | #include <qradiobutton.h> | ||
36 | |||
37 | #include <kdialogbase.h> | ||
38 | |||
39 | #include <libkcal/event.h> | ||
40 | |||
41 | #include "ktimeedit.h" | ||
42 | |||
43 | class QWidgetStack; | ||
44 | class QSpinBox; | ||
45 | |||
46 | class KDateEdit; | ||
47 | |||
48 | using namespace KCal; | ||
49 | |||
50 | class RecurBase : public QWidget | ||
51 | { | ||
52 | public: | ||
53 | RecurBase( QWidget *parent = 0, const char *name = 0 ); | ||
54 | |||
55 | void setFrequency( int ); | ||
56 | int frequency(); | ||
57 | |||
58 | QWidget *frequencyEdit(); | ||
59 | |||
60 | private: | ||
61 | QSpinBox *mFrequencyEdit; | ||
62 | }; | ||
63 | |||
64 | class RecurDaily : public RecurBase | ||
65 | { | ||
66 | public: | ||
67 | RecurDaily( QWidget *parent = 0, const char *name = 0 ); | ||
68 | }; | ||
69 | |||
70 | class RecurWeekly : public RecurBase | ||
71 | { | ||
72 | public: | ||
73 | RecurWeekly( QWidget *parent = 0, const char *name = 0 ); | ||
74 | |||
75 | void setDays( const QBitArray & ); | ||
76 | QBitArray days(); | ||
77 | |||
78 | private: | ||
79 | QCheckBox *mDayBoxes[7]; | ||
80 | }; | ||
81 | |||
82 | class RecurMonthly : public RecurBase | ||
83 | { | ||
84 | public: | ||
85 | RecurMonthly( QWidget *parent = 0, const char *name = 0 ); | ||
86 | |||
87 | void setByDay( int day ); | ||
88 | void setByPos( int count, int weekday ); | ||
89 | |||
90 | bool byDay(); | ||
91 | bool byPos(); | ||
92 | |||
93 | int day(); | ||
94 | |||
95 | int count(); | ||
96 | int weekday(); | ||
97 | |||
98 | private: | ||
99 | QRadioButton *mByDayRadio; | ||
100 | QComboBox *mByDayCombo; | ||
101 | |||
102 | QRadioButton *mByPosRadio; | ||
103 | QComboBox *mByPosCountCombo; | ||
104 | QComboBox *mByPosWeekdayCombo; | ||
105 | }; | ||
106 | |||
107 | class RecurYearly : public RecurBase | ||
108 | { | ||
109 | public: | ||
110 | RecurYearly( QWidget *parent = 0, const char *name = 0 ); | ||
111 | |||
112 | void setByDay(); | ||
113 | void setByMonth( int month ); | ||
114 | |||
115 | bool byMonth(); | ||
116 | bool byDay(); | ||
117 | |||
118 | int month(); | ||
119 | |||
120 | private: | ||
121 | QRadioButton *mByMonthRadio; | ||
122 | QComboBox *mByMonthCombo; | ||
123 | |||
124 | QRadioButton *mByDayRadio; | ||
125 | }; | ||
126 | |||
127 | class RecurrenceChooser : public QWidget | ||
128 | { | ||
129 | Q_OBJECT | ||
130 | public: | ||
131 | RecurrenceChooser( QWidget *parent = 0, const char *name = 0 ); | ||
132 | |||
133 | enum { Daily, Weekly, Monthly, Yearly }; | ||
134 | |||
135 | void setType( int ); | ||
136 | int type(); | ||
137 | |||
138 | signals: | ||
139 | void chosen( int ); | ||
140 | |||
141 | protected slots: | ||
142 | void emitChoice(); | ||
143 | |||
144 | private: | ||
145 | QComboBox *mTypeCombo; | ||
146 | |||
147 | QRadioButton *mDailyButton; | ||
148 | QRadioButton *mWeeklyButton; | ||
149 | QRadioButton *mMonthlyButton; | ||
150 | QRadioButton *mYearlyButton; | ||
151 | }; | ||
152 | |||
153 | class ExceptionsBase | ||
154 | { | ||
155 | public: | ||
156 | virtual void setDefaults( const QDateTime &from ) = 0; | ||
157 | virtual void setDates( const DateList & ) = 0; | ||
158 | virtual DateList dates() = 0; | ||
159 | }; | ||
160 | |||
161 | class ExceptionsWidget : public QWidget, public ExceptionsBase | ||
162 | { | ||
163 | Q_OBJECT | ||
164 | public: | ||
165 | ExceptionsWidget( QWidget *parent = 0, const char *name = 0 ); | ||
166 | |||
167 | void setDefaults( const QDateTime &from ); | ||
168 | |||
169 | void setDates( const DateList & ); | ||
170 | DateList dates(); | ||
171 | |||
172 | protected slots: | ||
173 | void addException(); | ||
174 | void changeException(); | ||
175 | void deleteException(); | ||
176 | |||
177 | private: | ||
178 | KDateEdit *mExceptionDateEdit; | ||
179 | QListBox *mExceptionList; | ||
180 | DateList mExceptionDates; | ||
181 | }; | ||
182 | |||
183 | class ExceptionsDialog : public KDialogBase, public ExceptionsBase | ||
184 | { | ||
185 | public: | ||
186 | ExceptionsDialog( QWidget *parent, const char *name = 0 ); | ||
187 | |||
188 | void setDefaults( const QDateTime &from ); | ||
189 | |||
190 | void setDates( const DateList & ); | ||
191 | DateList dates(); | ||
192 | |||
193 | private: | ||
194 | ExceptionsWidget *mExceptions; | ||
195 | }; | ||
196 | |||
197 | class RecurrenceRangeBase | ||
198 | { | ||
199 | public: | ||
200 | virtual void setDefaults( const QDateTime &from ) = 0; | ||
201 | |||
202 | virtual void setDuration( int ) = 0; | ||
203 | virtual int duration() = 0; | ||
204 | |||
205 | virtual void setEndDate( const QDate & ) = 0; | ||
206 | virtual QDate endDate() = 0; | ||
207 | |||
208 | virtual void setDateTimes( const QDateTime &start, | ||
209 | const QDateTime &end = QDateTime() ) = 0; | ||
210 | }; | ||
211 | |||
212 | class RecurrenceRangeWidget : public QWidget, public RecurrenceRangeBase | ||
213 | { | ||
214 | Q_OBJECT | ||
215 | public: | ||
216 | RecurrenceRangeWidget( QWidget *parent = 0, const char *name = 0 ); | ||
217 | |||
218 | void setDefaults( const QDateTime &from ); | ||
219 | |||
220 | void setDuration( int ); | ||
221 | int duration(); | ||
222 | |||
223 | void setEndDate( const QDate & ); | ||
224 | QDate endDate(); | ||
225 | |||
226 | void setDateTimes( const QDateTime &start, | ||
227 | const QDateTime &end = QDateTime() ); | ||
228 | |||
229 | protected slots: | ||
230 | void showCurrentRange(); | ||
231 | |||
232 | private: | ||
233 | QGroupBox *mRangeGroupBox; | ||
234 | QLabel *mStartDateLabel; | ||
235 | QRadioButton *mNoEndDateButton; | ||
236 | QRadioButton *mEndDurationButton; | ||
237 | QSpinBox *mEndDurationEdit; | ||
238 | QRadioButton *mEndDateButton; | ||
239 | KDateEdit *mEndDateEdit; | ||
240 | }; | ||
241 | |||
242 | class RecurrenceRangeDialog : public KDialogBase, public RecurrenceRangeBase | ||
243 | { | ||
244 | public: | ||
245 | RecurrenceRangeDialog( QWidget *parent = 0, const char *name = 0 ); | ||
246 | |||
247 | void setDefaults( const QDateTime &from ); | ||
248 | |||
249 | void setDuration( int ); | ||
250 | int duration(); | ||
251 | |||
252 | void setEndDate( const QDate & ); | ||
253 | QDate endDate(); | ||
254 | |||
255 | void setDateTimes( const QDateTime &start, | ||
256 | const QDateTime &end = QDateTime() ); | ||
257 | |||
258 | private: | ||
259 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | ||
260 | }; | ||
261 | |||
262 | class KOEditorRecurrence : public QWidget | ||
263 | { | ||
264 | Q_OBJECT | ||
265 | public: | ||
266 | KOEditorRecurrence ( QWidget *parent = 0, const char *name = 0 ); | ||
267 | virtual ~KOEditorRecurrence(); | ||
268 | |||
269 | enum { Daily, Weekly, Monthly, Yearly }; | ||
270 | |||
271 | /** Set widgets to default values */ | ||
272 | void setDefaults( QDateTime from, QDateTime to, bool allday ); | ||
273 | /** Read event object and setup widgets accordingly */ | ||
274 | void readEvent( Event * ); | ||
275 | /** Write event settings to event object */ | ||
276 | void writeEvent( Event * ); | ||
277 | |||
278 | /** Check if the input is valid. */ | ||
279 | bool validateInput(); | ||
280 | |||
281 | public slots: | ||
282 | void setEnabled( bool ); | ||
283 | void setDateTimes( QDateTime start, QDateTime end ); | ||
284 | void setDateTimeStr( const QString & ); | ||
285 | |||
286 | signals: | ||
287 | void dateTimesChanged( QDateTime start, QDateTime end ); | ||
288 | |||
289 | protected slots: | ||
290 | void showCurrentRule( int ); | ||
291 | void showExceptionsDialog(); | ||
292 | void showRecurrenceRangeDialog(); | ||
293 | |||
294 | private: | ||
295 | QCheckBox *mEnabledCheck; | ||
296 | |||
297 | QGroupBox *mTimeGroupBox; | ||
298 | QLabel *mDateTimeLabel; | ||
299 | |||
300 | QGroupBox *mRuleBox; | ||
301 | QWidgetStack *mRuleStack; | ||
302 | RecurrenceChooser *mRecurrenceChooser; | ||
303 | |||
304 | RecurDaily *mDaily; | ||
305 | RecurWeekly *mWeekly; | ||
306 | RecurMonthly *mMonthly; | ||
307 | RecurYearly *mYearly; | ||
308 | |||
309 | RecurrenceRangeBase *mRecurrenceRange; | ||
310 | RecurrenceRangeWidget *mRecurrenceRangeWidget; | ||
311 | RecurrenceRangeDialog *mRecurrenceRangeDialog; | ||
312 | QPushButton *mRecurrenceRangeButton; | ||
313 | |||
314 | ExceptionsBase *mExceptions; | ||
315 | ExceptionsDialog *mExceptionsDialog; | ||
316 | ExceptionsWidget *mExceptionsWidget; | ||
317 | QPushButton *mExceptionsButton; | ||
318 | |||
319 | }; | ||
320 | |||
321 | #endif | ||