summaryrefslogtreecommitdiff
path: root/libopie
Unidiff
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/orecurrancebase.ui713
-rw-r--r--libopie/orecurrancewidget.cpp556
-rw-r--r--libopie/orecurrancewidget.h68
-rw-r--r--libopie/pim/libopie.pro6
-rw-r--r--libopie/pim/orecordlist.h2
-rw-r--r--libopie/pim/orecur.cpp127
-rw-r--r--libopie/pim/orecur.h54
-rw-r--r--libopie/pim/otodoaccesssql.cpp2
8 files changed, 1525 insertions, 3 deletions
diff --git a/libopie/orecurrancebase.ui b/libopie/orecurrancebase.ui
new file mode 100644
index 0000000..baf79d3
--- a/dev/null
+++ b/libopie/orecurrancebase.ui
@@ -0,0 +1,713 @@
1<!DOCTYPE UI><UI>
2<class>ORecurranceBase</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>ORecurranceBase</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>ORecurranceBase</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>ORecurranceBase</receiver>
686 <slot>setupRepeatLabel( int )</slot>
687 </connection>
688 <connection>
689 <sender>fraType</sender>
690 <signal>clicked(int)</signal>
691 <receiver>ORecurranceBase</receiver>
692 <slot>slotSetRType( int )</slot>
693 </connection>
694 <connection>
695 <sender>fraExtra</sender>
696 <signal>clicked(int)</signal>
697 <receiver>ORecurranceBase</receiver>
698 <slot>slotMonthLabel( int )</slot>
699 </connection>
700 <connection>
701 <sender>fraExtra</sender>
702 <signal>clicked(int)</signal>
703 <receiver>ORecurranceBase</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/libopie/orecurrancewidget.cpp b/libopie/orecurrancewidget.cpp
new file mode 100644
index 0000000..53cee65
--- a/dev/null
+++ b/libopie/orecurrancewidget.cpp
@@ -0,0 +1,556 @@
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 "orecurrancewidget.h"
9
10// Global Templates for use in setting up the repeat label...
11const QString strDayTemplate = QObject::tr("Every");
12const QString strYearTemplate = QObject::tr("%1 %2 every ");
13const QString strMonthDateTemplate = QObject::tr("The %1 every ");
14const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every");
15const QString strWeekTemplate = QObject::tr("Every ");
16const QString dayLabel[] = { QObject::tr("Monday"),
17 QObject::tr("Tuesday"),
18 QObject::tr("Wednesday"),
19 QObject::tr("Thursday"),
20 QObject::tr("Friday"),
21 QObject::tr("Saturday"),
22 QObject::tr("Sunday") };
23
24
25 static QString numberPlacing( int x );// return the proper word format for
26 // x (1st, 2nd, etc)
27static int week( const QDate &dt ); // what week in the month is dt?
28
29
30ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
31 const QDate& newStart,
32 QWidget* parent,
33 const char* name,
34 bool modal,
35 WFlags fl )
36 : ORecurranceBase( parent, name, modal, fl ),
37 start( newStart ),
38 currInterval( None ),
39 startWeekOnMonday( startOnMonday )
40{
41 init();
42 fraType->setButton( currInterval );
43 chkNoEnd->setChecked( TRUE );
44 setupNone();
45}
46ORecurranceWidget::ORecurranceWidget( bool startOnMonday,
47 const ORecur& rp, const QDate& startDate,
48 QWidget* parent, const char* name,
49 bool modal, WFlags fl)
50 : ORecurranceBase( parent, name, modal, fl ),
51 start( startDate ),
52 end( rp.endDate() ),
53 startWeekOnMonday( startOnMonday )
54{
55 // do some stuff with the repeat pattern
56 init();
57 switch ( rp.type() ) {
58 default:
59 case ORecur::NoRepeat:
60 currInterval = None;
61 setupNone();
62 break;
63 case ORecur::Daily:
64 currInterval = Day;
65 setupDaily();
66 break;
67 case ORecur::Weekly:
68 currInterval = Week;
69 setupWeekly();
70 int day, buttons;
71 for ( day = 0x01, buttons = 0; buttons < 7;
72 day = day << 1, buttons++ ) {
73 if ( rp.days() & day ) {
74 if ( startWeekOnMonday )
75 fraExtra->setButton( buttons );
76 else {
77 if ( buttons == 7 )
78 fraExtra->setButton( 0 );
79 else
80 fraExtra->setButton( buttons + 1 );
81 }
82 }
83 }
84 slotWeekLabel();
85 break;
86 case ORecur::MonthlyDay:
87 currInterval = Month;
88 setupMonthly();
89 fraExtra->setButton( 0 );
90 slotMonthLabel( 0 );
91 break;
92 case ORecur::MonthlyDate:
93 currInterval = Month;
94 setupMonthly();
95 fraExtra->setButton( 1 );
96 slotMonthLabel( 1 );
97 break;
98 case ORecur::Yearly:
99 currInterval = Year;
100 setupYearly();
101 break;
102 }
103 fraType->setButton( currInterval );
104 spinFreq->setValue( rp.frequency() );
105 if ( !rp.hasEndDate() ) {
106 cmdEnd->setText( tr("No End Date") );
107 chkNoEnd->setChecked( TRUE );
108 } else
109 cmdEnd->setText( TimeString::shortDate( end ) );
110}
111ORecurranceWidget::~ORecurranceWidget() {
112
113}
114ORecur ORecurranceWidget::recurrance()const {
115 QListIterator<QToolButton> it( listRTypeButtons );
116 QListIterator<QToolButton> itExtra( listExtra );
117 ORecur rpTmp;
118 int i;
119 for ( i = 0; *it; ++it, i++ ) {
120 if ( (*it)->isOn() ) {
121 switch ( i ) {
122 case None:
123 rpTmp.setType( ORecur::NoRepeat );
124 break;
125 case Day:
126 rpTmp.setType( ORecur::Daily );
127 break;
128 case Week:{
129 rpTmp.setType( ORecur::Weekly );
130 int day;
131 int day2 = 0;
132 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
133 if ( (*itExtra)->isOn() ) {
134 if ( startWeekOnMonday )
135 day2 |= day;
136 else {
137 if ( day == 1 )
138 day2 |= Event::SUN;
139 else
140 day2 |= day >> 1;
141 }
142 }
143 }
144 rpTmp.setDays( day2 );
145 }
146 break;
147 case Month:
148 if ( cmdExtra1->isOn() )
149 rpTmp.setType( ORecur::MonthlyDay );
150 else if ( cmdExtra2->isOn() )
151 rpTmp.setType( ORecur::MonthlyDate );
152 // figure out the montly day...
153 rpTmp.setPosition( week( start ) );
154 break;
155 case Year:
156 rpTmp.setType( ORecur::Yearly );
157 break;
158 }
159 break; // no need to keep looking!
160 }
161 }
162 rpTmp.setFrequency(spinFreq->value() );
163 rpTmp.setHasEndDate( !chkNoEnd->isChecked() );
164 if ( rpTmp.hasEndDate() ) {
165 rpTmp.setEndDate( end );
166 }
167 // timestamp it...
168 rpTmp.setCreateTime( time( NULL ) );
169 return rpTmp;
170}
171QDate ORecurranceWidget::endDate()const {
172 return end;
173}
174void ORecurranceWidget::slotSetRType(int rtype) {
175 // now call the right function based on the type...
176 currInterval = static_cast<repeatButtons>(rtype);
177 switch ( currInterval ) {
178 case None:
179 setupNone();
180 break;
181 case Day:
182 setupDaily();
183 break;
184 case Week:
185 setupWeekly();
186 slotWeekLabel();
187 break;
188 case Month:
189 setupMonthly();
190 cmdExtra2->setOn( TRUE );
191 slotMonthLabel( 1 );
192 break;
193 case Year:
194 setupYearly();
195 break;
196 }
197}
198void ORecurranceWidget::endDateChanged(int y, int m, int d) {
199 end.setYMD( y, m, d );
200 if ( end < start )
201 end = start;
202 cmdEnd->setText( TimeString::shortDate( end ) );
203 repeatPicker->setDate( end.year(), end.month(), end.day() );
204}
205void ORecurranceWidget::slotNoEnd( bool unused) {
206 // if the item was toggled, then go ahead and set it to the maximum date
207 if ( unused ) {
208 end.setYMD( 3000, 12, 31 );
209 cmdEnd->setText( tr("No End Date") );
210 } else {
211 end = start;
212 cmdEnd->setText( TimeString::shortDate(end) );
213 }
214}
215void ORecurranceWidget::setupRepeatLabel( const QString& s) {
216 lblVar1->setText( s );
217}
218void ORecurranceWidget::setupRepeatLabel( int x) {
219 // change the spelling based on the value of x
220 QString strVar2;
221
222 if ( x > 1 )
223 lblVar1->show();
224 else
225 lblVar1->hide();
226
227 switch ( currInterval ) {
228 case None:
229 break;
230 case Day:
231 if ( x > 1 )
232 strVar2 = tr( "days" );
233 else
234 strVar2 = tr( "day" );
235 break;
236 case Week:
237 if ( x > 1 )
238 strVar2 = tr( "weeks" );
239 else
240 strVar2 = tr( "week" );
241 break;
242 case Month:
243 if ( x > 1 )
244 strVar2 = tr( "months" );
245 else
246 strVar2 = tr( "month" );
247 break;
248 case Year:
249 if ( x > 1 )
250 strVar2 = tr( "years" );
251 else
252 strVar2 = tr( "year" );
253 break;
254 }
255 if ( !strVar2.isNull() )
256 lblVar2->setText( strVar2 );
257}
258void ORecurranceWidget::slotWeekLabel() {
259 QString str;
260 QListIterator<QToolButton> it( listExtra );
261 unsigned int i;
262 unsigned int keepMe;
263 bool bNeedCarriage = FALSE;
264 // don't do something we'll regret!!!
265 if ( currInterval != Week )
266 return;
267
268 if ( startWeekOnMonday )
269 keepMe = start.dayOfWeek() - 1;
270 else
271 keepMe = start.dayOfWeek() % 7;
272
273 QStringList list;
274 for ( i = 0; *it; ++it, i++ ) {
275 // a crazy check, if you are repeating weekly, the current day
276 // must be selected!!!
277 if ( i == keepMe && !( (*it)->isOn() ) )
278 (*it)->setOn( TRUE );
279 if ( (*it)->isOn() ) {
280 if ( startWeekOnMonday )
281 list.append( dayLabel[i] );
282 else {
283 if ( i == 0 )
284 list.append( dayLabel[6] );
285 else
286 list.append( dayLabel[i - 1] );
287 }
288 }
289 }
290 QStringList::Iterator itStr;
291 for ( i = 0, itStr = list.begin(); itStr != list.end(); ++itStr, i++ ) {
292 if ( i == 3 )
293 bNeedCarriage = TRUE;
294 else
295 bNeedCarriage = FALSE;
296 if ( str.isNull() )
297 str = *itStr;
298 else if ( i == list.count() - 1 ) {
299 if ( i < 2 )
300 str += tr(" and ") + *itStr;
301 else {
302 if ( bNeedCarriage )
303 str += tr( ",\nand " ) + *itStr;
304 else
305 str += tr( ", and " ) + *itStr;
306 }
307 } else {
308 if ( bNeedCarriage )
309 str += ",\n" + *itStr;
310 else
311 str += ", " + *itStr;
312 }
313 }
314 str = str.prepend( "on " );
315 lblWeekVar->setText( str );
316}
317void ORecurranceWidget::slotMonthLabel(int type) {
318 QString str;
319 if ( currInterval != Month || type > 1 )
320 return;
321 if ( type == 1 )
322 str = strMonthDateTemplate.arg( numberPlacing(start.day()) );
323 else
324 str = strMonthDayTemplate.arg( numberPlacing(week(start)))
325 .arg( dayLabel[start.dayOfWeek() - 1] );
326 lblRepeat->setText( str );
327}
328void ORecurranceWidget::slotChangeStartOfWeek( bool onMonday ) {
329 startWeekOnMonday = onMonday;
330 // we need to make this unintrusive as possible...
331 int saveSpin = spinFreq->value();
332 char days = 0;
333 int day;
334 QListIterator<QToolButton> itExtra( listExtra );
335 for ( day = 1; *itExtra; ++itExtra, day = day << 1 ) {
336 if ( (*itExtra)->isOn() ) {
337 if ( !startWeekOnMonday )
338 days |= day;
339 else {
340 if ( day == 1 )
341 days |= ORecur::SUN;
342 else
343 days |= day >> 1;
344 }
345 }
346 }
347 setupWeekly();
348 spinFreq->setValue( saveSpin );
349 int buttons;
350 for ( day = 0x01, buttons = 0; buttons < 7;
351 day = day << 1, buttons++ ) {
352 if ( days & day ) {
353 if ( startWeekOnMonday )
354 fraExtra->setButton( buttons );
355 else {
356 if ( buttons == 7 )
357 fraExtra->setButton( 0 );
358 else
359 fraExtra->setButton( buttons + 1 );
360 }
361 }
362 }
363 slotWeekLabel();
364}
365void ORecurranceWidget::setupNone() {
366 lblRepeat->setText( tr("No Repeat") );
367 lblVar1->hide();
368 lblVar2->hide();
369 hideExtras();
370 cmdEnd->hide();
371 lblFreq->hide();
372 lblEvery->hide();
373 lblFreq->hide();
374 spinFreq->hide();
375 lblEnd->hide();
376 lblWeekVar->hide();
377}
378void ORecurranceWidget::setupDaily() {
379 hideExtras();
380 lblWeekVar->hide();
381 spinFreq->setValue( 1 );
382 lblFreq->setText( tr("day(s)") );
383 lblVar2->show();
384 showRepeatStuff();
385 lblRepeat->setText( strDayTemplate );
386 setupRepeatLabel( 1 );
387}
388void ORecurranceWidget::setupWeekly() {
389// reshow the buttons...
390 fraExtra->setTitle( tr("Repeat On") );
391 fraExtra->setExclusive( FALSE );
392 fraExtra->show();
393 if ( startWeekOnMonday ) {
394 cmdExtra1->setText( tr("Mon") );
395 cmdExtra2->setText( tr("Tue") );
396 cmdExtra3->setText( tr("Wed") );
397 cmdExtra4->setText( tr("Thu") );
398 cmdExtra5->setText( tr("Fri") );
399 cmdExtra6->setText( tr("Sat") );
400 cmdExtra7->setText( tr("Sun") );
401 } else {
402 cmdExtra1->setText( tr("Sun") );
403 cmdExtra2->setText( tr("Mon") );
404 cmdExtra3->setText( tr("Tue") );
405 cmdExtra4->setText( tr("Wed") );
406 cmdExtra5->setText( tr("Thu") );
407 cmdExtra6->setText( tr("Fri") );
408 cmdExtra7->setText( tr("Sat") );
409 }
410 // I hope clustering these improve performance....
411 cmdExtra1->setOn( FALSE );
412 cmdExtra2->setOn( FALSE );
413 cmdExtra3->setOn( FALSE );
414 cmdExtra4->setOn( FALSE );
415 cmdExtra5->setOn( FALSE );
416 cmdExtra6->setOn( FALSE );
417 cmdExtra7->setOn( FALSE );
418
419 cmdExtra1->show();
420 cmdExtra2->show();
421 cmdExtra3->show();
422 cmdExtra4->show();
423 cmdExtra5->show();
424 cmdExtra6->show();
425 cmdExtra7->show();
426
427 lblWeekVar->show();
428 spinFreq->setValue( 1 );
429 // might as well set the day too...
430 if ( startWeekOnMonday ) {
431 fraExtra->setButton( start.dayOfWeek() - 1 );
432 } else {
433 fraExtra->setButton( start.dayOfWeek() % 7 );
434 }
435 lblFreq->setText( tr("week(s)") );
436 lblVar2->show();
437 showRepeatStuff();
438 setupRepeatLabel( 1 );
439}
440void ORecurranceWidget::setupMonthly() {
441 hideExtras();
442 lblWeekVar->hide();
443 fraExtra->setTitle( tr("Repeat By") );
444 fraExtra->setExclusive( TRUE );
445 fraExtra->show();
446 cmdExtra1->setText( tr("Day") );
447 cmdExtra1->show();
448 cmdExtra2->setText( tr("Date") );
449 cmdExtra2->show();
450 spinFreq->setValue( 1 );
451 lblFreq->setText( tr("month(s)") );
452 lblVar2->show();
453 showRepeatStuff();
454 setupRepeatLabel( 1 );
455}
456void ORecurranceWidget::setupYearly() {
457hideExtras();
458 lblWeekVar->hide();
459 spinFreq->setValue( 1 );
460 lblFreq->setText( tr("year(s)") );
461 lblFreq->show();
462 lblFreq->show();
463 showRepeatStuff();
464 lblVar2->show();
465 QString strEvery = strYearTemplate.arg( start.monthName(start.month()) ).arg( numberPlacing(start.day()) );
466 lblRepeat->setText( strEvery );
467 setupRepeatLabel( 1 );
468
469}
470void ORecurranceWidget::init() {
471 QPopupMenu *m1 = new QPopupMenu( this );
472 repeatPicker = new DateBookMonth( m1, 0, TRUE );
473 m1->insertItem( repeatPicker );
474 cmdEnd->setPopup( m1 );
475 cmdEnd->setPopupDelay( 0 );
476
477 QObject::connect( repeatPicker, SIGNAL(dateClicked(int, int, int)),
478 this, SLOT(endDateChanged(int, int, int)) );
479 QObject::connect( qApp, SIGNAL(weekChanged(bool)),
480 this, SLOT(slotChangeStartOfWeek(bool)) );
481
482 listRTypeButtons.setAutoDelete( TRUE );
483 listRTypeButtons.append( cmdNone );
484 listRTypeButtons.append( cmdDay );
485 listRTypeButtons.append( cmdWeek );
486 listRTypeButtons.append( cmdMonth );
487 listRTypeButtons.append( cmdYear );
488
489 listExtra.setAutoDelete( TRUE );
490 listExtra.append( cmdExtra1 );
491 listExtra.append( cmdExtra2 );
492 listExtra.append( cmdExtra3 );
493 listExtra.append( cmdExtra4 );
494 listExtra.append( cmdExtra5 );
495 listExtra.append( cmdExtra6 );
496 listExtra.append( cmdExtra7 );
497}
498void ORecurranceWidget::hideExtras() {
499 // hide the extra buttons...
500 fraExtra->hide();
501 chkNoEnd->hide();
502 QListIterator<QToolButton> it( listExtra );
503 for ( ; *it; ++it ) {
504 (*it)->hide();
505 (*it)->setOn( FALSE );
506 }
507}
508void ORecurranceWidget::showRepeatStuff() {
509 cmdEnd->show();
510 chkNoEnd->show();
511 lblFreq->show();
512 lblEvery->show();
513 lblFreq->show();
514 spinFreq->show();
515 lblEnd->show();
516 lblRepeat->setText( tr("Every") );
517}
518
519
520static int week( const QDate &start )
521{
522 // figure out the week...
523 int stop = start.day(),
524 sentinel = start.dayOfWeek(),
525 dayOfWeek = QDate( start.year(), start.month(), 1 ).dayOfWeek(),
526 week = 1,
527 i;
528 for ( i = 1; i < stop; i++ ) {
529 if ( dayOfWeek++ == sentinel )
530 week++;
531 if ( dayOfWeek > 7 )
532 dayOfWeek = 0;
533 }
534 return week;
535}
536
537static QString numberPlacing( int x )
538{
539 // I hope this works in other languages besides english...
540 QString str = QString::number( x );
541 switch ( x % 10 ) {
542 case 1:
543 str += QWidget::tr( "st" );
544 break;
545 case 2:
546 str += QWidget::tr( "nd" );
547 break;
548 case 3:
549 str += QWidget::tr( "rd" );
550 break;
551 default:
552 str += QWidget::tr( "th" );
553 break;
554 }
555 return str;
556}
diff --git a/libopie/orecurrancewidget.h b/libopie/orecurrancewidget.h
new file mode 100644
index 0000000..f2d7f87
--- a/dev/null
+++ b/libopie/orecurrancewidget.h
@@ -0,0 +1,68 @@
1/*
2 * GPL and based on the widget from TT
3 */
4
5#ifndef OPIE_RECURRANCE_WIDGET_H
6#define OPIE_RECURRANCE_WIDGET_H
7
8#include <qlist.h>
9#include <qtoolbutton.h>
10#include <qcheckbox.h>
11#include <qdatetime.h>
12#include <qbuttongroup.h>
13
14#include <qpe/datebookmonth.h>
15
16#include "orecurrancebase.h"
17#include <opie/orecur.h>
18
19class ORecurranceWidget : public ORecurranceBase {
20 Q_OBJECT
21public:
22 ORecurranceWidget( bool startOnMonday,
23 const QDate& start, QWidget* parent = 0,
24 const char* name = 0, bool modal = TRUE,
25 WFlags fl = 0 );
26 ORecurranceWidget( bool startOnMonday,
27 const ORecur& rp, const QDate& start,
28 QWidget* parent = 0, const char* name =0,
29 bool modal = TRUE, WFlags = 0 );
30 ~ORecurranceWidget();
31 ORecur recurrance()const;
32 QDate endDate()const;
33
34public slots:
35 void slotSetRType( int );
36 void endDateChanged( int, int, int );
37 void slotNoEnd( bool unused );
38
39private slots:
40 void setupRepeatLabel( const QString& );
41 void setupRepeatLabel( int );
42 void slotWeekLabel();
43 void slotMonthLabel( int );
44 void slotChangeStartOfWeek( bool onMonday );
45
46private:
47 void setupNone();
48 void setupDaily();
49 void setupWeekly();
50 void setupMonthly();
51 void setupYearly();
52
53 enum repeatButtons { None, Day, Week, Month, Year };
54 void init();
55 void hideExtras();
56 void showRepeatStuff();
57
58 QList<QToolButton> listRTypeButtons;
59 QList<QToolButton> listExtra;
60 QDate start; // only used in one spot...
61 QDate end;
62 repeatButtons currInterval;
63 bool startWeekOnMonday : 1;
64 DateBookMonth *repeatPicker;
65
66};
67
68#endif
diff --git a/libopie/pim/libopie.pro b/libopie/pim/libopie.pro
index 1dacbe7..b871374 100644
--- a/libopie/pim/libopie.pro
+++ b/libopie/pim/libopie.pro
@@ -27,7 +27,8 @@ HEADERS = ofontmenu.h \
27 pim/ocontact.h \ 27 pim/ocontact.h \
28 pim/ocontactaccess.h \ 28 pim/ocontactaccess.h \
29 pim/ocontactaccessbackend.h \ 29 pim/ocontactaccessbackend.h \
30 pim/ocontactaccessbackend_xml.h 30 pim/ocontactaccessbackend_xml.h \
31 pim/orecord.h
31 32
32SOURCES = ofontmenu.cc \ 33SOURCES = ofontmenu.cc \
33 xmltree.cc \ 34 xmltree.cc \
@@ -50,7 +51,8 @@ SOURCES = ofontmenu.cc \
50 pim/otodoaccess.cpp \ 51 pim/otodoaccess.cpp \
51 pim/otodoaccessbackend.cpp \ 52 pim/otodoaccessbackend.cpp \
52 pim/ocontact.cpp \ 53 pim/ocontact.cpp \
53 pim/ocontactaccess.cpp 54 pim/ocontactaccess.cpp \
55 pim/orecord.cpp
54 56
55TARGET = opie 57TARGET = opie
56INCLUDEPATH += $(OPIEDIR)/include 58INCLUDEPATH += $(OPIEDIR)/include
diff --git a/libopie/pim/orecordlist.h b/libopie/pim/orecordlist.h
index 5404910..e377447 100644
--- a/libopie/pim/orecordlist.h
+++ b/libopie/pim/orecordlist.h
@@ -260,6 +260,8 @@ return m_ids.count();
260} 260}
261template <class T> 261template <class T>
262T ORecordList<T>::operator[]( uint i ) { 262T ORecordList<T>::operator[]( uint i ) {
263 if ( i < 0 || (i+1) > m_ids.count() )
264 return T();
263 /* forward */ 265 /* forward */
264 return m_acc->find( m_ids[i], m_ids, i ); 266 return m_acc->find( m_ids[i], m_ids, i );
265} 267}
diff --git a/libopie/pim/orecur.cpp b/libopie/pim/orecur.cpp
new file mode 100644
index 0000000..6c81f8f
--- a/dev/null
+++ b/libopie/pim/orecur.cpp
@@ -0,0 +1,127 @@
1#include <qshared.h>
2
3#include <qtopia/timeconversion.h>
4
5#include "orecur.h"
6
7struct ORecur::Data : public QShared {
8 Data() : QShared() {
9 type = ORecur::NoRepeat;
10 freq = -1;
11 days = 0;
12 pos = 0;
13 create = -1;
14 hasEnd = FALSE;
15 end = 0;
16 }
17 char days; // Q_UINT8 for 8 seven days;)
18 ORecur::RepeatType type;
19 int freq;
20 int pos;
21 bool hasEnd : 1;
22 time_t end;
23 time_t create;
24};
25
26
27ORecur::ORecur() {
28 data = new Data;
29}
30ORecur::ORecur( const ORecur& rec)
31 : data( rec.data )
32{
33 data->ref();
34}
35ORecur::~ORecur() {
36 if ( data->deref() ) {
37 delete data;
38 data = 0l;
39 }
40}
41void ORecur::deref() {
42 if ( data->deref() ) {
43 delete data;
44 data = 0l;
45 }
46}
47bool ORecur::operator==( const ORecur& )const {
48 return false;
49}
50ORecur &ORecur::operator=( const ORecur& re) {
51 re.data->ref();
52 deref();
53 data = re.data;
54
55 return *this;
56}
57ORecur::RepeatType ORecur::type()const{
58 return data->type;
59}
60int ORecur::frequency()const {
61 return data->freq;
62}
63int ORecur::position()const {
64 return data->pos;
65}
66char ORecur::days() const{
67 return data->days;
68}
69bool ORecur::hasEndDate()const {
70 return data->hasEnd;
71}
72QDate ORecur::endDate()const {
73 return TimeConversion::fromUTC( data->end ).date();
74}
75time_t ORecur::endDateUTC()const {
76 return data->end;
77}
78time_t ORecur::createTime()const {
79 return data->create;
80}
81void ORecur::setType( const RepeatType& z) {
82 checkOrModify();
83 data->type = z;
84}
85void ORecur::setFrequency( int freq ) {
86 checkOrModify();
87 data->freq = freq;
88}
89void ORecur::setPosition( int pos ) {
90 checkOrModify();
91 data->pos = pos;
92}
93void ORecur::setDays( char c ) {
94 checkOrModify();
95 data->days = c;
96}
97void ORecur::setEndDate( const QDate& dt) {
98 checkOrModify();
99 data->end = TimeConversion::toUTC( dt );
100}
101void ORecur::setEndDateUTC( time_t t) {
102 checkOrModify();
103 data->end = t;
104}
105void ORecur::setCreateTime( time_t t) {
106 checkOrModify();
107 data->create = t;
108}
109void ORecur::setHasEndDate( bool b) {
110 checkOrModify();
111 data->hasEnd = b;
112}
113void ORecur::checkOrModify() {
114 if ( data->count != 1 ) {
115 data->deref();
116 Data* d2 = new Data;
117 d2->days = data->days;
118 d2->type = data->type;
119 d2->freq = data->freq;
120 d2->pos = data->pos;
121 d2->hasEnd = data->hasEnd;
122 d2->end = data->end;
123 d2->create = data->create;
124 data = d2;
125 }
126}
127
diff --git a/libopie/pim/orecur.h b/libopie/pim/orecur.h
new file mode 100644
index 0000000..89258f8
--- a/dev/null
+++ b/libopie/pim/orecur.h
@@ -0,0 +1,54 @@
1/*
2 * GPL from TT
3 */
4
5#ifndef OPIE_RECUR_H
6#define OPIE_RECUR_H
7
8#include <sys/types.h>
9
10#include <qdatetime.h>
11
12
13
14class ORecur {
15public:
16 enum RepeatType{ NoRepeat = -1, Daily, Weekly, MonthlyDay,
17 MonthlyDate, Yearly };
18 enum Days { MON = 0x01, TUE = 0x02, WED = 0x04, THU = 0x08,
19 FRI = 0x10, SAT = 0x20, SUN = 0x40 };
20 ORecur();
21 ORecur( const ORecur& );
22 ~ORecur();
23
24 ORecur &operator=( const ORecur& );
25 bool operator==(const ORecur& )const;
26 RepeatType type()const;
27 int frequency()const;
28 int position()const;
29 char days()const;
30 bool hasEndDate()const;
31 QDate endDate()const;
32 time_t endDateUTC()const;
33 time_t createTime()const;
34
35 void setType( const RepeatType& );
36 void setFrequency( int freq );
37 void setPosition( int pos );
38 void setDays( char c);
39 void setEndDate( const QDate& dt );
40 void setEndDateUTC( time_t );
41 void setCreateTime( time_t );
42 void setHasEndDate( bool b );
43private:
44 void deref();
45 inline void checkOrModify();
46
47
48 class Data;
49 Data* data;
50 class ORecurPrivate;
51 ORecurPrivate *d;
52};
53
54#endif
diff --git a/libopie/pim/otodoaccesssql.cpp b/libopie/pim/otodoaccesssql.cpp
index 8c2ea3a..761d7d8 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/libopie/pim/otodoaccesssql.cpp
@@ -421,7 +421,7 @@ QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
421 query += "priority"; 421 query += "priority";
422 break; 422 break;
423 case 2: 423 case 2:
424 query += "description"; 424 query += "summary";
425 break; 425 break;
426 case 3: 426 case 3:
427 query += "DueDate"; 427 query += "DueDate";