author | zecke <zecke> | 2002-10-20 12:15:51 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-20 12:15:51 (UTC) |
commit | 82689364fd558ccd28253961204e6b3eb9e32b03 (patch) (unidiff) | |
tree | aec5a649346194aa76aaadd9c7418b700ac4d3d3 /libopie | |
parent | 7948b5910a098d05f4cc7d0fb14b0f216bf41358 (diff) | |
download | opie-82689364fd558ccd28253961204e6b3eb9e32b03.zip opie-82689364fd558ccd28253961204e6b3eb9e32b03.tar.gz opie-82689364fd558ccd28253961204e6b3eb9e32b03.tar.bz2 |
Added ORecur which is a base class for Recurrance extracted from TT Event class
and a widget where you can set the Recurrance
This will be used at least in Todolist and Datebook and in the common
classes of OTodo and OEvent
Fixed the SQL in multiple ways it's summary not description for example
-rw-r--r-- | libopie/orecurrancebase.ui | 713 | ||||
-rw-r--r-- | libopie/orecurrancewidget.cpp | 556 | ||||
-rw-r--r-- | libopie/orecurrancewidget.h | 68 | ||||
-rw-r--r-- | libopie/pim/libopie.pro | 6 | ||||
-rw-r--r-- | libopie/pim/orecordlist.h | 2 | ||||
-rw-r--r-- | libopie/pim/orecur.cpp | 127 | ||||
-rw-r--r-- | libopie/pim/orecur.h | 54 | ||||
-rw-r--r-- | libopie/pim/otodoaccesssql.cpp | 2 |
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 & )</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... | ||
11 | const QString strDayTemplate = QObject::tr("Every"); | ||
12 | const QString strYearTemplate = QObject::tr("%1 %2 every "); | ||
13 | const QString strMonthDateTemplate = QObject::tr("The %1 every "); | ||
14 | const QString strMonthDayTemplate = QObject::tr("The %1 %1 of every"); | ||
15 | const QString strWeekTemplate = QObject::tr("Every "); | ||
16 | const 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) | ||
27 | static int week( const QDate &dt ); // what week in the month is dt? | ||
28 | |||
29 | |||
30 | ORecurranceWidget::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 | } | ||
46 | ORecurranceWidget::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 | } | ||
111 | ORecurranceWidget::~ORecurranceWidget() { | ||
112 | |||
113 | } | ||
114 | ORecur 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 | } | ||
171 | QDate ORecurranceWidget::endDate()const { | ||
172 | return end; | ||
173 | } | ||
174 | void 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 | } | ||
198 | void 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 | } | ||
205 | void 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 | } | ||
215 | void ORecurranceWidget::setupRepeatLabel( const QString& s) { | ||
216 | lblVar1->setText( s ); | ||
217 | } | ||
218 | void 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 | } | ||
258 | void 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 | } | ||
317 | void 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 | } | ||
328 | void 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 | } | ||
365 | void 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 | } | ||
378 | void 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 | } | ||
388 | void 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 | } | ||
440 | void 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 | } | ||
456 | void ORecurranceWidget::setupYearly() { | ||
457 | hideExtras(); | ||
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 | } | ||
470 | void 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 | } | ||
498 | void 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 | } | ||
508 | void 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 | |||
520 | static 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 | |||
537 | static 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 | |||
19 | class ORecurranceWidget : public ORecurranceBase { | ||
20 | Q_OBJECT | ||
21 | public: | ||
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 | |||
34 | public slots: | ||
35 | void slotSetRType( int ); | ||
36 | void endDateChanged( int, int, int ); | ||
37 | void slotNoEnd( bool unused ); | ||
38 | |||
39 | private slots: | ||
40 | void setupRepeatLabel( const QString& ); | ||
41 | void setupRepeatLabel( int ); | ||
42 | void slotWeekLabel(); | ||
43 | void slotMonthLabel( int ); | ||
44 | void slotChangeStartOfWeek( bool onMonday ); | ||
45 | |||
46 | private: | ||
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 | |||
@@ -1,75 +1,77 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = ofontmenu.h \ | 3 | HEADERS = ofontmenu.h \ |
4 | tododb.h \ | 4 | tododb.h \ |
5 | todoevent.h todoresource.h \ | 5 | todoevent.h todoresource.h \ |
6 | todovcalresource.h xmltree.h \ | 6 | todovcalresource.h xmltree.h \ |
7 | colordialog.h colorpopupmenu.h \ | 7 | colordialog.h colorpopupmenu.h \ |
8 | oclickablelabel.h oprocctrl.h \ | 8 | oclickablelabel.h oprocctrl.h \ |
9 | oprocess.h odevice.h \ | 9 | oprocess.h odevice.h \ |
10 | otimepicker.h otabwidget.h \ | 10 | otimepicker.h otabwidget.h \ |
11 | otabbar.h otabinfo.h \ | 11 | otabbar.h otabinfo.h \ |
12 | ofileselector/ofiledialog.h \ | 12 | ofileselector/ofiledialog.h \ |
13 | ofileselector/ofilelistview.h \ | 13 | ofileselector/ofilelistview.h \ |
14 | ofileselector/ofileselector.h \ | 14 | ofileselector/ofileselector.h \ |
15 | ofileselector/ofileselectoritem.h \ | 15 | ofileselector/ofileselectoritem.h \ |
16 | ofileselector/ofileview.h \ | 16 | ofileselector/ofileview.h \ |
17 | ofileselector/olister.h \ | 17 | ofileselector/olister.h \ |
18 | ofileselector/olocallister.h \ | 18 | ofileselector/olocallister.h \ |
19 | ofileselector/ofileselectormain.h \ | 19 | ofileselector/ofileselectormain.h \ |
20 | pim/opimrecord.h \ | 20 | pim/opimrecord.h \ |
21 | pim/otodo.h \ | 21 | pim/otodo.h \ |
22 | pim/orecordlist.h \ | 22 | pim/orecordlist.h \ |
23 | pim/opimaccesstemplate.h \ | 23 | pim/opimaccesstemplate.h \ |
24 | pim/opimaccessbackend.h \ | 24 | pim/opimaccessbackend.h \ |
25 | pim/otodoaccess.h \ | 25 | pim/otodoaccess.h \ |
26 | pim/otodacessbackend.h \ | 26 | pim/otodacessbackend.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 | ||
32 | SOURCES = ofontmenu.cc \ | 33 | SOURCES = ofontmenu.cc \ |
33 | xmltree.cc \ | 34 | xmltree.cc \ |
34 | tododb.cpp todoevent.cpp \ | 35 | tododb.cpp todoevent.cpp \ |
35 | todovcalresource.cpp colordialog.cpp \ | 36 | todovcalresource.cpp colordialog.cpp \ |
36 | colorpopupmenu.cpp oclickablelabel.cpp \ | 37 | colorpopupmenu.cpp oclickablelabel.cpp \ |
37 | oprocctrl.cpp oprocess.cpp \ | 38 | oprocctrl.cpp oprocess.cpp \ |
38 | odevice.cpp otimepicker.cpp \ | 39 | odevice.cpp otimepicker.cpp \ |
39 | otabwidget.cpp otabbar.cpp \ | 40 | otabwidget.cpp otabbar.cpp \ |
40 | ofileselector/ofiledialog.cpp \ | 41 | ofileselector/ofiledialog.cpp \ |
41 | ofileselector/ofilelistview.cpp \ | 42 | ofileselector/ofilelistview.cpp \ |
42 | ofileselector/ofileselector.cpp \ | 43 | ofileselector/ofileselector.cpp \ |
43 | ofileselector/ofileselectoritem.cpp \ | 44 | ofileselector/ofileselectoritem.cpp \ |
44 | ofileselector/ofileview.cpp \ | 45 | ofileselector/ofileview.cpp \ |
45 | ofileselector/olister.cpp \ | 46 | ofileselector/olister.cpp \ |
46 | ofileselector/olocallister.cpp \ | 47 | ofileselector/olocallister.cpp \ |
47 | ofileselector/ofileselectormain.cpp \ | 48 | ofileselector/ofileselectormain.cpp \ |
48 | pim/otodo.cpp \ | 49 | pim/otodo.cpp \ |
49 | pim/opimrecord.cpp \ | 50 | pim/opimrecord.cpp \ |
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 | ||
55 | TARGET = opie | 57 | TARGET = opie |
56 | INCLUDEPATH += $(OPIEDIR)/include | 58 | INCLUDEPATH += $(OPIEDIR)/include |
57 | DESTDIR = $(QTDIR)/lib$(PROJMAK) | 59 | DESTDIR = $(QTDIR)/lib$(PROJMAK) |
58 | #VERSION = 1.0.0 | 60 | #VERSION = 1.0.0 |
59 | 61 | ||
60 | INTERFACES = otimepickerbase.ui | 62 | INTERFACES = otimepickerbase.ui |
61 | 63 | ||
62 | TRANSLATIONS = ../i18n/de/libopie.ts \ | 64 | TRANSLATIONS = ../i18n/de/libopie.ts \ |
63 | ../i18n/en/libopie.ts \ | 65 | ../i18n/en/libopie.ts \ |
64 | ../i18n/es/libopie.ts \ | 66 | ../i18n/es/libopie.ts \ |
65 | ../i18n/fr/libopie.ts \ | 67 | ../i18n/fr/libopie.ts \ |
66 | ../i18n/hu/libopie.ts \ | 68 | ../i18n/hu/libopie.ts \ |
67 | ../i18n/ja/libopie.ts \ | 69 | ../i18n/ja/libopie.ts \ |
68 | ../i18n/ko/libopie.ts \ | 70 | ../i18n/ko/libopie.ts \ |
69 | ../i18n/no/libopie.ts \ | 71 | ../i18n/no/libopie.ts \ |
70 | ../i18n/pl/libopie.ts \ | 72 | ../i18n/pl/libopie.ts \ |
71 | ../i18n/pt/libopie.ts \ | 73 | ../i18n/pt/libopie.ts \ |
72 | ../i18n/pt_BR/libopie.ts \ | 74 | ../i18n/pt_BR/libopie.ts \ |
73 | ../i18n/sl/libopie.ts \ | 75 | ../i18n/sl/libopie.ts \ |
74 | ../i18n/zh_CN/libopie.ts \ | 76 | ../i18n/zh_CN/libopie.ts \ |
75 | ../i18n/zh_TW/libopie.ts | 77 | ../i18n/zh_TW/libopie.ts |
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 | |||
@@ -1,270 +1,272 @@ | |||
1 | 1 | ||
2 | #ifndef OPIE_RECORD_LIST_H | 2 | #ifndef OPIE_RECORD_LIST_H |
3 | #define OPIE_RECORD_LIST_H | 3 | #define OPIE_RECORD_LIST_H |
4 | 4 | ||
5 | #include <qarray.h> | 5 | #include <qarray.h> |
6 | 6 | ||
7 | #include "otemplatebase.h" | 7 | #include "otemplatebase.h" |
8 | #include "opimrecord.h" | 8 | #include "opimrecord.h" |
9 | 9 | ||
10 | /** | 10 | /** |
11 | * Our List Iterator | 11 | * Our List Iterator |
12 | * it behaves like STL or Qt | 12 | * it behaves like STL or Qt |
13 | * | 13 | * |
14 | * for(it = list.begin(); it != list.end(); ++it ) | 14 | * for(it = list.begin(); it != list.end(); ++it ) |
15 | * doSomeCoolStuff( (*it) ); | 15 | * doSomeCoolStuff( (*it) ); |
16 | */ | 16 | */ |
17 | template <class T> class ORecordList; | 17 | template <class T> class ORecordList; |
18 | template <class T = OPimRecord> | 18 | template <class T = OPimRecord> |
19 | class ORecordListIterator { | 19 | class ORecordListIterator { |
20 | friend class ORecordList<T>; | 20 | friend class ORecordList<T>; |
21 | public: | 21 | public: |
22 | typedef OTemplateBase<T> Base; | 22 | typedef OTemplateBase<T> Base; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * The c'tor used internally from | 25 | * The c'tor used internally from |
26 | * ORecordList | 26 | * ORecordList |
27 | */ | 27 | */ |
28 | ORecordListIterator( const QArray<int>, const Base* ); | 28 | ORecordListIterator( const QArray<int>, const Base* ); |
29 | 29 | ||
30 | /** | 30 | /** |
31 | * The standard c'tor | 31 | * The standard c'tor |
32 | */ | 32 | */ |
33 | ORecordListIterator(); | 33 | ORecordListIterator(); |
34 | ~ORecordListIterator(); | 34 | ~ORecordListIterator(); |
35 | 35 | ||
36 | ORecordListIterator( const ORecordListIterator& ); | 36 | ORecordListIterator( const ORecordListIterator& ); |
37 | ORecordListIterator &operator=(const ORecordListIterator& ); | 37 | ORecordListIterator &operator=(const ORecordListIterator& ); |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * a * operator ;) | 40 | * a * operator ;) |
41 | * use it like this T = (*it); | 41 | * use it like this T = (*it); |
42 | */ | 42 | */ |
43 | T operator*(); | 43 | T operator*(); |
44 | ORecordListIterator &operator++(); | 44 | ORecordListIterator &operator++(); |
45 | ORecordListIterator &operator--(); | 45 | ORecordListIterator &operator--(); |
46 | 46 | ||
47 | bool operator==( const ORecordListIterator& it ); | 47 | bool operator==( const ORecordListIterator& it ); |
48 | bool operator!=( const ORecordListIterator& it ); | 48 | bool operator!=( const ORecordListIterator& it ); |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * the current item | 51 | * the current item |
52 | */ | 52 | */ |
53 | uint current()const; | 53 | uint current()const; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * the number of items | 56 | * the number of items |
57 | */ | 57 | */ |
58 | uint count()const; | 58 | uint count()const; |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * sets the current item | 61 | * sets the current item |
62 | */ | 62 | */ |
63 | void setCurrent( uint cur ); | 63 | void setCurrent( uint cur ); |
64 | 64 | ||
65 | private: | 65 | private: |
66 | QArray<int> m_uids; | 66 | QArray<int> m_uids; |
67 | uint m_current; | 67 | uint m_current; |
68 | const Base* m_temp; | 68 | const Base* m_temp; |
69 | bool m_end : 1; | 69 | bool m_end : 1; |
70 | T m_record; | 70 | T m_record; |
71 | bool m_direction :1; | 71 | bool m_direction :1; |
72 | 72 | ||
73 | /* d pointer for future versions */ | 73 | /* d pointer for future versions */ |
74 | class IteratorPrivate; | 74 | class IteratorPrivate; |
75 | IteratorPrivate *d; | 75 | IteratorPrivate *d; |
76 | }; | 76 | }; |
77 | /** | 77 | /** |
78 | * The recordlist used as a return type | 78 | * The recordlist used as a return type |
79 | * from OPimAccessTemplate | 79 | * from OPimAccessTemplate |
80 | */ | 80 | */ |
81 | template <class T = OPimRecord > | 81 | template <class T = OPimRecord > |
82 | class ORecordList { | 82 | class ORecordList { |
83 | public: | 83 | public: |
84 | typedef OTemplateBase<T> Base; | 84 | typedef OTemplateBase<T> Base; |
85 | typedef ORecordListIterator<T> Iterator; | 85 | typedef ORecordListIterator<T> Iterator; |
86 | 86 | ||
87 | /** | 87 | /** |
88 | * c'tor | 88 | * c'tor |
89 | */ | 89 | */ |
90 | ORecordList () { | 90 | ORecordList () { |
91 | } | 91 | } |
92 | ORecordList( const QArray<int>& ids, | 92 | ORecordList( const QArray<int>& ids, |
93 | const Base* ); | 93 | const Base* ); |
94 | ~ORecordList(); | 94 | ~ORecordList(); |
95 | 95 | ||
96 | /** | 96 | /** |
97 | * the first iterator | 97 | * the first iterator |
98 | */ | 98 | */ |
99 | Iterator begin(); | 99 | Iterator begin(); |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * the end | 102 | * the end |
103 | */ | 103 | */ |
104 | Iterator end(); | 104 | Iterator end(); |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * the number of items in the list | 107 | * the number of items in the list |
108 | */ | 108 | */ |
109 | uint count()const; | 109 | uint count()const; |
110 | 110 | ||
111 | T operator[]( uint i ); | 111 | T operator[]( uint i ); |
112 | int uidAt(uint i ); | 112 | int uidAt(uint i ); |
113 | // FIXME implemenent remove | 113 | // FIXME implemenent remove |
114 | /* | 114 | /* |
115 | ConstIterator begin()const; | 115 | ConstIterator begin()const; |
116 | ConstIterator end()const; | 116 | ConstIterator end()const; |
117 | */ | 117 | */ |
118 | private: | 118 | private: |
119 | QArray<int> m_ids; | 119 | QArray<int> m_ids; |
120 | const Base* m_acc; | 120 | const Base* m_acc; |
121 | }; | 121 | }; |
122 | 122 | ||
123 | /* ok now implement it */ | 123 | /* ok now implement it */ |
124 | template <class T> | 124 | template <class T> |
125 | ORecordListIterator<T>::ORecordListIterator() { | 125 | ORecordListIterator<T>::ORecordListIterator() { |
126 | m_current = 0; | 126 | m_current = 0; |
127 | m_temp = 0l; | 127 | m_temp = 0l; |
128 | m_end = true; | 128 | m_end = true; |
129 | m_record = T(); | 129 | m_record = T(); |
130 | /* forward */ | 130 | /* forward */ |
131 | m_direction = TRUE; | 131 | m_direction = TRUE; |
132 | } | 132 | } |
133 | template <class T> | 133 | template <class T> |
134 | ORecordListIterator<T>::~ORecordListIterator() { | 134 | ORecordListIterator<T>::~ORecordListIterator() { |
135 | /* nothing to delete */ | 135 | /* nothing to delete */ |
136 | } | 136 | } |
137 | 137 | ||
138 | template <class T> | 138 | template <class T> |
139 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { | 139 | ORecordListIterator<T>::ORecordListIterator( const ORecordListIterator<T>& it) { |
140 | // qWarning("ORecordListIterator copy c'tor"); | 140 | // qWarning("ORecordListIterator copy c'tor"); |
141 | m_uids = it.m_uids; | 141 | m_uids = it.m_uids; |
142 | m_current = it.m_current; | 142 | m_current = it.m_current; |
143 | m_temp = it.m_temp; | 143 | m_temp = it.m_temp; |
144 | m_end = it.m_end; | 144 | m_end = it.m_end; |
145 | m_record = it.m_record; | 145 | m_record = it.m_record; |
146 | m_direction = it.m_direction; | 146 | m_direction = it.m_direction; |
147 | } | 147 | } |
148 | 148 | ||
149 | template <class T> | 149 | template <class T> |
150 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { | 150 | ORecordListIterator<T> &ORecordListIterator<T>::operator=( const ORecordListIterator<T>& it) { |
151 | m_uids = it.m_uids; | 151 | m_uids = it.m_uids; |
152 | m_current = it.m_current; | 152 | m_current = it.m_current; |
153 | m_temp = it.m_temp; | 153 | m_temp = it.m_temp; |
154 | m_end = it.m_end; | 154 | m_end = it.m_end; |
155 | m_record = it.m_record; | 155 | m_record = it.m_record; |
156 | 156 | ||
157 | return *this; | 157 | return *this; |
158 | } | 158 | } |
159 | 159 | ||
160 | template <class T> | 160 | template <class T> |
161 | T ORecordListIterator<T>::operator*() { | 161 | T ORecordListIterator<T>::operator*() { |
162 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 162 | qWarning("operator* %d %d", m_current, m_uids[m_current] ); |
163 | if (!m_end ) | 163 | if (!m_end ) |
164 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, | 164 | m_record = m_temp->find( m_uids[m_current], m_uids, m_current, |
165 | m_direction ? Base::Forward : | 165 | m_direction ? Base::Forward : |
166 | Base::Reverse ); | 166 | Base::Reverse ); |
167 | else | 167 | else |
168 | m_record = T(); | 168 | m_record = T(); |
169 | 169 | ||
170 | return m_record; | 170 | return m_record; |
171 | } | 171 | } |
172 | 172 | ||
173 | template <class T> | 173 | template <class T> |
174 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { | 174 | ORecordListIterator<T> &ORecordListIterator<T>::operator++() { |
175 | m_direction = true; | 175 | m_direction = true; |
176 | if (m_current < m_uids.count() ) { | 176 | if (m_current < m_uids.count() ) { |
177 | m_end = false; | 177 | m_end = false; |
178 | ++m_current; | 178 | ++m_current; |
179 | }else | 179 | }else |
180 | m_end = true; | 180 | m_end = true; |
181 | 181 | ||
182 | return *this; | 182 | return *this; |
183 | } | 183 | } |
184 | template <class T> | 184 | template <class T> |
185 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { | 185 | ORecordListIterator<T> &ORecordListIterator<T>::operator--() { |
186 | m_direction = false; | 186 | m_direction = false; |
187 | if ( m_current > 0 ) { | 187 | if ( m_current > 0 ) { |
188 | --m_current; | 188 | --m_current; |
189 | m_end = false; | 189 | m_end = false; |
190 | } else | 190 | } else |
191 | m_end = true; | 191 | m_end = true; |
192 | 192 | ||
193 | return *this; | 193 | return *this; |
194 | } | 194 | } |
195 | 195 | ||
196 | template <class T> | 196 | template <class T> |
197 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { | 197 | bool ORecordListIterator<T>::operator==( const ORecordListIterator<T>& it ) { |
198 | 198 | ||
199 | /* if both are at we're the same.... */ | 199 | /* if both are at we're the same.... */ |
200 | if ( m_end == it.m_end ) return true; | 200 | if ( m_end == it.m_end ) return true; |
201 | 201 | ||
202 | if ( m_uids != it.m_uids ) return false; | 202 | if ( m_uids != it.m_uids ) return false; |
203 | if ( m_current != it.m_current ) return false; | 203 | if ( m_current != it.m_current ) return false; |
204 | if ( m_temp != it.m_temp ) return false; | 204 | if ( m_temp != it.m_temp ) return false; |
205 | 205 | ||
206 | return true; | 206 | return true; |
207 | } | 207 | } |
208 | template <class T> | 208 | template <class T> |
209 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { | 209 | bool ORecordListIterator<T>::operator!=( const ORecordListIterator<T>& it ) { |
210 | return !(*this == it ); | 210 | return !(*this == it ); |
211 | } | 211 | } |
212 | template <class T> | 212 | template <class T> |
213 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, | 213 | ORecordListIterator<T>::ORecordListIterator( const QArray<int> uids, |
214 | const Base* t ) | 214 | const Base* t ) |
215 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), | 215 | : m_uids( uids ), m_current( 0 ), m_temp( t ), m_end( false ), |
216 | m_direction( false ) | 216 | m_direction( false ) |
217 | { | 217 | { |
218 | } | 218 | } |
219 | template <class T> | 219 | template <class T> |
220 | uint ORecordListIterator<T>::current()const { | 220 | uint ORecordListIterator<T>::current()const { |
221 | return m_current; | 221 | return m_current; |
222 | } | 222 | } |
223 | template <class T> | 223 | template <class T> |
224 | void ORecordListIterator<T>::setCurrent( uint cur ) { | 224 | void ORecordListIterator<T>::setCurrent( uint cur ) { |
225 | if( cur < m_uids.count() ) { | 225 | if( cur < m_uids.count() ) { |
226 | m_end = false; | 226 | m_end = false; |
227 | m_current= cur; | 227 | m_current= cur; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | template <class T> | 230 | template <class T> |
231 | uint ORecordListIterator<T>::count()const { | 231 | uint ORecordListIterator<T>::count()const { |
232 | return m_uids.count(); | 232 | return m_uids.count(); |
233 | } | 233 | } |
234 | template <class T> | 234 | template <class T> |
235 | ORecordList<T>::ORecordList( const QArray<int>& ids, | 235 | ORecordList<T>::ORecordList( const QArray<int>& ids, |
236 | const Base* acc ) | 236 | const Base* acc ) |
237 | : m_ids( ids ), m_acc( acc ) | 237 | : m_ids( ids ), m_acc( acc ) |
238 | { | 238 | { |
239 | } | 239 | } |
240 | template <class T> | 240 | template <class T> |
241 | ORecordList<T>::~ORecordList() { | 241 | ORecordList<T>::~ORecordList() { |
242 | /* nothing to do here */ | 242 | /* nothing to do here */ |
243 | } | 243 | } |
244 | template <class T> | 244 | template <class T> |
245 | ORecordList<T>::Iterator ORecordList<T>::begin() { | 245 | ORecordList<T>::Iterator ORecordList<T>::begin() { |
246 | Iterator it( m_ids, m_acc ); | 246 | Iterator it( m_ids, m_acc ); |
247 | return it; | 247 | return it; |
248 | } | 248 | } |
249 | template <class T> | 249 | template <class T> |
250 | ORecordList<T>::Iterator ORecordList<T>::end() { | 250 | ORecordList<T>::Iterator ORecordList<T>::end() { |
251 | Iterator it( m_ids, m_acc ); | 251 | Iterator it( m_ids, m_acc ); |
252 | it.m_end = true; | 252 | it.m_end = true; |
253 | it.m_current = m_ids.count(); | 253 | it.m_current = m_ids.count(); |
254 | 254 | ||
255 | return it; | 255 | return it; |
256 | } | 256 | } |
257 | template <class T> | 257 | template <class T> |
258 | uint ORecordList<T>::count()const { | 258 | uint ORecordList<T>::count()const { |
259 | return m_ids.count(); | 259 | return m_ids.count(); |
260 | } | 260 | } |
261 | template <class T> | 261 | template <class T> |
262 | T ORecordList<T>::operator[]( uint i ) { | 262 | T 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 | } |
266 | template <class T> | 268 | template <class T> |
267 | int ORecordList<T>::uidAt( uint i ) { | 269 | int ORecordList<T>::uidAt( uint i ) { |
268 | return m_ids[i]; | 270 | return m_ids[i]; |
269 | } | 271 | } |
270 | #endif | 272 | #endif |
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 | |||
7 | struct 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 | |||
27 | ORecur::ORecur() { | ||
28 | data = new Data; | ||
29 | } | ||
30 | ORecur::ORecur( const ORecur& rec) | ||
31 | : data( rec.data ) | ||
32 | { | ||
33 | data->ref(); | ||
34 | } | ||
35 | ORecur::~ORecur() { | ||
36 | if ( data->deref() ) { | ||
37 | delete data; | ||
38 | data = 0l; | ||
39 | } | ||
40 | } | ||
41 | void ORecur::deref() { | ||
42 | if ( data->deref() ) { | ||
43 | delete data; | ||
44 | data = 0l; | ||
45 | } | ||
46 | } | ||
47 | bool ORecur::operator==( const ORecur& )const { | ||
48 | return false; | ||
49 | } | ||
50 | ORecur &ORecur::operator=( const ORecur& re) { | ||
51 | re.data->ref(); | ||
52 | deref(); | ||
53 | data = re.data; | ||
54 | |||
55 | return *this; | ||
56 | } | ||
57 | ORecur::RepeatType ORecur::type()const{ | ||
58 | return data->type; | ||
59 | } | ||
60 | int ORecur::frequency()const { | ||
61 | return data->freq; | ||
62 | } | ||
63 | int ORecur::position()const { | ||
64 | return data->pos; | ||
65 | } | ||
66 | char ORecur::days() const{ | ||
67 | return data->days; | ||
68 | } | ||
69 | bool ORecur::hasEndDate()const { | ||
70 | return data->hasEnd; | ||
71 | } | ||
72 | QDate ORecur::endDate()const { | ||
73 | return TimeConversion::fromUTC( data->end ).date(); | ||
74 | } | ||
75 | time_t ORecur::endDateUTC()const { | ||
76 | return data->end; | ||
77 | } | ||
78 | time_t ORecur::createTime()const { | ||
79 | return data->create; | ||
80 | } | ||
81 | void ORecur::setType( const RepeatType& z) { | ||
82 | checkOrModify(); | ||
83 | data->type = z; | ||
84 | } | ||
85 | void ORecur::setFrequency( int freq ) { | ||
86 | checkOrModify(); | ||
87 | data->freq = freq; | ||
88 | } | ||
89 | void ORecur::setPosition( int pos ) { | ||
90 | checkOrModify(); | ||
91 | data->pos = pos; | ||
92 | } | ||
93 | void ORecur::setDays( char c ) { | ||
94 | checkOrModify(); | ||
95 | data->days = c; | ||
96 | } | ||
97 | void ORecur::setEndDate( const QDate& dt) { | ||
98 | checkOrModify(); | ||
99 | data->end = TimeConversion::toUTC( dt ); | ||
100 | } | ||
101 | void ORecur::setEndDateUTC( time_t t) { | ||
102 | checkOrModify(); | ||
103 | data->end = t; | ||
104 | } | ||
105 | void ORecur::setCreateTime( time_t t) { | ||
106 | checkOrModify(); | ||
107 | data->create = t; | ||
108 | } | ||
109 | void ORecur::setHasEndDate( bool b) { | ||
110 | checkOrModify(); | ||
111 | data->hasEnd = b; | ||
112 | } | ||
113 | void 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 | |||
14 | class ORecur { | ||
15 | public: | ||
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 ); | ||
43 | private: | ||
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 | |||
@@ -40,501 +40,501 @@ namespace { | |||
40 | QString query()const; | 40 | QString query()const; |
41 | }; | 41 | }; |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * inserts/adds a OTodo to the table | 44 | * inserts/adds a OTodo to the table |
45 | */ | 45 | */ |
46 | class InsertQuery : public OSQLQuery { | 46 | class InsertQuery : public OSQLQuery { |
47 | public: | 47 | public: |
48 | InsertQuery(const OTodo& ); | 48 | InsertQuery(const OTodo& ); |
49 | ~InsertQuery(); | 49 | ~InsertQuery(); |
50 | QString query()const; | 50 | QString query()const; |
51 | private: | 51 | private: |
52 | OTodo m_todo; | 52 | OTodo m_todo; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * removes one from the table | 56 | * removes one from the table |
57 | */ | 57 | */ |
58 | class RemoveQuery : public OSQLQuery { | 58 | class RemoveQuery : public OSQLQuery { |
59 | public: | 59 | public: |
60 | RemoveQuery(int uid ); | 60 | RemoveQuery(int uid ); |
61 | ~RemoveQuery(); | 61 | ~RemoveQuery(); |
62 | QString query()const; | 62 | QString query()const; |
63 | private: | 63 | private: |
64 | int m_uid; | 64 | int m_uid; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | /** | 67 | /** |
68 | * Clears (delete) a Table | 68 | * Clears (delete) a Table |
69 | */ | 69 | */ |
70 | class ClearQuery : public OSQLQuery { | 70 | class ClearQuery : public OSQLQuery { |
71 | public: | 71 | public: |
72 | ClearQuery(); | 72 | ClearQuery(); |
73 | ~ClearQuery(); | 73 | ~ClearQuery(); |
74 | QString query()const; | 74 | QString query()const; |
75 | 75 | ||
76 | }; | 76 | }; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * a find query | 79 | * a find query |
80 | */ | 80 | */ |
81 | class FindQuery : public OSQLQuery { | 81 | class FindQuery : public OSQLQuery { |
82 | public: | 82 | public: |
83 | FindQuery(int uid); | 83 | FindQuery(int uid); |
84 | FindQuery(const QArray<int>& ); | 84 | FindQuery(const QArray<int>& ); |
85 | ~FindQuery(); | 85 | ~FindQuery(); |
86 | QString query()const; | 86 | QString query()const; |
87 | private: | 87 | private: |
88 | QString single()const; | 88 | QString single()const; |
89 | QString multi()const; | 89 | QString multi()const; |
90 | QArray<int> m_uids; | 90 | QArray<int> m_uids; |
91 | int m_uid; | 91 | int m_uid; |
92 | }; | 92 | }; |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * overdue query | 95 | * overdue query |
96 | */ | 96 | */ |
97 | class OverDueQuery : public OSQLQuery { | 97 | class OverDueQuery : public OSQLQuery { |
98 | public: | 98 | public: |
99 | OverDueQuery(); | 99 | OverDueQuery(); |
100 | ~OverDueQuery(); | 100 | ~OverDueQuery(); |
101 | QString query()const; | 101 | QString query()const; |
102 | }; | 102 | }; |
103 | class EffQuery : public OSQLQuery { | 103 | class EffQuery : public OSQLQuery { |
104 | public: | 104 | public: |
105 | EffQuery( const QDate&, const QDate&, bool inc ); | 105 | EffQuery( const QDate&, const QDate&, bool inc ); |
106 | ~EffQuery(); | 106 | ~EffQuery(); |
107 | QString query()const; | 107 | QString query()const; |
108 | private: | 108 | private: |
109 | QString with()const; | 109 | QString with()const; |
110 | QString out()const; | 110 | QString out()const; |
111 | QDate m_start; | 111 | QDate m_start; |
112 | QDate m_end; | 112 | QDate m_end; |
113 | bool m_inc :1; | 113 | bool m_inc :1; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | 116 | ||
117 | CreateQuery::CreateQuery() : OSQLQuery() {} | 117 | CreateQuery::CreateQuery() : OSQLQuery() {} |
118 | CreateQuery::~CreateQuery() {} | 118 | CreateQuery::~CreateQuery() {} |
119 | QString CreateQuery::query()const { | 119 | QString CreateQuery::query()const { |
120 | QString qu; | 120 | QString qu; |
121 | qu += "create table todolist( uid, categories, completed, progress, "; | 121 | qu += "create table todolist( uid, categories, completed, progress, "; |
122 | qu += "summary, DueDate, priority, description )"; | 122 | qu += "summary, DueDate, priority, description )"; |
123 | return qu; | 123 | return qu; |
124 | } | 124 | } |
125 | 125 | ||
126 | LoadQuery::LoadQuery() : OSQLQuery() {} | 126 | LoadQuery::LoadQuery() : OSQLQuery() {} |
127 | LoadQuery::~LoadQuery() {} | 127 | LoadQuery::~LoadQuery() {} |
128 | QString LoadQuery::query()const { | 128 | QString LoadQuery::query()const { |
129 | QString qu; | 129 | QString qu; |
130 | qu += "select distinct uid from todolist"; | 130 | qu += "select distinct uid from todolist"; |
131 | 131 | ||
132 | return qu; | 132 | return qu; |
133 | } | 133 | } |
134 | 134 | ||
135 | InsertQuery::InsertQuery( const OTodo& todo ) | 135 | InsertQuery::InsertQuery( const OTodo& todo ) |
136 | : OSQLQuery(), m_todo( todo ) { | 136 | : OSQLQuery(), m_todo( todo ) { |
137 | } | 137 | } |
138 | InsertQuery::~InsertQuery() { | 138 | InsertQuery::~InsertQuery() { |
139 | } | 139 | } |
140 | /* | 140 | /* |
141 | * converts from a OTodo to a query | 141 | * converts from a OTodo to a query |
142 | * we leave out X-Ref + Alarms | 142 | * we leave out X-Ref + Alarms |
143 | */ | 143 | */ |
144 | QString InsertQuery::query()const{ | 144 | QString InsertQuery::query()const{ |
145 | 145 | ||
146 | int year, month, day; | 146 | int year, month, day; |
147 | year = month = day = 0; | 147 | year = month = day = 0; |
148 | if (m_todo.hasDueDate() ) { | 148 | if (m_todo.hasDueDate() ) { |
149 | QDate date = m_todo.dueDate(); | 149 | QDate date = m_todo.dueDate(); |
150 | year = date.year(); | 150 | year = date.year(); |
151 | month = date.month(); | 151 | month = date.month(); |
152 | day = date.day(); | 152 | day = date.day(); |
153 | } | 153 | } |
154 | QString qu; | 154 | QString qu; |
155 | qu = "insert into todolist VALUES(" + QString::number( m_todo.uid() ) + ",'" + m_todo.idsToString( m_todo.categories() ) + "',"; | 155 | qu = "insert into todolist VALUES(" + QString::number( m_todo.uid() ) + ",'" + m_todo.idsToString( m_todo.categories() ) + "',"; |
156 | qu += QString::number( m_todo.isCompleted() ) + "," + QString::number( m_todo.progress() ) + ","; | 156 | qu += QString::number( m_todo.isCompleted() ) + "," + QString::number( m_todo.progress() ) + ","; |
157 | qu += "'"+m_todo.summary()+"','"+QString::number(year)+"-"+QString::number(month)+"-"+QString::number(day)+"',"; | 157 | qu += "'"+m_todo.summary()+"','"+QString::number(year)+"-"+QString::number(month)+"-"+QString::number(day)+"',"; |
158 | qu += QString::number(m_todo.priority() ) +",'" + m_todo.description() + "')"; | 158 | qu += QString::number(m_todo.priority() ) +",'" + m_todo.description() + "')"; |
159 | 159 | ||
160 | qWarning("add %s", qu.latin1() ); | 160 | qWarning("add %s", qu.latin1() ); |
161 | return qu; | 161 | return qu; |
162 | } | 162 | } |
163 | 163 | ||
164 | RemoveQuery::RemoveQuery(int uid ) | 164 | RemoveQuery::RemoveQuery(int uid ) |
165 | : OSQLQuery(), m_uid( uid ) {} | 165 | : OSQLQuery(), m_uid( uid ) {} |
166 | RemoveQuery::~RemoveQuery() {} | 166 | RemoveQuery::~RemoveQuery() {} |
167 | QString RemoveQuery::query()const { | 167 | QString RemoveQuery::query()const { |
168 | QString qu = "DELETE from todolist where uid = " + QString::number(m_uid); | 168 | QString qu = "DELETE from todolist where uid = " + QString::number(m_uid); |
169 | return qu; | 169 | return qu; |
170 | } | 170 | } |
171 | 171 | ||
172 | 172 | ||
173 | ClearQuery::ClearQuery() | 173 | ClearQuery::ClearQuery() |
174 | : OSQLQuery() {} | 174 | : OSQLQuery() {} |
175 | ClearQuery::~ClearQuery() {} | 175 | ClearQuery::~ClearQuery() {} |
176 | QString ClearQuery::query()const { | 176 | QString ClearQuery::query()const { |
177 | QString qu = "drop table todolist"; | 177 | QString qu = "drop table todolist"; |
178 | return qu; | 178 | return qu; |
179 | } | 179 | } |
180 | FindQuery::FindQuery(int uid) | 180 | FindQuery::FindQuery(int uid) |
181 | : OSQLQuery(), m_uid(uid ) { | 181 | : OSQLQuery(), m_uid(uid ) { |
182 | } | 182 | } |
183 | FindQuery::FindQuery(const QArray<int>& ints) | 183 | FindQuery::FindQuery(const QArray<int>& ints) |
184 | : OSQLQuery(), m_uids(ints){ | 184 | : OSQLQuery(), m_uids(ints){ |
185 | } | 185 | } |
186 | FindQuery::~FindQuery() { | 186 | FindQuery::~FindQuery() { |
187 | } | 187 | } |
188 | QString FindQuery::query()const{ | 188 | QString FindQuery::query()const{ |
189 | if (m_uids.count() == 0 ) | 189 | if (m_uids.count() == 0 ) |
190 | return single(); | 190 | return single(); |
191 | else | 191 | else |
192 | return multi(); | 192 | return multi(); |
193 | } | 193 | } |
194 | QString FindQuery::single()const{ | 194 | QString FindQuery::single()const{ |
195 | QString qu = "select uid, categories, completed, progress, summary, "; | 195 | QString qu = "select uid, categories, completed, progress, summary, "; |
196 | qu += "DueDate, priority, description from todolist where uid = " + QString::number(m_uid); | 196 | qu += "DueDate, priority, description from todolist where uid = " + QString::number(m_uid); |
197 | return qu; | 197 | return qu; |
198 | } | 198 | } |
199 | QString FindQuery::multi()const { | 199 | QString FindQuery::multi()const { |
200 | QString qu = "select uid, categories, completed, progress, summary, "; | 200 | QString qu = "select uid, categories, completed, progress, summary, "; |
201 | qu += "DueDate, priority, description from todolist where "; | 201 | qu += "DueDate, priority, description from todolist where "; |
202 | for (uint i = 0; i < m_uids.count(); i++ ) { | 202 | for (uint i = 0; i < m_uids.count(); i++ ) { |
203 | qu += " UID = " + QString::number( m_uids[i] ) + " OR"; | 203 | qu += " UID = " + QString::number( m_uids[i] ) + " OR"; |
204 | } | 204 | } |
205 | qu.remove( qu.length()-2, 2 ); | 205 | qu.remove( qu.length()-2, 2 ); |
206 | return qu; | 206 | return qu; |
207 | } | 207 | } |
208 | 208 | ||
209 | OverDueQuery::OverDueQuery(): OSQLQuery() {} | 209 | OverDueQuery::OverDueQuery(): OSQLQuery() {} |
210 | OverDueQuery::~OverDueQuery() {} | 210 | OverDueQuery::~OverDueQuery() {} |
211 | QString OverDueQuery::query()const { | 211 | QString OverDueQuery::query()const { |
212 | QDate date = QDate::currentDate(); | 212 | QDate date = QDate::currentDate(); |
213 | QString str; | 213 | QString str; |
214 | str = QString("select uid from todolist where DueDate ='%1-%2-%3'").arg(date.year() ).arg(date.month() ).arg(date.day() ); | 214 | str = QString("select uid from todolist where DueDate ='%1-%2-%3'").arg(date.year() ).arg(date.month() ).arg(date.day() ); |
215 | 215 | ||
216 | return str; | 216 | return str; |
217 | } | 217 | } |
218 | 218 | ||
219 | 219 | ||
220 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) | 220 | EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc ) |
221 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} | 221 | : OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {} |
222 | EffQuery::~EffQuery() {} | 222 | EffQuery::~EffQuery() {} |
223 | QString EffQuery::query()const { | 223 | QString EffQuery::query()const { |
224 | return m_inc ? with() : out(); | 224 | return m_inc ? with() : out(); |
225 | } | 225 | } |
226 | QString EffQuery::with()const { | 226 | QString EffQuery::with()const { |
227 | QString str; | 227 | QString str; |
228 | str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") | 228 | str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ") |
229 | .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) | 229 | .arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() ) |
230 | .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); | 230 | .arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() ); |
231 | return str; | 231 | return str; |
232 | } | 232 | } |
233 | QString EffQuery::out()const { | 233 | QString EffQuery::out()const { |
234 | QString str; | 234 | QString str; |
235 | str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") | 235 | str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'") |
236 | .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) | 236 | .arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() ) |
237 | .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); | 237 | .arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() ); |
238 | 238 | ||
239 | return str; | 239 | return str; |
240 | } | 240 | } |
241 | }; | 241 | }; |
242 | 242 | ||
243 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) | 243 | OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file ) |
244 | : OTodoAccessBackend(), m_dict(15), m_dirty(true) | 244 | : OTodoAccessBackend(), m_dict(15), m_dirty(true) |
245 | { | 245 | { |
246 | QString fi = file; | 246 | QString fi = file; |
247 | if ( fi.isEmpty() ) | 247 | if ( fi.isEmpty() ) |
248 | fi = Global::applicationFileName( "todolist", "todolist.db" ); | 248 | fi = Global::applicationFileName( "todolist", "todolist.db" ); |
249 | OSQLManager man; | 249 | OSQLManager man; |
250 | m_driver = man.standard(); | 250 | m_driver = man.standard(); |
251 | m_driver->setUrl(fi); | 251 | m_driver->setUrl(fi); |
252 | fillDict(); | 252 | fillDict(); |
253 | } | 253 | } |
254 | 254 | ||
255 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ | 255 | OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){ |
256 | } | 256 | } |
257 | bool OTodoAccessBackendSQL::load(){ | 257 | bool OTodoAccessBackendSQL::load(){ |
258 | if (!m_driver->open() ) | 258 | if (!m_driver->open() ) |
259 | return false; | 259 | return false; |
260 | 260 | ||
261 | CreateQuery creat; | 261 | CreateQuery creat; |
262 | OSQLResult res = m_driver->query(&creat ); | 262 | OSQLResult res = m_driver->query(&creat ); |
263 | 263 | ||
264 | m_dirty = true; | 264 | m_dirty = true; |
265 | return true; | 265 | return true; |
266 | } | 266 | } |
267 | bool OTodoAccessBackendSQL::reload(){ | 267 | bool OTodoAccessBackendSQL::reload(){ |
268 | return load(); | 268 | return load(); |
269 | } | 269 | } |
270 | 270 | ||
271 | bool OTodoAccessBackendSQL::save(){ | 271 | bool OTodoAccessBackendSQL::save(){ |
272 | return m_driver->close(); | 272 | return m_driver->close(); |
273 | } | 273 | } |
274 | QArray<int> OTodoAccessBackendSQL::allRecords()const { | 274 | QArray<int> OTodoAccessBackendSQL::allRecords()const { |
275 | if (m_dirty ) | 275 | if (m_dirty ) |
276 | update(); | 276 | update(); |
277 | 277 | ||
278 | return m_uids; | 278 | return m_uids; |
279 | } | 279 | } |
280 | QArray<int> OTodoAccessBackendSQL::queryByExample( const OTodo& , int ){ | 280 | QArray<int> OTodoAccessBackendSQL::queryByExample( const OTodo& , int ){ |
281 | QArray<int> ints(0); | 281 | QArray<int> ints(0); |
282 | return ints; | 282 | return ints; |
283 | } | 283 | } |
284 | OTodo OTodoAccessBackendSQL::find(int uid ) const{ | 284 | OTodo OTodoAccessBackendSQL::find(int uid ) const{ |
285 | FindQuery query( uid ); | 285 | FindQuery query( uid ); |
286 | return todo( m_driver->query(&query) ); | 286 | return todo( m_driver->query(&query) ); |
287 | 287 | ||
288 | } | 288 | } |
289 | OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, | 289 | OTodo OTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, |
290 | uint cur, Frontend::CacheDirection dir ) const{ | 290 | uint cur, Frontend::CacheDirection dir ) const{ |
291 | int CACHE = readAhead(); | 291 | int CACHE = readAhead(); |
292 | qWarning("searching for %d", uid ); | 292 | qWarning("searching for %d", uid ); |
293 | QArray<int> search( CACHE ); | 293 | QArray<int> search( CACHE ); |
294 | uint size =0; | 294 | uint size =0; |
295 | OTodo to; | 295 | OTodo to; |
296 | 296 | ||
297 | // we try to cache CACHE items | 297 | // we try to cache CACHE items |
298 | switch( dir ) { | 298 | switch( dir ) { |
299 | /* forward */ | 299 | /* forward */ |
300 | case 0: | 300 | case 0: |
301 | for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { | 301 | for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { |
302 | qWarning("size %d %d", size, ints[i] ); | 302 | qWarning("size %d %d", size, ints[i] ); |
303 | search[size] = ints[i]; | 303 | search[size] = ints[i]; |
304 | size++; | 304 | size++; |
305 | } | 305 | } |
306 | break; | 306 | break; |
307 | /* reverse */ | 307 | /* reverse */ |
308 | case 1: | 308 | case 1: |
309 | for (uint i = cur; i != 0 && size < CACHE; i-- ) { | 309 | for (uint i = cur; i != 0 && size < CACHE; i-- ) { |
310 | search[size] = ints[i]; | 310 | search[size] = ints[i]; |
311 | size++; | 311 | size++; |
312 | } | 312 | } |
313 | break; | 313 | break; |
314 | } | 314 | } |
315 | search.resize( size ); | 315 | search.resize( size ); |
316 | FindQuery query( search ); | 316 | FindQuery query( search ); |
317 | OSQLResult res = m_driver->query( &query ); | 317 | OSQLResult res = m_driver->query( &query ); |
318 | if ( res.state() != OSQLResult::Success ) | 318 | if ( res.state() != OSQLResult::Success ) |
319 | return to; | 319 | return to; |
320 | 320 | ||
321 | return todo( res ); | 321 | return todo( res ); |
322 | } | 322 | } |
323 | void OTodoAccessBackendSQL::clear() { | 323 | void OTodoAccessBackendSQL::clear() { |
324 | ClearQuery cle; | 324 | ClearQuery cle; |
325 | OSQLResult res = m_driver->query( &cle ); | 325 | OSQLResult res = m_driver->query( &cle ); |
326 | CreateQuery qu; | 326 | CreateQuery qu; |
327 | res = m_driver->query(&qu); | 327 | res = m_driver->query(&qu); |
328 | } | 328 | } |
329 | bool OTodoAccessBackendSQL::add( const OTodo& t) { | 329 | bool OTodoAccessBackendSQL::add( const OTodo& t) { |
330 | InsertQuery ins( t ); | 330 | InsertQuery ins( t ); |
331 | OSQLResult res = m_driver->query( &ins ); | 331 | OSQLResult res = m_driver->query( &ins ); |
332 | 332 | ||
333 | if ( res.state() == OSQLResult::Failure ) | 333 | if ( res.state() == OSQLResult::Failure ) |
334 | return false; | 334 | return false; |
335 | int c = m_uids.count(); | 335 | int c = m_uids.count(); |
336 | m_uids.resize( c+1 ); | 336 | m_uids.resize( c+1 ); |
337 | m_uids[c] = t.uid(); | 337 | m_uids[c] = t.uid(); |
338 | 338 | ||
339 | return true; | 339 | return true; |
340 | } | 340 | } |
341 | bool OTodoAccessBackendSQL::remove( int uid ) { | 341 | bool OTodoAccessBackendSQL::remove( int uid ) { |
342 | RemoveQuery rem( uid ); | 342 | RemoveQuery rem( uid ); |
343 | OSQLResult res = m_driver->query(&rem ); | 343 | OSQLResult res = m_driver->query(&rem ); |
344 | 344 | ||
345 | if ( res.state() == OSQLResult::Failure ) | 345 | if ( res.state() == OSQLResult::Failure ) |
346 | return false; | 346 | return false; |
347 | 347 | ||
348 | m_dirty = true; | 348 | m_dirty = true; |
349 | return true; | 349 | return true; |
350 | } | 350 | } |
351 | /* | 351 | /* |
352 | * FIXME better set query | 352 | * FIXME better set query |
353 | * but we need the cache for that | 353 | * but we need the cache for that |
354 | * now we remove | 354 | * now we remove |
355 | */ | 355 | */ |
356 | bool OTodoAccessBackendSQL::replace( const OTodo& t) { | 356 | bool OTodoAccessBackendSQL::replace( const OTodo& t) { |
357 | remove( t.uid() ); | 357 | remove( t.uid() ); |
358 | bool b= add(t); | 358 | bool b= add(t); |
359 | m_dirty = false; // we changed some stuff but the UID stayed the same | 359 | m_dirty = false; // we changed some stuff but the UID stayed the same |
360 | return b; | 360 | return b; |
361 | } | 361 | } |
362 | QArray<int> OTodoAccessBackendSQL::overDue() { | 362 | QArray<int> OTodoAccessBackendSQL::overDue() { |
363 | OverDueQuery qu; | 363 | OverDueQuery qu; |
364 | return uids( m_driver->query(&qu ) ); | 364 | return uids( m_driver->query(&qu ) ); |
365 | } | 365 | } |
366 | QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s, | 366 | QArray<int> OTodoAccessBackendSQL::effectiveToDos( const QDate& s, |
367 | const QDate& t, | 367 | const QDate& t, |
368 | bool u) { | 368 | bool u) { |
369 | EffQuery ef(s, t, u ); | 369 | EffQuery ef(s, t, u ); |
370 | return uids (m_driver->query(&ef) ); | 370 | return uids (m_driver->query(&ef) ); |
371 | } | 371 | } |
372 | /* | 372 | /* |
373 | * | 373 | * |
374 | */ | 374 | */ |
375 | QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder, | 375 | QArray<int> OTodoAccessBackendSQL::sorted( bool asc, int sortOrder, |
376 | int sortFilter, int cat ) { | 376 | int sortFilter, int cat ) { |
377 | qWarning("sorted %d, %d", asc, sortOrder ); | 377 | qWarning("sorted %d, %d", asc, sortOrder ); |
378 | QString query; | 378 | QString query; |
379 | query = "select uid from todolist WHERE "; | 379 | query = "select uid from todolist WHERE "; |
380 | 380 | ||
381 | /* | 381 | /* |
382 | * Sort Filter stuff | 382 | * Sort Filter stuff |
383 | * not that straight forward | 383 | * not that straight forward |
384 | * | 384 | * |
385 | */ | 385 | */ |
386 | /* Category */ | 386 | /* Category */ |
387 | if ( sortFilter & 1 ) { | 387 | if ( sortFilter & 1 ) { |
388 | QString str; | 388 | QString str; |
389 | if (cat != 0 ) str = QString::number( cat ); | 389 | if (cat != 0 ) str = QString::number( cat ); |
390 | query += " categories like '%" +str+"%' AND"; | 390 | query += " categories like '%" +str+"%' AND"; |
391 | } | 391 | } |
392 | /* Show only overdue */ | 392 | /* Show only overdue */ |
393 | if ( sortFilter & 2 ) { | 393 | if ( sortFilter & 2 ) { |
394 | QDate date = QDate::currentDate(); | 394 | QDate date = QDate::currentDate(); |
395 | QString due; | 395 | QString due; |
396 | QString base; | 396 | QString base; |
397 | base = QString("DueDate <= '%1-%2-%3' AND completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() ); | 397 | base = QString("DueDate <= '%1-%2-%3' AND completed = 0").arg( date.year() ).arg( date.month() ).arg( date.day() ); |
398 | query += " " + base + " AND"; | 398 | query += " " + base + " AND"; |
399 | } | 399 | } |
400 | /* not show completed */ | 400 | /* not show completed */ |
401 | if ( sortFilter & 4 ) { | 401 | if ( sortFilter & 4 ) { |
402 | query += " completed = 0 AND"; | 402 | query += " completed = 0 AND"; |
403 | }else{ | 403 | }else{ |
404 | query += " ( completed = 1 OR completed = 0) AND"; | 404 | query += " ( completed = 1 OR completed = 0) AND"; |
405 | } | 405 | } |
406 | /* srtip the end */ | 406 | /* srtip the end */ |
407 | query = query.remove( query.length()-3, 3 ); | 407 | query = query.remove( query.length()-3, 3 ); |
408 | 408 | ||
409 | 409 | ||
410 | /* | 410 | /* |
411 | * sort order stuff | 411 | * sort order stuff |
412 | * quite straight forward | 412 | * quite straight forward |
413 | */ | 413 | */ |
414 | query += "ORDER BY "; | 414 | query += "ORDER BY "; |
415 | switch( sortOrder ) { | 415 | switch( sortOrder ) { |
416 | /* completed */ | 416 | /* completed */ |
417 | case 0: | 417 | case 0: |
418 | query += "completed"; | 418 | query += "completed"; |
419 | break; | 419 | break; |
420 | case 1: | 420 | case 1: |
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"; |
428 | break; | 428 | break; |
429 | } | 429 | } |
430 | 430 | ||
431 | if ( !asc ) { | 431 | if ( !asc ) { |
432 | qWarning("not ascending!"); | 432 | qWarning("not ascending!"); |
433 | query += " DESC"; | 433 | query += " DESC"; |
434 | } | 434 | } |
435 | 435 | ||
436 | qWarning( query ); | 436 | qWarning( query ); |
437 | OSQLRawQuery raw(query ); | 437 | OSQLRawQuery raw(query ); |
438 | return uids( m_driver->query(&raw) ); | 438 | return uids( m_driver->query(&raw) ); |
439 | } | 439 | } |
440 | bool OTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ | 440 | bool OTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ |
441 | if ( str == "0-0-0" ) | 441 | if ( str == "0-0-0" ) |
442 | return false; | 442 | return false; |
443 | else{ | 443 | else{ |
444 | int day, year, month; | 444 | int day, year, month; |
445 | QStringList list = QStringList::split("-", str ); | 445 | QStringList list = QStringList::split("-", str ); |
446 | year = list[0].toInt(); | 446 | year = list[0].toInt(); |
447 | month = list[1].toInt(); | 447 | month = list[1].toInt(); |
448 | day = list[2].toInt(); | 448 | day = list[2].toInt(); |
449 | da.setYMD( year, month, day ); | 449 | da.setYMD( year, month, day ); |
450 | return true; | 450 | return true; |
451 | } | 451 | } |
452 | } | 452 | } |
453 | OTodo OTodoAccessBackendSQL::todo( const OSQLResult& res) const{ | 453 | OTodo OTodoAccessBackendSQL::todo( const OSQLResult& res) const{ |
454 | if ( res.state() == OSQLResult::Failure ) { | 454 | if ( res.state() == OSQLResult::Failure ) { |
455 | OTodo to; | 455 | OTodo to; |
456 | return to; | 456 | return to; |
457 | } | 457 | } |
458 | 458 | ||
459 | OSQLResultItem::ValueList list = res.results(); | 459 | OSQLResultItem::ValueList list = res.results(); |
460 | OSQLResultItem::ValueList::Iterator it = list.begin(); | 460 | OSQLResultItem::ValueList::Iterator it = list.begin(); |
461 | qWarning("todo1"); | 461 | qWarning("todo1"); |
462 | OTodo to = todo( (*it) ); | 462 | OTodo to = todo( (*it) ); |
463 | cache( to ); | 463 | cache( to ); |
464 | ++it; | 464 | ++it; |
465 | 465 | ||
466 | for ( ; it != list.end(); ++it ) { | 466 | for ( ; it != list.end(); ++it ) { |
467 | qWarning("caching"); | 467 | qWarning("caching"); |
468 | cache( todo( (*it) ) ); | 468 | cache( todo( (*it) ) ); |
469 | } | 469 | } |
470 | return to; | 470 | return to; |
471 | } | 471 | } |
472 | OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { | 472 | OTodo OTodoAccessBackendSQL::todo( OSQLResultItem& item )const { |
473 | qWarning("todo"); | 473 | qWarning("todo"); |
474 | bool has = false; QDate da = QDate::currentDate(); | 474 | bool has = false; QDate da = QDate::currentDate(); |
475 | has = date( da, item.data("DueDate") ); | 475 | has = date( da, item.data("DueDate") ); |
476 | QStringList cats = QStringList::split(";", item.data("categories") ); | 476 | QStringList cats = QStringList::split(";", item.data("categories") ); |
477 | 477 | ||
478 | OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), | 478 | OTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), |
479 | cats, item.data("summary"), item.data("description"), | 479 | cats, item.data("summary"), item.data("description"), |
480 | item.data("progress").toUShort(), has, da, | 480 | item.data("progress").toUShort(), has, da, |
481 | item.data("uid").toInt() ); | 481 | item.data("uid").toInt() ); |
482 | return to; | 482 | return to; |
483 | } | 483 | } |
484 | OTodo OTodoAccessBackendSQL::todo( int uid )const { | 484 | OTodo OTodoAccessBackendSQL::todo( int uid )const { |
485 | FindQuery find( uid ); | 485 | FindQuery find( uid ); |
486 | return todo( m_driver->query(&find) ); | 486 | return todo( m_driver->query(&find) ); |
487 | } | 487 | } |
488 | /* | 488 | /* |
489 | * update the dict | 489 | * update the dict |
490 | */ | 490 | */ |
491 | void OTodoAccessBackendSQL::fillDict() { | 491 | void OTodoAccessBackendSQL::fillDict() { |
492 | /* initialize dict */ | 492 | /* initialize dict */ |
493 | /* | 493 | /* |
494 | * UPDATE dict if you change anything!!! | 494 | * UPDATE dict if you change anything!!! |
495 | */ | 495 | */ |
496 | m_dict.setAutoDelete( TRUE ); | 496 | m_dict.setAutoDelete( TRUE ); |
497 | m_dict.insert("Categories" , new int(OTodo::Category) ); | 497 | m_dict.insert("Categories" , new int(OTodo::Category) ); |
498 | m_dict.insert("Uid" , new int(OTodo::Uid) ); | 498 | m_dict.insert("Uid" , new int(OTodo::Uid) ); |
499 | m_dict.insert("HasDate" , new int(OTodo::HasDate) ); | 499 | m_dict.insert("HasDate" , new int(OTodo::HasDate) ); |
500 | m_dict.insert("Completed" , new int(OTodo::Completed) ); | 500 | m_dict.insert("Completed" , new int(OTodo::Completed) ); |
501 | m_dict.insert("Description" , new int(OTodo::Description) ); | 501 | m_dict.insert("Description" , new int(OTodo::Description) ); |
502 | m_dict.insert("Summary" , new int(OTodo::Summary) ); | 502 | m_dict.insert("Summary" , new int(OTodo::Summary) ); |
503 | m_dict.insert("Priority" , new int(OTodo::Priority) ); | 503 | m_dict.insert("Priority" , new int(OTodo::Priority) ); |
504 | m_dict.insert("DateDay" , new int(OTodo::DateDay) ); | 504 | m_dict.insert("DateDay" , new int(OTodo::DateDay) ); |
505 | m_dict.insert("DateMonth" , new int(OTodo::DateMonth) ); | 505 | m_dict.insert("DateMonth" , new int(OTodo::DateMonth) ); |
506 | m_dict.insert("DateYear" , new int(OTodo::DateYear) ); | 506 | m_dict.insert("DateYear" , new int(OTodo::DateYear) ); |
507 | m_dict.insert("Progress" , new int(OTodo::Progress) ); | 507 | m_dict.insert("Progress" , new int(OTodo::Progress) ); |
508 | m_dict.insert("Completed", new int(OTodo::Completed) ); | 508 | m_dict.insert("Completed", new int(OTodo::Completed) ); |
509 | m_dict.insert("CrossReference", new int(OTodo::CrossReference) ); | 509 | m_dict.insert("CrossReference", new int(OTodo::CrossReference) ); |
510 | m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); | 510 | m_dict.insert("HasAlarmDateTime",new int(OTodo::HasAlarmDateTime) ); |
511 | m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); | 511 | m_dict.insert("AlarmDateTime", new int(OTodo::AlarmDateTime) ); |
512 | } | 512 | } |
513 | /* | 513 | /* |
514 | * need to be const so let's fool the | 514 | * need to be const so let's fool the |
515 | * compiler :( | 515 | * compiler :( |
516 | */ | 516 | */ |
517 | void OTodoAccessBackendSQL::update()const { | 517 | void OTodoAccessBackendSQL::update()const { |
518 | ((OTodoAccessBackendSQL*)this)->m_dirty = false; | 518 | ((OTodoAccessBackendSQL*)this)->m_dirty = false; |
519 | LoadQuery lo; | 519 | LoadQuery lo; |
520 | OSQLResult res = m_driver->query(&lo); | 520 | OSQLResult res = m_driver->query(&lo); |
521 | if ( res.state() != OSQLResult::Success ) | 521 | if ( res.state() != OSQLResult::Success ) |
522 | return; | 522 | return; |
523 | 523 | ||
524 | ((OTodoAccessBackendSQL*)this)->m_uids = uids( res ); | 524 | ((OTodoAccessBackendSQL*)this)->m_uids = uids( res ); |
525 | } | 525 | } |
526 | QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{ | 526 | QArray<int> OTodoAccessBackendSQL::uids( const OSQLResult& res) const{ |
527 | 527 | ||
528 | OSQLResultItem::ValueList list = res.results(); | 528 | OSQLResultItem::ValueList list = res.results(); |
529 | OSQLResultItem::ValueList::Iterator it; | 529 | OSQLResultItem::ValueList::Iterator it; |
530 | QArray<int> ints(list.count() ); | 530 | QArray<int> ints(list.count() ); |
531 | qWarning(" count = %d", list.count() ); | 531 | qWarning(" count = %d", list.count() ); |
532 | 532 | ||
533 | int i = 0; | 533 | int i = 0; |
534 | for (it = list.begin(); it != list.end(); ++it ) { | 534 | for (it = list.begin(); it != list.end(); ++it ) { |
535 | ints[i] = (*it).data("uid").toInt(); | 535 | ints[i] = (*it).data("uid").toInt(); |
536 | i++; | 536 | i++; |
537 | } | 537 | } |
538 | return ints; | 538 | return ints; |
539 | } | 539 | } |
540 | 540 | ||