summaryrefslogtreecommitdiff
authordrw <drw>2004-02-25 16:28:34 (UTC)
committer drw <drw>2004-02-25 16:28:34 (UTC)
commitf84a46fce6c1b7702ec1eaebd40e363b67253649 (patch) (unidiff)
tree8ce368593373f66cd3e5b090ee222a7cc7835739
parent25e87d9ccc92b7a4c12518532576f55b11726b26 (diff)
downloadopie-f84a46fce6c1b7702ec1eaebd40e363b67253649.zip
opie-f84a46fce6c1b7702ec1eaebd40e363b67253649.tar.gz
opie-f84a46fce6c1b7702ec1eaebd40e363b67253649.tar.bz2
Added OPimRecurrenceBase & OPimRecurrenceWidget to libopiepim2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/ui/.cvsignore8
-rw-r--r--libopie2/opiepim/ui/opimrecurrencebase.ui713
-rw-r--r--libopie2/opiepim/ui/opimrecurrencewidget.cpp634
-rw-r--r--libopie2/opiepim/ui/opimrecurrencewidget.h93
-rw-r--r--libopie2/opiepim/ui/ui.pro8
5 files changed, 1454 insertions, 2 deletions
diff --git a/libopie2/opiepim/ui/.cvsignore b/libopie2/opiepim/ui/.cvsignore
new file mode 100644
index 0000000..fc84516
--- a/dev/null
+++ b/libopie2/opiepim/ui/.cvsignore
@@ -0,0 +1,8 @@
1Makefile*
2opimrecurrencebase.cpp
3opimrecurrencebase.h
4obj
5moc*
6*moc
7*.o
8~*
diff --git a/libopie2/opiepim/ui/opimrecurrencebase.ui b/libopie2/opiepim/ui/opimrecurrencebase.ui
new file mode 100644
index 0000000..d70acb9
--- a/dev/null
+++ b/libopie2/opiepim/ui/opimrecurrencebase.ui
@@ -0,0 +1,713 @@
1<!DOCTYPE UI><UI>
2<class>OPimRecurrenceBase</class>
3<comment>*********************************************************************
4** Copyright (C) 2000 Trolltech AS. All rights reserved.
5**
6** This file is part of Qtopia Environment.
7**
8** This file may be distributed and/or modified under the terms of the
9** GNU General Public License version 2 as published by the Free Software
10** Foundation and appearing in the file LICENSE.GPL included in the
11** packaging of this file.
12**
13** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15**
16** See http://www.trolltech.com/gpl/ for GPL licensing information.
17**
18** Contact info@trolltech.com if any conditions of this licensing are
19** not clear to you.
20**
21** $Id$
22**
23*********************************************************************</comment>
24<widget>
25 <class>QDialog</class>
26 <property stdset="1">
27 <name>name</name>
28 <cstring>OPimRecurrenceBase</cstring>
29 </property>
30 <property stdset="1">
31 <name>geometry</name>
32 <rect>
33 <x>0</x>
34 <y>0</y>
35 <width>246</width>
36 <height>309</height>
37 </rect>
38 </property>
39 <property stdset="1">
40 <name>caption</name>
41 <string>Repeating Event </string>
42 </property>
43 <property>
44 <name>layoutMargin</name>
45 </property>
46 <property>
47 <name>layoutSpacing</name>
48 </property>
49 <vbox>
50 <property stdset="1">
51 <name>margin</name>
52 <number>5</number>
53 </property>
54 <property stdset="1">
55 <name>spacing</name>
56 <number>1</number>
57 </property>
58 <widget>
59 <class>QButtonGroup</class>
60 <property stdset="1">
61 <name>name</name>
62 <cstring>fraType</cstring>
63 </property>
64 <property stdset="1">
65 <name>frameShape</name>
66 <enum>NoFrame</enum>
67 </property>
68 <property stdset="1">
69 <name>frameShadow</name>
70 <enum>Sunken</enum>
71 </property>
72 <property stdset="1">
73 <name>title</name>
74 <string></string>
75 </property>
76 <property stdset="1">
77 <name>exclusive</name>
78 <bool>true</bool>
79 </property>
80 <property>
81 <name>layoutMargin</name>
82 </property>
83 <property>
84 <name>layoutSpacing</name>
85 </property>
86 <hbox>
87 <property stdset="1">
88 <name>margin</name>
89 <number>5</number>
90 </property>
91 <property stdset="1">
92 <name>spacing</name>
93 <number>1</number>
94 </property>
95 <widget>
96 <class>QToolButton</class>
97 <property stdset="1">
98 <name>name</name>
99 <cstring>cmdNone</cstring>
100 </property>
101 <property stdset="1">
102 <name>text</name>
103 <string>None</string>
104 </property>
105 <property stdset="1">
106 <name>toggleButton</name>
107 <bool>true</bool>
108 </property>
109 <property stdset="1">
110 <name>toggleButton</name>
111 <bool>true</bool>
112 </property>
113 </widget>
114 <widget>
115 <class>QToolButton</class>
116 <property stdset="1">
117 <name>name</name>
118 <cstring>cmdDay</cstring>
119 </property>
120 <property stdset="1">
121 <name>text</name>
122 <string>Day</string>
123 </property>
124 <property stdset="1">
125 <name>toggleButton</name>
126 <bool>true</bool>
127 </property>
128 <property stdset="1">
129 <name>toggleButton</name>
130 <bool>true</bool>
131 </property>
132 </widget>
133 <widget>
134 <class>QToolButton</class>
135 <property stdset="1">
136 <name>name</name>
137 <cstring>cmdWeek</cstring>
138 </property>
139 <property stdset="1">
140 <name>sizePolicy</name>
141 <sizepolicy>
142 <hsizetype>1</hsizetype>
143 <vsizetype>0</vsizetype>
144 </sizepolicy>
145 </property>
146 <property stdset="1">
147 <name>text</name>
148 <string>Week</string>
149 </property>
150 <property stdset="1">
151 <name>toggleButton</name>
152 <bool>true</bool>
153 </property>
154 <property stdset="1">
155 <name>toggleButton</name>
156 <bool>true</bool>
157 </property>
158 </widget>
159 <widget>
160 <class>QToolButton</class>
161 <property stdset="1">
162 <name>name</name>
163 <cstring>cmdMonth</cstring>
164 </property>
165 <property stdset="1">
166 <name>sizePolicy</name>
167 <sizepolicy>
168 <hsizetype>1</hsizetype>
169 <vsizetype>0</vsizetype>
170 </sizepolicy>
171 </property>
172 <property stdset="1">
173 <name>text</name>
174 <string>Month</string>
175 </property>
176 <property stdset="1">
177 <name>toggleButton</name>
178 <bool>true</bool>
179 </property>
180 <property stdset="1">
181 <name>toggleButton</name>
182 <bool>true</bool>
183 </property>
184 </widget>
185 <widget>
186 <class>QToolButton</class>
187 <property stdset="1">
188 <name>name</name>
189 <cstring>cmdYear</cstring>
190 </property>
191 <property stdset="1">
192 <name>text</name>
193 <string>Year</string>
194 </property>
195 <property stdset="1">
196 <name>toggleButton</name>
197 <bool>true</bool>
198 </property>
199 <property stdset="1">
200 <name>toggleButton</name>
201 <bool>true</bool>
202 </property>
203 </widget>
204 </hbox>
205 </widget>
206 <widget>
207 <class>QLayoutWidget</class>
208 <property stdset="1">
209 <name>name</name>
210 <cstring>Layout4</cstring>
211 </property>
212 <hbox>
213 <property stdset="1">
214 <name>margin</name>
215 <number>0</number>
216 </property>
217 <property stdset="1">
218 <name>spacing</name>
219 <number>6</number>
220 </property>
221 <widget>
222 <class>QLabel</class>
223 <property stdset="1">
224 <name>name</name>
225 <cstring>lblEvery</cstring>
226 </property>
227 <property stdset="1">
228 <name>text</name>
229 <string>Every:</string>
230 </property>
231 </widget>
232 <widget>
233 <class>QSpinBox</class>
234 <property stdset="1">
235 <name>name</name>
236 <cstring>spinFreq</cstring>
237 </property>
238 <property stdset="1">
239 <name>minValue</name>
240 <number>1</number>
241 </property>
242 </widget>
243 <widget>
244 <class>QLabel</class>
245 <property stdset="1">
246 <name>name</name>
247 <cstring>lblFreq</cstring>
248 </property>
249 <property stdset="1">
250 <name>sizePolicy</name>
251 <sizepolicy>
252 <hsizetype>1</hsizetype>
253 <vsizetype>1</vsizetype>
254 </sizepolicy>
255 </property>
256 <property stdset="1">
257 <name>text</name>
258 <string>Frequency</string>
259 </property>
260 </widget>
261 </hbox>
262 </widget>
263 <widget>
264 <class>QLayoutWidget</class>
265 <property stdset="1">
266 <name>name</name>
267 <cstring>Layout8</cstring>
268 </property>
269 <hbox>
270 <property stdset="1">
271 <name>margin</name>
272 <number>0</number>
273 </property>
274 <property stdset="1">
275 <name>spacing</name>
276 <number>6</number>
277 </property>
278 <widget>
279 <class>QLabel</class>
280 <property stdset="1">
281 <name>name</name>
282 <cstring>lblEnd</cstring>
283 </property>
284 <property stdset="1">
285 <name>sizePolicy</name>
286 <sizepolicy>
287 <hsizetype>1</hsizetype>
288 <vsizetype>0</vsizetype>
289 </sizepolicy>
290 </property>
291 <property stdset="1">
292 <name>text</name>
293 <string>End On:</string>
294 </property>
295 </widget>
296 <widget>
297 <class>QToolButton</class>
298 <property stdset="1">
299 <name>name</name>
300 <cstring>cmdEnd</cstring>
301 </property>
302 <property stdset="1">
303 <name>text</name>
304 <string>No End Date</string>
305 </property>
306 </widget>
307 <widget>
308 <class>QCheckBox</class>
309 <property stdset="1">
310 <name>name</name>
311 <cstring>chkNoEnd</cstring>
312 </property>
313 <property stdset="1">
314 <name>text</name>
315 <string>No End Date</string>
316 </property>
317 </widget>
318 </hbox>
319 </widget>
320 <widget>
321 <class>QButtonGroup</class>
322 <property stdset="1">
323 <name>name</name>
324 <cstring>fraExtra</cstring>
325 </property>
326 <property stdset="1">
327 <name>sizePolicy</name>
328 <sizepolicy>
329 <hsizetype>7</hsizetype>
330 <vsizetype>7</vsizetype>
331 </sizepolicy>
332 </property>
333 <property stdset="1">
334 <name>frameShape</name>
335 <enum>Box</enum>
336 </property>
337 <property stdset="1">
338 <name>title</name>
339 <string>Repeat On</string>
340 </property>
341 <property>
342 <name>layoutMargin</name>
343 </property>
344 <property>
345 <name>layoutSpacing</name>
346 </property>
347 <hbox>
348 <property stdset="1">
349 <name>margin</name>
350 <number>5</number>
351 </property>
352 <property stdset="1">
353 <name>spacing</name>
354 <number>1</number>
355 </property>
356 <widget>
357 <class>QToolButton</class>
358 <property stdset="1">
359 <name>name</name>
360 <cstring>cmdExtra1</cstring>
361 </property>
362 <property stdset="1">
363 <name>text</name>
364 <string>Mon</string>
365 </property>
366 <property stdset="1">
367 <name>toggleButton</name>
368 <bool>true</bool>
369 </property>
370 <property stdset="1">
371 <name>toggleButton</name>
372 <bool>true</bool>
373 </property>
374 </widget>
375 <widget>
376 <class>QToolButton</class>
377 <property stdset="1">
378 <name>name</name>
379 <cstring>cmdExtra2</cstring>
380 </property>
381 <property stdset="1">
382 <name>text</name>
383 <string>Tue</string>
384 </property>
385 <property stdset="1">
386 <name>toggleButton</name>
387 <bool>true</bool>
388 </property>
389 <property stdset="1">
390 <name>toggleButton</name>
391 <bool>true</bool>
392 </property>
393 </widget>
394 <widget>
395 <class>QToolButton</class>
396 <property stdset="1">
397 <name>name</name>
398 <cstring>cmdExtra3</cstring>
399 </property>
400 <property stdset="1">
401 <name>text</name>
402 <string>Wed</string>
403 </property>
404 <property stdset="1">
405 <name>toggleButton</name>
406 <bool>true</bool>
407 </property>
408 <property stdset="1">
409 <name>toggleButton</name>
410 <bool>true</bool>
411 </property>
412 </widget>
413 <widget>
414 <class>QToolButton</class>
415 <property stdset="1">
416 <name>name</name>
417 <cstring>cmdExtra4</cstring>
418 </property>
419 <property stdset="1">
420 <name>text</name>
421 <string>Thu</string>
422 </property>
423 <property stdset="1">
424 <name>toggleButton</name>
425 <bool>true</bool>
426 </property>
427 <property stdset="1">
428 <name>toggleButton</name>
429 <bool>true</bool>
430 </property>
431 </widget>
432 <widget>
433 <class>QToolButton</class>
434 <property stdset="1">
435 <name>name</name>
436 <cstring>cmdExtra5</cstring>
437 </property>
438 <property stdset="1">
439 <name>text</name>
440 <string>Fri</string>
441 </property>
442 <property stdset="1">
443 <name>toggleButton</name>
444 <bool>true</bool>
445 </property>
446 <property stdset="1">
447 <name>toggleButton</name>
448 <bool>true</bool>
449 </property>
450 </widget>
451 <widget>
452 <class>QToolButton</class>
453 <property stdset="1">
454 <name>name</name>
455 <cstring>cmdExtra6</cstring>
456 </property>
457 <property stdset="1">
458 <name>text</name>
459 <string>Sat</string>
460 </property>
461 <property stdset="1">
462 <name>toggleButton</name>
463 <bool>true</bool>
464 </property>
465 <property stdset="1">
466 <name>toggleButton</name>
467 <bool>true</bool>
468 </property>
469 </widget>
470 <widget>
471 <class>QToolButton</class>
472 <property stdset="1">
473 <name>name</name>
474 <cstring>cmdExtra7</cstring>
475 </property>
476 <property stdset="1">
477 <name>text</name>
478 <string>Sun</string>
479 </property>
480 <property stdset="1">
481 <name>toggleButton</name>
482 <bool>true</bool>
483 </property>
484 <property stdset="1">
485 <name>toggleButton</name>
486 <bool>true</bool>
487 </property>
488 </widget>
489 </hbox>
490 </widget>
491 <widget>
492 <class>QFrame</class>
493 <property stdset="1">
494 <name>name</name>
495 <cstring>Frame3</cstring>
496 </property>
497 <property stdset="1">
498 <name>sizePolicy</name>
499 <sizepolicy>
500 <hsizetype>7</hsizetype>
501 <vsizetype>7</vsizetype>
502 </sizepolicy>
503 </property>
504 <property stdset="1">
505 <name>frameShape</name>
506 <enum>Box</enum>
507 </property>
508 <property stdset="1">
509 <name>frameShadow</name>
510 <enum>Sunken</enum>
511 </property>
512 <property>
513 <name>layoutMargin</name>
514 </property>
515 <property>
516 <name>layoutSpacing</name>
517 </property>
518 <vbox>
519 <property stdset="1">
520 <name>margin</name>
521 <number>5</number>
522 </property>
523 <property stdset="1">
524 <name>spacing</name>
525 <number>1</number>
526 </property>
527 <widget>
528 <class>QLayoutWidget</class>
529 <property stdset="1">
530 <name>name</name>
531 <cstring>Layout6</cstring>
532 </property>
533 <property>
534 <name>layoutSpacing</name>
535 </property>
536 <hbox>
537 <property stdset="1">
538 <name>margin</name>
539 <number>0</number>
540 </property>
541 <property stdset="1">
542 <name>spacing</name>
543 <number>0</number>
544 </property>
545 <widget>
546 <class>QLabel</class>
547 <property stdset="1">
548 <name>name</name>
549 <cstring>lblRepeat</cstring>
550 </property>
551 <property stdset="1">
552 <name>sizePolicy</name>
553 <sizepolicy>
554 <hsizetype>1</hsizetype>
555 <vsizetype>3</vsizetype>
556 </sizepolicy>
557 </property>
558 <property stdset="1">
559 <name>text</name>
560 <string>Every</string>
561 </property>
562 <property stdset="1">
563 <name>alignment</name>
564 <set>AlignTop|AlignLeft</set>
565 </property>
566 <property>
567 <name>hAlign</name>
568 </property>
569 <property>
570 <name>vAlign</name>
571 </property>
572 </widget>
573 <widget>
574 <class>QLabel</class>
575 <property stdset="1">
576 <name>name</name>
577 <cstring>lblVar1</cstring>
578 </property>
579 <property stdset="1">
580 <name>sizePolicy</name>
581 <sizepolicy>
582 <hsizetype>1</hsizetype>
583 <vsizetype>1</vsizetype>
584 </sizepolicy>
585 </property>
586 <property stdset="1">
587 <name>text</name>
588 <string>Var1</string>
589 </property>
590 <property stdset="1">
591 <name>alignment</name>
592 <set>AlignTop|AlignLeft</set>
593 </property>
594 <property>
595 <name>hAlign</name>
596 </property>
597 <property>
598 <name>vAlign</name>
599 </property>
600 </widget>
601 <widget>
602 <class>QLabel</class>
603 <property stdset="1">
604 <name>name</name>
605 <cstring>lblVar2</cstring>
606 </property>
607 <property stdset="1">
608 <name>sizePolicy</name>
609 <sizepolicy>
610 <hsizetype>4</hsizetype>
611 <vsizetype>1</vsizetype>
612 </sizepolicy>
613 </property>
614 <property stdset="1">
615 <name>text</name>
616 <string>Var 2</string>
617 </property>
618 <property stdset="1">
619 <name>alignment</name>
620 <set>AlignTop|AlignRight</set>
621 </property>
622 <property>
623 <name>hAlign</name>
624 </property>
625 <property>
626 <name>vAlign</name>
627 </property>
628 </widget>
629 </hbox>
630 </widget>
631 <widget>
632 <class>QLabel</class>
633 <property stdset="1">
634 <name>name</name>
635 <cstring>lblWeekVar</cstring>
636 </property>
637 <property stdset="1">
638 <name>sizePolicy</name>
639 <sizepolicy>
640 <hsizetype>1</hsizetype>
641 <vsizetype>7</vsizetype>
642 </sizepolicy>
643 </property>
644 <property stdset="1">
645 <name>text</name>
646 <string>WeekVar</string>
647 </property>
648 <property stdset="1">
649 <name>alignment</name>
650 <set>AlignTop|AlignHCenter</set>
651 </property>
652 <property>
653 <name>hAlign</name>
654 </property>
655 <property>
656 <name>vAlign</name>
657 </property>
658 </widget>
659 </vbox>
660 </widget>
661 </vbox>
662</widget>
663<connections>
664 <connection>
665 <sender>chkNoEnd</sender>
666 <signal>toggled(bool)</signal>
667 <receiver>cmdEnd</receiver>
668 <slot>setDisabled(bool)</slot>
669 </connection>
670 <connection>
671 <sender>chkNoEnd</sender>
672 <signal>toggled(bool)</signal>
673 <receiver>OPimRecurrenceBase</receiver>
674 <slot>slotNoEnd(bool)</slot>
675 </connection>
676 <connection>
677 <sender>spinFreq</sender>
678 <signal>valueChanged(int)</signal>
679 <receiver>lblVar1</receiver>
680 <slot>setNum(int)</slot>
681 </connection>
682 <connection>
683 <sender>spinFreq</sender>
684 <signal>valueChanged(int)</signal>
685 <receiver>OPimRecurrenceBase</receiver>
686 <slot>setupRepeatLabel( int )</slot>
687 </connection>
688 <connection>
689 <sender>fraType</sender>
690 <signal>clicked(int)</signal>
691 <receiver>OPimRecurrenceBase</receiver>
692 <slot>slotSetRType( int )</slot>
693 </connection>
694 <connection>
695 <sender>fraExtra</sender>
696 <signal>clicked(int)</signal>
697 <receiver>OPimRecurrenceBase</receiver>
698 <slot>slotMonthLabel( int )</slot>
699 </connection>
700 <connection>
701 <sender>fraExtra</sender>
702 <signal>clicked(int)</signal>
703 <receiver>OPimRecurrenceBase</receiver>
704 <slot>slotWeekLabel()</slot>
705 </connection>
706 <slot access="public">setupRepeatLabel( const QString &amp; )</slot>
707 <slot access="public">setupRepeatLabel( int )</slot>
708 <slot access="public">slotMonthLabel( int )</slot>
709 <slot access="public">slotNoEnd(bool)</slot>
710 <slot access="public">slotSetRType( int )</slot>
711 <slot access="public">slotWeekLabel()</slot>
712</connections>
713</UI>
diff --git a/libopie2/opiepim/ui/opimrecurrencewidget.cpp b/libopie2/opiepim/ui/opimrecurrencewidget.cpp
new file mode 100644
index 0000000..569bdd5
--- a/dev/null
+++ b/libopie2/opiepim/ui/opimrecurrencewidget.cpp
@@ -0,0 +1,634 @@
1#include <qapplication.h>
2#include <qlabel.h>
3#include <qpopupmenu.h>
4#include <qspinbox.h>
5
6#include <qpe/timestring.h>
7
8#include "opimrecurrencewidget.h"
9
10// Global Templates for use in setting up the repeat label...
11// the problem is these strings get initialized before QPEApplication can install the translator -zecke
12namespace {
13QString strDayTemplate;
14QString strYearTemplate;
15QString strMonthDateTemplate;
16QString strMonthDayTemplate;
17QString strWeekTemplate;
18QString dayLabel[7];
19}
20
21/*
22 * static linkage to not polute the symbol table...
23 * The problem is that const and static linkage are resolved prior to installing a translator
24 * leading to that the above strings are translted but to the original we delay the init of these strings...
25 * -zecke
26 */
27static void fillStrings() {
28 strDayTemplate = QObject::tr("Every");
29 strYearTemplate = QObject::tr("%1 %2 every ");
30 strMonthDateTemplate = QObject::tr("The %1 every ");
31 strMonthDayTemplate = QObject::tr("The %1 %2 of every");
32 strWeekTemplate = QObject::tr("Every ");
33 dayLabel[0] = QObject::tr("Monday");
34 dayLabel[1] = QObject::tr("Tuesday");
35 dayLabel[2] = QObject::tr("Wednesday");
36 dayLabel[3] = QObject::tr("Thursday");
37 dayLabel[4] = QObject::tr("Friday");
38 dayLabel[5] = QObject::tr("Saturday");
39 dayLabel[6] = QObject::tr("Sunday");
40}
41
42 static QString numberPlacing( int x );// return the proper word format for
43 // x (1st, 2nd, etc)
44static int week( const QDate &dt ); // what week in the month is dt?
45
46/**
47 * Constructs the Widget
48 * @param startOnMonday Does the week start on monday
49 * @param newStart The start date of the recurrence
50 * @param parent The parent widget
51 * @param name the name of object
52 * @param modal if the dialog should be modal
53 * @param fl Additional window flags
54 */
55OPimRecurrenceWidget::OPimRecurrenceWidget( bool startOnMonday,
56 const QDate& newStart,
57 QWidget* parent,
58 const char* name,
59 bool modal,
60 WFlags fl )
61 : OPimRecurrenceBase( parent, name, modal, fl ),
62 start( newStart ),
63 currInterval( None ),
64 startWeekOnMonday( startOnMonday )
65{
66 if (strDayTemplate.isEmpty() )
67 fillStrings();
68
69 init();
70 fraType->setButton( currInterval );
71 chkNoEnd->setChecked( TRUE );
72 setupNone();
73}
74
75/**
76 * Different constructor
77 * @param startOnMonday Does the week start on monday?
78 * @param rp Already set OPimRecurrence object
79 * @param startDate The start date
80 * @param parent The parent widget
81 * @param name The name of the object
82 * @param modal
83 * @param fl The flags for window
84 */
85OPimRecurrenceWidget::OPimRecurrenceWidget( bool startOnMonday,
86 const OPimRecurrence& rp, const QDate& startDate,
87 QWidget* parent, const char* name,
88 bool modal, WFlags fl)
89 : OPimRecurrenceBase( parent, name, modal, fl ),
90 start( startDate ),
91 end( rp.endDate() ),
92 startWeekOnMonday( startOnMonday )
93{
94 if (strDayTemplate.isEmpty() )
95 fillStrings();
96 // do some stuff with the repeat pattern
97 init();
98 setRecurrence( rp );
99}
100
101OPimRecurrenceWidget::~OPimRecurrenceWidget() {
102}
103
104/**
105 * set the start date
106 * @param date the new start date
107 */
108void OPimRecurrenceWidget::setStartDate( const QDate& date ) {
109 setRecurrence( recurrence(), date );
110}
111/**
112 * set the recurrence
113 * @param rp The OPimRecurrence object with the new recurrence rules
114 */
115void OPimRecurrenceWidget::setRecurrence( const OPimRecurrence& rp ) {
116 setRecurrence( rp, start );
117}
118
119/**
120 * overloaded method taking OPimRecurrence and a new start date
121 * @param rp Recurrence rule
122 * @param date The new start date
123 */
124void OPimRecurrenceWidget::setRecurrence( const OPimRecurrence& rp, const QDate& date ) {
125 start = date;
126 end = rp.endDate();
127 switch ( rp.type() ) {
128 default:
129 case OPimRecurrence::NoRepeat:
130 currInterval = None;
131 setupNone();
132 break;
133 case OPimRecurrence::Daily:
134 currInterval = Day;
135 setupDaily();
136 break;
137 case OPimRecurrence::Weekly:
138 currInterval = Week;
139 setupWeekly();
140 int day, buttons;
141 for ( day = 0x01, buttons = 0; buttons < 7;
142 day = day << 1, buttons++ ) {
143 if ( rp.days() & day ) {
144 if ( startWeekOnMonday )
145 fraExtra->setButton( buttons );
146 else {
147 if ( buttons == 7 )
148 fraExtra->setButton( 0 );
149 else
150 fraExtra->setButton( buttons + 1 );
151 }
152 }
153 }
154 slotWeekLabel();
155 break;
156 case OPimRecurrence::MonthlyDay:
157 currInterval = Month;
158 setupMonthly();
159 fraExtra->setButton( 0 );
160 slotMonthLabel( 0 );
161 break;
162 case OPimRecurrence::MonthlyDate:
163 currInterval = Month;
164 setupMonthly();
165 fraExtra->setButton( 1 );
166 slotMonthLabel( 1 );
167 break;
168 case OPimRecurrence::Yearly:
169 currInterval = Year;
170 setupYearly();
171 break;
172 }
173 fraType->setButton( currInterval );
174 spinFreq->setValue( rp.frequency() );
175 if ( !rp.hasEndDate() ) {
176 cmdEnd->setText( tr("No End Date") );
177 chkNoEnd->setChecked( TRUE );
178 } else
179 cmdEnd->setText( TimeString::shortDate( end ) );
180}
181
182/**
183 * the user selected recurrence rule.
184 * @return The recurrence rule.
185 */
186OPimRecurrence OPimRecurrenceWidget::recurrence()const {
187 QListIterator<QToolButton> it( listRTypeButtons );
188 QListIterator<QToolButton> itExtra( listExtra );
189 OPimRecurrence rpTmp;
190 int i;
191 for ( i = 0; *it; ++it, i++ ) {
192 if ( (*it)->isOn() ) {
193 switch ( i ) {
194 case None:
195 rpTmp.setType( OPimRecurrence::NoRepeat );
196 break;
197 case Day:
198 rpTmp.setType( OPimRecurrence::Daily );
199 break;
200 case Week:{
201 rpTmp.setType( OPimRecurrence::Weekly );
202 int day;
203 int day2 = 0;
204 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
205 if ( (*itExtra)->isOn() ) {
206 if ( startWeekOnMonday )
207 day2 |= day;
208 else {
209 if ( day == 1 )
210 day2 |= Event::SUN;
211 else
212 day2 |= day >> 1;
213 }
214 }
215 }
216 rpTmp.setDays( day2 );
217 }
218 break;
219 case Month:
220 if ( cmdExtra1->isOn() )
221 rpTmp.setType( OPimRecurrence::MonthlyDay );
222 else if ( cmdExtra2->isOn() )
223 rpTmp.setType( OPimRecurrence::MonthlyDate );
224 // figure out the montly day...
225 rpTmp.setPosition( week( start ) );
226 break;
227 case Year:
228 rpTmp.setType( OPimRecurrence::Yearly );
229 break;
230 }
231 break; // no need to keep looking!
232 }
233 }
234 rpTmp.setFrequency(spinFreq->value() );
235 rpTmp.setHasEndDate( !chkNoEnd->isChecked() );
236 if ( rpTmp.hasEndDate() ) {
237 rpTmp.setEndDate( end );
238 }
239 // timestamp it...
240// rpTmp.setCreateTime( ); current DateTime is already set -zecke
241 return rpTmp;
242}
243
244/**
245 * Return the end date of the recurrence. This is only
246 * valid if the recurrence rule does contain an enddate
247 */
248QDate OPimRecurrenceWidget::endDate()const {
249 return end;
250}
251void OPimRecurrenceWidget::slotSetRType(int rtype) {
252 // now call the right function based on the type...
253 currInterval = static_cast<repeatButtons>(rtype);
254 switch ( currInterval ) {
255 case None:
256 setupNone();
257 break;
258 case Day:
259 setupDaily();
260 break;
261 case Week:
262 setupWeekly();
263 slotWeekLabel();
264 break;
265 case Month:
266 setupMonthly();
267 cmdExtra2->setOn( TRUE );
268 slotMonthLabel( 1 );
269 break;
270 case Year:
271 setupYearly();
272 break;
273 }
274}
275void OPimRecurrenceWidget::endDateChanged(int y, int m, int d) {
276 end.setYMD( y, m, d );
277 if ( end < start )
278 end = start;
279 cmdEnd->setText( TimeString::shortDate( end ) );
280 repeatPicker->setDate( end.year(), end.month(), end.day() );
281}
282void OPimRecurrenceWidget::slotNoEnd( bool unused) {
283 // if the item was toggled, then go ahead and set it to the maximum date
284 if ( unused ) {
285 end.setYMD( 3000, 12, 31 );
286 cmdEnd->setText( tr("No End Date") );
287 } else {
288 end = start;
289 cmdEnd->setText( TimeString::shortDate(end) );
290 }
291}
292void OPimRecurrenceWidget::setupRepeatLabel( const QString& s) {
293 lblVar1->setText( s );
294}
295void OPimRecurrenceWidget::setupRepeatLabel( int x) {
296 // change the spelling based on the value of x
297 QString strVar2;
298
299 if ( x > 1 )
300 lblVar1->show();
301 else
302 lblVar1->hide();
303
304 switch ( currInterval ) {
305 case None:
306 break;
307 case Day:
308 if ( x > 1 )
309 strVar2 = tr( "days" );
310 else
311 strVar2 = tr( "day" );
312 break;
313 case Week:
314 if ( x > 1 )
315 strVar2 = tr( "weeks" );
316 else
317 strVar2 = tr( "week" );
318 break;
319 case Month:
320 if ( x > 1 )
321 strVar2 = tr( "months" );
322 else
323 strVar2 = tr( "month" );
324 break;
325 case Year:
326 if ( x > 1 )
327 strVar2 = tr( "years" );
328 else
329 strVar2 = tr( "year" );
330 break;
331 }
332 if ( !strVar2.isNull() )
333 lblVar2->setText( strVar2 );
334}
335void OPimRecurrenceWidget::slotWeekLabel() {
336 QString str;
337 QListIterator<QToolButton> it( listExtra );
338 unsigned int i;
339 unsigned int keepMe;
340 bool bNeedCarriage = FALSE;
341 // don't do something we'll regret!!!
342 if ( currInterval != Week )
343 return;
344
345 if ( startWeekOnMonday )
346 keepMe = start.dayOfWeek() - 1;
347 else
348 keepMe = start.dayOfWeek() % 7;
349
350 QStringList list;
351 for ( i = 0; *it; ++it, i++ ) {
352 // a crazy check, if you are repeating weekly, the current day
353 // must be selected!!!
354 if ( i == keepMe && !( (*it)->isOn() ) )
355 (*it)->setOn( TRUE );
356 if ( (*it)->isOn() ) {
357 if ( startWeekOnMonday )
358 list.append( dayLabel[i] );
359 else {
360 if ( i == 0 )
361 list.append( dayLabel[6] );
362 else
363 list.append( dayLabel[i - 1] );
364 }
365 }
366 }
367 QStringList::Iterator itStr;
368 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
369 if ( i == 3 )
370 bNeedCarriage = TRUE;
371 else
372 bNeedCarriage = FALSE;
373 if ( str.isNull() )
374 str = *itStr;
375 else if ( i == list.count() - 1 ) {
376 if ( i < 2 )
377 str += tr(" and ") + *itStr;
378 else {
379 if ( bNeedCarriage )
380 str += tr( ",\nand " ) + *itStr;
381 else
382 str += tr( ", and " ) + *itStr;
383 }
384 } else {
385 if ( bNeedCarriage )
386 str += ",\n" + *itStr;
387 else
388 str += ", " + *itStr;
389 }
390 }
391 str = str.prepend( tr("on ") );
392
393 lblWeekVar->setText( str );
394}
395void OPimRecurrenceWidget::slotMonthLabel(int type) {
396 QString str;
397 if ( currInterval != Month || type > 1 )
398 return;
399 if ( type == 1 )
400 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
401 else
402 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
403 .arg( dayLabel[start.dayOfWeek() - 1] );
404 lblRepeat->setText( str );
405}
406void OPimRecurrenceWidget::slotChangeStartOfWeek( bool onMonday ) {
407 startWeekOnMonday = onMonday;
408 // we need to make this unintrusive as possible...
409 int saveSpin = spinFreq->value();
410 char days = 0;
411 int day;
412 QListIterator<QToolButton> itExtra( listExtra );
413 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
414 if ( (*itExtra)->isOn() ) {
415 if ( !startWeekOnMonday )
416 days |= day;
417 else {
418 if ( day == 1 )
419 days |= OPimRecurrence::SUN;
420 else
421 days |= day >> 1;
422 }
423 }
424 }
425 setupWeekly();
426 spinFreq->setValue( saveSpin );
427 int buttons;
428 for ( day = 0x01, buttons = 0; buttons < 7;
429 day = day << 1, buttons++ ) {
430 if ( days & day ) {
431 if ( startWeekOnMonday )
432 fraExtra->setButton( buttons );
433 else {
434 if ( buttons == 7 )
435 fraExtra->setButton( 0 );
436 else
437 fraExtra->setButton( buttons + 1 );
438 }
439 }
440 }
441 slotWeekLabel();
442}
443void OPimRecurrenceWidget::setupNone() {
444 lblRepeat->setText( tr("No Repeat") );
445 lblVar1->hide();
446 lblVar2->hide();
447 hideExtras();
448 cmdEnd->hide();
449 lblFreq->hide();
450 lblEvery->hide();
451 lblFreq->hide();
452 spinFreq->hide();
453 lblEnd->hide();
454 lblWeekVar->hide();
455}
456void OPimRecurrenceWidget::setupDaily() {
457 hideExtras();
458 lblWeekVar->hide();
459 spinFreq->setValue( 1 );
460 lblFreq->setText( tr("day(s)") );
461 lblVar2->show();
462 showRepeatStuff();
463 lblRepeat->setText( strDayTemplate );
464 setupRepeatLabel( 1 );
465}
466void OPimRecurrenceWidget::setupWeekly() {
467// reshow the buttons...
468 fraExtra->setTitle( tr("Repeat On") );
469 fraExtra->setExclusive( FALSE );
470 fraExtra->show();
471 if ( startWeekOnMonday ) {
472 cmdExtra1->setText( tr("Mon") );
473 cmdExtra2->setText( tr("Tue") );
474 cmdExtra3->setText( tr("Wed") );
475 cmdExtra4->setText( tr("Thu") );
476 cmdExtra5->setText( tr("Fri") );
477 cmdExtra6->setText( tr("Sat") );
478 cmdExtra7->setText( tr("Sun") );
479 } else {
480 cmdExtra1->setText( tr("Sun") );
481 cmdExtra2->setText( tr("Mon") );
482 cmdExtra3->setText( tr("Tue") );
483 cmdExtra4->setText( tr("Wed") );
484 cmdExtra5->setText( tr("Thu") );
485 cmdExtra6->setText( tr("Fri") );
486 cmdExtra7->setText( tr("Sat") );
487 }
488 // I hope clustering these improve performance....
489 cmdExtra1->setOn( FALSE );
490 cmdExtra2->setOn( FALSE );
491 cmdExtra3->setOn( FALSE );
492 cmdExtra4->setOn( FALSE );
493 cmdExtra5->setOn( FALSE );
494 cmdExtra6->setOn( FALSE );
495 cmdExtra7->setOn( FALSE );
496
497 cmdExtra1->show();
498 cmdExtra2->show();
499 cmdExtra3->show();
500 cmdExtra4->show();
501 cmdExtra5->show();
502 cmdExtra6->show();
503 cmdExtra7->show();
504
505 lblWeekVar->show();
506 spinFreq->setValue( 1 );
507 // might as well set the day too...
508 if ( startWeekOnMonday ) {
509 fraExtra->setButton( start.dayOfWeek() - 1 );
510 } else {
511 fraExtra->setButton( start.dayOfWeek() % 7 );
512 }
513 lblFreq->setText( tr("week(s)") );
514 lblVar2->show();
515 showRepeatStuff();
516 setupRepeatLabel( 1 );
517}
518void OPimRecurrenceWidget::setupMonthly() {
519 hideExtras();
520 lblWeekVar->hide();
521 fraExtra->setTitle( tr("Repeat By") );
522 fraExtra->setExclusive( TRUE );
523 fraExtra->show();
524 cmdExtra1->setText( tr("Day") );
525 cmdExtra1->show();
526 cmdExtra2->setText( tr("Date") );
527 cmdExtra2->show();
528 spinFreq->setValue( 1 );
529 lblFreq->setText( tr("month(s)") );
530 lblVar2->show();
531 showRepeatStuff();
532 setupRepeatLabel( 1 );
533}
534void OPimRecurrenceWidget::setupYearly() {
535hideExtras();
536 lblWeekVar->hide();
537 spinFreq->setValue( 1 );
538 lblFreq->setText( tr("year(s)") );
539 lblFreq->show();
540 lblFreq->show();
541 showRepeatStuff();
542 lblVar2->show();
543 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
544 lblRepeat->setText( strEvery );
545 setupRepeatLabel( 1 );
546
547}
548void OPimRecurrenceWidget::init() {
549 QPopupMenu *m1 = new QPopupMenu( this );
550 repeatPicker = new DateBookMonth( m1, 0, TRUE );
551 m1->insertItem( repeatPicker );
552 cmdEnd->setPopup( m1 );
553 cmdEnd->setPopupDelay( 0 );
554
555 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)),
556 this, SLOT(endDateChanged(int, int, int)) );
557 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
558 this, SLOT(slotChangeStartOfWeek(bool)) );
559
560 listRTypeButtons.setAutoDelete( TRUE );
561 listRTypeButtons.append( cmdNone );
562 listRTypeButtons.append( cmdDay );
563 listRTypeButtons.append( cmdWeek );
564 listRTypeButtons.append( cmdMonth );
565 listRTypeButtons.append( cmdYear );
566
567 listExtra.setAutoDelete( TRUE );
568 listExtra.append( cmdExtra1 );
569 listExtra.append( cmdExtra2 );
570 listExtra.append( cmdExtra3 );
571 listExtra.append( cmdExtra4 );
572 listExtra.append( cmdExtra5 );
573 listExtra.append( cmdExtra6 );
574 listExtra.append( cmdExtra7 );
575}
576void OPimRecurrenceWidget::hideExtras() {
577 // hide the extra buttons...
578 fraExtra->hide();
579 chkNoEnd->hide();
580 QListIterator<QToolButton> it( listExtra );
581 for ( ; *it; ++it ) {
582 (*it)->hide();
583 (*it)->setOn( FALSE );
584 }
585}
586void OPimRecurrenceWidget::showRepeatStuff() {
587 cmdEnd->show();
588 chkNoEnd->show();
589 lblFreq->show();
590 lblEvery->show();
591 lblFreq->show();
592 spinFreq->show();
593 lblEnd->show();
594 lblRepeat->setText( tr("Every") );
595}
596
597
598static int week( const QDate &start )
599{
600 // figure out the week...
601 int stop = start.day(),
602 sentinel = start.dayOfWeek(),
603 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
604 week = 1,
605 i;
606 for ( i = 1; i < stop; i++ ) {
607 if ( dayOfWeek++ == sentinel )
608 week++;
609 if ( dayOfWeek > 7 )
610 dayOfWeek = 0;
611 }
612 return week;
613}
614
615static QString numberPlacing( int x )
616{
617 // I hope this works in other languages besides english...
618 QString str = QString::number( x );
619 switch ( x % 10 ) {
620 case 1:
621 str += QWidget::tr( "st" );
622 break;
623 case 2:
624 str += QWidget::tr( "nd" );
625 break;
626 case 3:
627 str += QWidget::tr( "rd" );
628 break;
629 default:
630 str += QWidget::tr( "th" );
631 break;
632 }
633 return str;
634}
diff --git a/libopie2/opiepim/ui/opimrecurrencewidget.h b/libopie2/opiepim/ui/opimrecurrencewidget.h
new file mode 100644
index 0000000..3f28565
--- a/dev/null
+++ b/libopie2/opiepim/ui/opimrecurrencewidget.h
@@ -0,0 +1,93 @@
1/*
2 * GPL and based on the widget from TT
3 */
4
5#ifndef OPIE_PIM_RECURRENCE_WIDGET_H
6#define OPIE_PIM_RECURRENCE_WIDGET_H
7
8#include <opie2/opimrecurrence.h>
9
10#include <qpe/datebookmonth.h>
11
12#include <qlist.h>
13#include <qtoolbutton.h>
14#include <qcheckbox.h>
15#include <qdatetime.h>
16#include <qbuttongroup.h>
17
18#include "opimrecurrencebase.h"
19
20using namespace Opie;
21
22/**
23 * A widget to let the user select rules for recurrences.
24 * This widget can take care of weekly, monthly, daily and yearly recurrence
25 * It is used inside todolist and datebook.
26 *
27 *
28 * @short Widget of selecting Recurrance
29 * @author Trolltech, Holger Freyther
30 * @version 0.9
31 */
32class OPimRecurrenceWidget : public OPimRecurrenceBase {
33 Q_OBJECT
34public:
35 OPimRecurrenceWidget( bool startOnMonday,
36 const QDate& start, QWidget* parent = 0,
37 const char* name = 0, bool modal = TRUE,
38 WFlags fl = 0 );
39 OPimRecurrenceWidget( bool startOnMonday,
40 const OPimRecurrence& rp, const QDate& start,
41 QWidget* parent = 0, const char* name =0,
42 bool modal = TRUE, WFlags = 0 );
43 ~OPimRecurrenceWidget();
44 OPimRecurrence recurrence()const;
45 QDate endDate()const;
46
47public slots:
48 void slotSetRType( int );
49 /**
50 * set the new end date
51 */
52 void endDateChanged( int, int, int );
53 /**
54 * enable/disable end date
55 */
56 void slotNoEnd( bool unused );
57 void setStartDate( const QDate& );
58 void setRecurrence( const OPimRecurrence& recur, const QDate& start );
59 void setRecurrence( const OPimRecurrence& recur );
60
61private slots:
62 void setupRepeatLabel( const QString& );
63 void setupRepeatLabel( int );
64 void slotWeekLabel();
65 void slotMonthLabel( int );
66 void slotChangeStartOfWeek( bool onMonday );
67
68private:
69 void setupNone();
70 void setupDaily();
71 void setupWeekly();
72 void setupMonthly();
73 void setupYearly();
74
75 enum repeatButtons { None, Day, Week, Month, Year };
76 void init();
77 void hideExtras();
78 void showRepeatStuff();
79
80 QList<QToolButton> listRTypeButtons;
81 QList<QToolButton> listExtra;
82 QDate start; // only used in one spot...
83 QDate end;
84 repeatButtons currInterval;
85 bool startWeekOnMonday : 1;
86 DateBookMonth *repeatPicker;
87
88 class Private;
89 Private *d;
90
91};
92
93#endif
diff --git a/libopie2/opiepim/ui/ui.pro b/libopie2/opiepim/ui/ui.pro
index db19bca..530bd9f 100644
--- a/libopie2/opiepim/ui/ui.pro
+++ b/libopie2/opiepim/ui/ui.pro
@@ -1,3 +1,7 @@
1HEADERS += ui/opimmainwindow.h 1HEADERS += ui/opimmainwindow.h \
2 ui/opimrecurrencewidget.h
2 3
3SOURCES += ui/opimmainwindow.cpp 4SOURCES += ui/opimmainwindow.cpp \
5 ui/opimrecurrencewidget.cpp
6
7INTERFACES += ui/opimrecurrencebase.ui \ No newline at end of file