author | mickeyl <mickeyl> | 2004-02-21 12:25:50 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-21 12:25:50 (UTC) |
commit | 6155f1be5c19fc51a4929c9e173f9e5a24d193e6 (patch) (unidiff) | |
tree | c18ca863f82a559c60728f922519ac696387ec53 /libopie2/opiepim/core/orecur.cpp | |
parent | a570c2824fcecaf1c278e1b5a592fa14cc0647f8 (diff) | |
download | opie-6155f1be5c19fc51a4929c9e173f9e5a24d193e6.zip opie-6155f1be5c19fc51a4929c9e173f9e5a24d193e6.tar.gz opie-6155f1be5c19fc51a4929c9e173f9e5a24d193e6.tar.bz2 |
the usual cosmetics
Diffstat (limited to 'libopie2/opiepim/core/orecur.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/orecur.cpp | 76 |
1 files changed, 71 insertions, 5 deletions
diff --git a/libopie2/opiepim/core/orecur.cpp b/libopie2/opiepim/core/orecur.cpp index 033f264..5e2da25 100644 --- a/libopie2/opiepim/core/orecur.cpp +++ b/libopie2/opiepim/core/orecur.cpp | |||
@@ -1,179 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <time.h> | 30 | #include "orecur.h" |
31 | 31 | ||
32 | #include <qshared.h> | 32 | /* OPIE */ |
33 | #include <opie2/otimezone.h> | ||
34 | #include <qpe/timeconversion.h> | ||
33 | 35 | ||
34 | #include <qtopia/timeconversion.h> | 36 | /* QT */ |
37 | #include <qshared.h> | ||
35 | 38 | ||
36 | #include <opie2/otimezone.h> | 39 | /* STD */ |
37 | #include <opie2/orecur.h> | 40 | #include <time.h> |
38 | 41 | ||
39 | namespace Opie { | 42 | namespace Opie { |
43 | |||
40 | struct ORecur::Data : public QShared { | 44 | struct ORecur::Data : public QShared { |
41 | Data() : QShared() { | 45 | Data() : QShared() { |
42 | type = ORecur::NoRepeat; | 46 | type = ORecur::NoRepeat; |
43 | freq = -1; | 47 | freq = -1; |
44 | days = 0; | 48 | days = 0; |
45 | pos = 0; | 49 | pos = 0; |
46 | create = QDateTime::currentDateTime(); | 50 | create = QDateTime::currentDateTime(); |
47 | hasEnd = FALSE; | 51 | hasEnd = FALSE; |
48 | end = QDate::currentDate(); | 52 | end = QDate::currentDate(); |
49 | } | 53 | } |
50 | char days; // Q_UINT8 for 8 seven days;) | 54 | char days; // Q_UINT8 for 8 seven days;) |
51 | ORecur::RepeatType type; | 55 | ORecur::RepeatType type; |
52 | int freq; | 56 | int freq; |
53 | int pos; | 57 | int pos; |
54 | bool hasEnd : 1; | 58 | bool hasEnd : 1; |
55 | QDate end; | 59 | QDate end; |
56 | QDateTime create; | 60 | QDateTime create; |
57 | int rep; | 61 | int rep; |
58 | QString app; | 62 | QString app; |
59 | ExceptionList list; | 63 | ExceptionList list; |
60 | QDate start; | 64 | QDate start; |
61 | }; | 65 | }; |
62 | 66 | ||
63 | 67 | ||
64 | ORecur::ORecur() { | 68 | ORecur::ORecur() { |
65 | data = new Data; | 69 | data = new Data; |
66 | } | 70 | } |
67 | 71 | ||
68 | ORecur::ORecur( const QMap<int, QString>& map ) | 72 | ORecur::ORecur( const QMap<int, QString>& map ) |
69 | { | 73 | { |
70 | ORecur(); | 74 | ORecur(); |
71 | fromMap( map ); | 75 | fromMap( map ); |
72 | } | 76 | } |
73 | 77 | ||
74 | 78 | ||
75 | ORecur::ORecur( const ORecur& rec) | 79 | ORecur::ORecur( const ORecur& rec) |
76 | : data( rec.data ) | 80 | : data( rec.data ) |
77 | { | 81 | { |
78 | data->ref(); | 82 | data->ref(); |
79 | } | 83 | } |
84 | |||
85 | |||
80 | ORecur::~ORecur() { | 86 | ORecur::~ORecur() { |
81 | if ( data->deref() ) { | 87 | if ( data->deref() ) { |
82 | delete data; | 88 | delete data; |
83 | data = 0l; | 89 | data = 0l; |
84 | } | 90 | } |
85 | } | 91 | } |
92 | |||
93 | |||
86 | void ORecur::deref() { | 94 | void ORecur::deref() { |
87 | if ( data->deref() ) { | 95 | if ( data->deref() ) { |
88 | delete data; | 96 | delete data; |
89 | data = 0l; | 97 | data = 0l; |
90 | } | 98 | } |
91 | } | 99 | } |
100 | |||
101 | |||
92 | bool ORecur::operator==( const ORecur& )const { | 102 | bool ORecur::operator==( const ORecur& )const { |
93 | return false; | 103 | return false; |
94 | } | 104 | } |
105 | |||
106 | |||
95 | ORecur &ORecur::operator=( const ORecur& re) { | 107 | ORecur &ORecur::operator=( const ORecur& re) { |
96 | if ( *this == re ) return *this; | 108 | if ( *this == re ) return *this; |
97 | 109 | ||
98 | re.data->ref(); | 110 | re.data->ref(); |
99 | deref(); | 111 | deref(); |
100 | data = re.data; | 112 | data = re.data; |
101 | 113 | ||
102 | return *this; | 114 | return *this; |
103 | } | 115 | } |
116 | |||
117 | |||
104 | bool ORecur::doesRecur()const { | 118 | bool ORecur::doesRecur()const { |
105 | return !( type() == NoRepeat ); | 119 | return !( type() == NoRepeat ); |
106 | } | 120 | } |
121 | |||
122 | |||
107 | /* | 123 | /* |
108 | * we try to be smart here | 124 | * we try to be smart here |
109 | * | 125 | * |
110 | */ | 126 | */ |
111 | bool ORecur::doesRecur( const QDate& date ) { | 127 | bool ORecur::doesRecur( const QDate& date ) { |
112 | /* the day before the recurrance */ | 128 | /* the day before the recurrance */ |
113 | QDate da = date.addDays(-1); | 129 | QDate da = date.addDays(-1); |
114 | 130 | ||
115 | QDate recur; | 131 | QDate recur; |
116 | if (!nextOcurrence( da, recur ) ) | 132 | if (!nextOcurrence( da, recur ) ) |
117 | return false; | 133 | return false; |
118 | 134 | ||
119 | return (recur == date); | 135 | return (recur == date); |
120 | } | 136 | } |
137 | |||
138 | |||
121 | // FIXME unuglify! | 139 | // FIXME unuglify! |
122 | // GPL from Datebookdb.cpp | 140 | // GPL from Datebookdb.cpp |
123 | // FIXME exception list! | 141 | // FIXME exception list! |
124 | bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { | 142 | bool ORecur::nextOcurrence( const QDate& from, QDate& next ) { |
125 | bool stillLooking; | 143 | bool stillLooking; |
126 | stillLooking = p_nextOccurrence( from, next ); | 144 | stillLooking = p_nextOccurrence( from, next ); |
127 | while ( stillLooking && data->list.contains(next) ) | 145 | while ( stillLooking && data->list.contains(next) ) |
128 | stillLooking = p_nextOccurrence( next.addDays(1), next ); | 146 | stillLooking = p_nextOccurrence( next.addDays(1), next ); |
129 | 147 | ||
130 | return stillLooking; | 148 | return stillLooking; |
131 | } | 149 | } |
150 | |||
151 | |||
132 | bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { | 152 | bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { |
133 | 153 | ||
134 | // easy checks, first are we too far in the future or too far in the past? | 154 | // easy checks, first are we too far in the future or too far in the past? |
135 | QDate tmpDate; | 155 | QDate tmpDate; |
136 | int freq = frequency(); | 156 | int freq = frequency(); |
137 | int diff, diff2, a; | 157 | int diff, diff2, a; |
138 | int iday, imonth, iyear; | 158 | int iday, imonth, iyear; |
139 | int dayOfWeek = 0; | 159 | int dayOfWeek = 0; |
140 | int firstOfWeek = 0; | 160 | int firstOfWeek = 0; |
141 | int weekOfMonth; | 161 | int weekOfMonth; |
142 | 162 | ||
143 | 163 | ||
144 | if (hasEndDate() && endDate() < from) | 164 | if (hasEndDate() && endDate() < from) |
145 | return FALSE; | 165 | return FALSE; |
146 | 166 | ||
147 | if (start() >= from ) { | 167 | if (start() >= from ) { |
148 | next = start(); | 168 | next = start(); |
149 | return TRUE; | 169 | return TRUE; |
150 | } | 170 | } |
151 | 171 | ||
152 | switch ( type() ) { | 172 | switch ( type() ) { |
153 | case Weekly: | 173 | case Weekly: |
154 | /* weekly is just daily by 7 */ | 174 | /* weekly is just daily by 7 */ |
155 | /* first convert the repeatPattern.Days() mask to the next | 175 | /* first convert the repeatPattern.Days() mask to the next |
156 | day of week valid after from */ | 176 | day of week valid after from */ |
157 | dayOfWeek = from.dayOfWeek(); | 177 | dayOfWeek = from.dayOfWeek(); |
158 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ | 178 | dayOfWeek--; /* we want 0-6, doco for above specs 1-7 */ |
159 | 179 | ||
160 | /* this is done in case freq > 1 and from in week not | 180 | /* this is done in case freq > 1 and from in week not |
161 | for this round */ | 181 | for this round */ |
162 | // firstOfWeek = 0; this is already done at decl. | 182 | // firstOfWeek = 0; this is already done at decl. |
163 | while(!((1 << firstOfWeek) & days() )) | 183 | while(!((1 << firstOfWeek) & days() )) |
164 | firstOfWeek++; | 184 | firstOfWeek++; |
165 | 185 | ||
166 | /* there is at least one 'day', or there would be no event */ | 186 | /* there is at least one 'day', or there would be no event */ |
167 | while(!((1 << (dayOfWeek % 7)) & days() )) | 187 | while(!((1 << (dayOfWeek % 7)) & days() )) |
168 | dayOfWeek++; | 188 | dayOfWeek++; |
169 | 189 | ||
170 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ | 190 | dayOfWeek = dayOfWeek % 7; /* the actual day of week */ |
171 | dayOfWeek -= start().dayOfWeek() -1; | 191 | dayOfWeek -= start().dayOfWeek() -1; |
172 | 192 | ||
173 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ | 193 | firstOfWeek = firstOfWeek % 7; /* the actual first of week */ |
174 | firstOfWeek -= start().dayOfWeek() -1; | 194 | firstOfWeek -= start().dayOfWeek() -1; |
175 | 195 | ||
176 | // dayOfWeek may be negitive now | 196 | // dayOfWeek may be negitive now |
177 | // day of week is number of days to add to start day | 197 | // day of week is number of days to add to start day |
178 | 198 | ||
179 | freq *= 7; | 199 | freq *= 7; |
@@ -356,187 +376,233 @@ bool ORecur::p_nextOccurrence( const QDate& from, QDate& next ) { | |||
356 | 376 | ||
357 | diff = 1; | 377 | diff = 1; |
358 | if(imonth == 2 && iday > 28) { | 378 | if(imonth == 2 && iday > 28) { |
359 | /* leap year, and it counts, calculate actual frequency */ | 379 | /* leap year, and it counts, calculate actual frequency */ |
360 | if(freq % 4) | 380 | if(freq % 4) |
361 | if (freq % 2) | 381 | if (freq % 2) |
362 | freq = freq * 4; | 382 | freq = freq * 4; |
363 | else | 383 | else |
364 | freq = freq * 2; | 384 | freq = freq * 2; |
365 | /* else divides by 4 already, leave freq alone */ | 385 | /* else divides by 4 already, leave freq alone */ |
366 | diff = 4; | 386 | diff = 4; |
367 | } | 387 | } |
368 | 388 | ||
369 | a = from.year() - start().year(); | 389 | a = from.year() - start().year(); |
370 | if(a % freq) { | 390 | if(a % freq) { |
371 | a = freq - (a % freq); | 391 | a = freq - (a % freq); |
372 | iyear = iyear + a; | 392 | iyear = iyear + a; |
373 | } | 393 | } |
374 | 394 | ||
375 | /* under the assumption we won't hit one of the special not-leap years twice */ | 395 | /* under the assumption we won't hit one of the special not-leap years twice */ |
376 | if(!QDate::isValid(iyear, imonth, iday)) { | 396 | if(!QDate::isValid(iyear, imonth, iday)) { |
377 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ | 397 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ |
378 | iyear += freq; | 398 | iyear += freq; |
379 | } | 399 | } |
380 | 400 | ||
381 | if(QDate(iyear, imonth, iday) >= from) { | 401 | if(QDate(iyear, imonth, iday) >= from) { |
382 | next = QDate(iyear, imonth, iday); | 402 | next = QDate(iyear, imonth, iday); |
383 | 403 | ||
384 | if ((next > endDate()) && hasEndDate() ) | 404 | if ((next > endDate()) && hasEndDate() ) |
385 | return FALSE; | 405 | return FALSE; |
386 | return TRUE; | 406 | return TRUE; |
387 | } | 407 | } |
388 | /* iyear == from.year(), need to advance again */ | 408 | /* iyear == from.year(), need to advance again */ |
389 | iyear += freq; | 409 | iyear += freq; |
390 | /* under the assumption we won't hit one of the special not-leap years twice */ | 410 | /* under the assumption we won't hit one of the special not-leap years twice */ |
391 | if(!QDate::isValid(iyear, imonth, iday)) { | 411 | if(!QDate::isValid(iyear, imonth, iday)) { |
392 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ | 412 | /* must have been skipping by leap years and hit one that wasn't, (e.g. 2100) */ |
393 | iyear += freq; | 413 | iyear += freq; |
394 | } | 414 | } |
395 | 415 | ||
396 | next = QDate(iyear, imonth, iday); | 416 | next = QDate(iyear, imonth, iday); |
397 | if ((next > endDate()) && hasEndDate() ) | 417 | if ((next > endDate()) && hasEndDate() ) |
398 | return FALSE; | 418 | return FALSE; |
399 | return TRUE; | 419 | return TRUE; |
400 | default: | 420 | default: |
401 | return FALSE; | 421 | return FALSE; |
402 | } | 422 | } |
403 | } | 423 | } |
424 | |||
425 | |||
404 | ORecur::RepeatType ORecur::type()const{ | 426 | ORecur::RepeatType ORecur::type()const{ |
405 | return data->type; | 427 | return data->type; |
406 | } | 428 | } |
429 | |||
430 | |||
407 | int ORecur::frequency()const { | 431 | int ORecur::frequency()const { |
408 | return data->freq; | 432 | return data->freq; |
409 | } | 433 | } |
434 | |||
435 | |||
410 | int ORecur::position()const { | 436 | int ORecur::position()const { |
411 | return data->pos; | 437 | return data->pos; |
412 | } | 438 | } |
439 | |||
440 | |||
413 | char ORecur::days() const{ | 441 | char ORecur::days() const{ |
414 | return data->days; | 442 | return data->days; |
415 | } | 443 | } |
444 | |||
445 | |||
416 | bool ORecur::hasEndDate()const { | 446 | bool ORecur::hasEndDate()const { |
417 | return data->hasEnd; | 447 | return data->hasEnd; |
418 | } | 448 | } |
449 | |||
450 | |||
419 | QDate ORecur::endDate()const { | 451 | QDate ORecur::endDate()const { |
420 | return data->end; | 452 | return data->end; |
421 | } | 453 | } |
454 | |||
455 | |||
422 | QDate ORecur::start()const{ | 456 | QDate ORecur::start()const{ |
423 | return data->start; | 457 | return data->start; |
424 | } | 458 | } |
459 | |||
460 | |||
425 | QDateTime ORecur::createdDateTime()const { | 461 | QDateTime ORecur::createdDateTime()const { |
426 | return data->create; | 462 | return data->create; |
427 | } | 463 | } |
464 | |||
465 | |||
428 | int ORecur::repetition()const { | 466 | int ORecur::repetition()const { |
429 | return data->rep; | 467 | return data->rep; |
430 | } | 468 | } |
469 | |||
470 | |||
431 | QString ORecur::service()const { | 471 | QString ORecur::service()const { |
432 | return data->app; | 472 | return data->app; |
433 | } | 473 | } |
474 | |||
475 | |||
434 | ORecur::ExceptionList& ORecur::exceptions() { | 476 | ORecur::ExceptionList& ORecur::exceptions() { |
435 | return data->list; | 477 | return data->list; |
436 | } | 478 | } |
479 | |||
480 | |||
437 | void ORecur::setType( const RepeatType& z) { | 481 | void ORecur::setType( const RepeatType& z) { |
438 | checkOrModify(); | 482 | checkOrModify(); |
439 | data->type = z; | 483 | data->type = z; |
440 | } | 484 | } |
485 | |||
486 | |||
441 | void ORecur::setFrequency( int freq ) { | 487 | void ORecur::setFrequency( int freq ) { |
442 | checkOrModify(); | 488 | checkOrModify(); |
443 | data->freq = freq; | 489 | data->freq = freq; |
444 | } | 490 | } |
491 | |||
492 | |||
445 | void ORecur::setPosition( int pos ) { | 493 | void ORecur::setPosition( int pos ) { |
446 | checkOrModify(); | 494 | checkOrModify(); |
447 | data->pos = pos; | 495 | data->pos = pos; |
448 | } | 496 | } |
497 | |||
498 | |||
449 | void ORecur::setDays( char c ) { | 499 | void ORecur::setDays( char c ) { |
450 | checkOrModify(); | 500 | checkOrModify(); |
451 | data->days = c; | 501 | data->days = c; |
452 | } | 502 | } |
503 | |||
504 | |||
453 | void ORecur::setEndDate( const QDate& dt) { | 505 | void ORecur::setEndDate( const QDate& dt) { |
454 | checkOrModify(); | 506 | checkOrModify(); |
455 | data->end = dt; | 507 | data->end = dt; |
456 | } | 508 | } |
509 | |||
510 | |||
457 | void ORecur::setCreatedDateTime( const QDateTime& t) { | 511 | void ORecur::setCreatedDateTime( const QDateTime& t) { |
458 | checkOrModify(); | 512 | checkOrModify(); |
459 | data->create = t; | 513 | data->create = t; |
460 | } | 514 | } |
515 | |||
516 | |||
461 | void ORecur::setHasEndDate( bool b) { | 517 | void ORecur::setHasEndDate( bool b) { |
462 | checkOrModify(); | 518 | checkOrModify(); |
463 | data->hasEnd = b; | 519 | data->hasEnd = b; |
464 | } | 520 | } |
521 | |||
522 | |||
465 | void ORecur::setRepitition( int rep ) { | 523 | void ORecur::setRepitition( int rep ) { |
466 | checkOrModify(); | 524 | checkOrModify(); |
467 | data->rep = rep; | 525 | data->rep = rep; |
468 | } | 526 | } |
527 | |||
528 | |||
469 | void ORecur::setService( const QString& app ) { | 529 | void ORecur::setService( const QString& app ) { |
470 | checkOrModify(); | 530 | checkOrModify(); |
471 | data->app = app; | 531 | data->app = app; |
472 | } | 532 | } |
533 | |||
534 | |||
473 | void ORecur::setStart( const QDate& dt ) { | 535 | void ORecur::setStart( const QDate& dt ) { |
474 | checkOrModify(); | 536 | checkOrModify(); |
475 | data->start = dt; | 537 | data->start = dt; |
476 | } | 538 | } |
539 | |||
540 | |||
477 | void ORecur::checkOrModify() { | 541 | void ORecur::checkOrModify() { |
478 | if ( data->count != 1 ) { | 542 | if ( data->count != 1 ) { |
479 | data->deref(); | 543 | data->deref(); |
480 | Data* d2 = new Data; | 544 | Data* d2 = new Data; |
481 | d2->days = data->days; | 545 | d2->days = data->days; |
482 | d2->type = data->type; | 546 | d2->type = data->type; |
483 | d2->freq = data->freq; | 547 | d2->freq = data->freq; |
484 | d2->pos = data->pos; | 548 | d2->pos = data->pos; |
485 | d2->hasEnd = data->hasEnd; | 549 | d2->hasEnd = data->hasEnd; |
486 | d2->end = data->end; | 550 | d2->end = data->end; |
487 | d2->create = data->create; | 551 | d2->create = data->create; |
488 | d2->rep = data->rep; | 552 | d2->rep = data->rep; |
489 | d2->app = data->app; | 553 | d2->app = data->app; |
490 | d2->list = data->list; | 554 | d2->list = data->list; |
491 | d2->start = data->start; | 555 | d2->start = data->start; |
492 | data = d2; | 556 | data = d2; |
493 | } | 557 | } |
494 | } | 558 | } |
559 | |||
560 | |||
495 | QString ORecur::toString()const { | 561 | QString ORecur::toString()const { |
496 | QString buf; | 562 | QString buf; |
497 | QMap<int, QString> recMap = toMap(); | 563 | QMap<int, QString> recMap = toMap(); |
498 | 564 | ||
499 | buf += " rtype=\""; | 565 | buf += " rtype=\""; |
500 | buf += recMap[ORecur::RType]; | 566 | buf += recMap[ORecur::RType]; |
501 | buf += "\""; | 567 | buf += "\""; |
502 | if (data->days > 0 ) | 568 | if (data->days > 0 ) |
503 | buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; | 569 | buf += " rweekdays=\"" + recMap[ORecur::RWeekdays] + "\""; |
504 | if ( data->pos != 0 ) | 570 | if ( data->pos != 0 ) |
505 | buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; | 571 | buf += " rposition=\"" + recMap[ORecur::RPosition] + "\""; |
506 | 572 | ||
507 | buf += " rfreq=\"" + recMap[ORecur::RFreq] + "\""; | 573 | buf += " rfreq=\"" + recMap[ORecur::RFreq] + "\""; |
508 | buf += " rhasenddate=\"" + recMap[ORecur::RHasEndDate]+ "\""; | 574 | buf += " rhasenddate=\"" + recMap[ORecur::RHasEndDate]+ "\""; |
509 | if ( data->hasEnd ) | 575 | if ( data->hasEnd ) |
510 | buf += " enddt=\"" | 576 | buf += " enddt=\"" |
511 | + recMap[ORecur::EndDate] | 577 | + recMap[ORecur::EndDate] |
512 | + "\""; | 578 | + "\""; |
513 | buf += " created=\"" + recMap[ORecur::Created] + "\""; | 579 | buf += " created=\"" + recMap[ORecur::Created] + "\""; |
514 | 580 | ||
515 | if ( data->list.isEmpty() ) return buf; | 581 | if ( data->list.isEmpty() ) return buf; |
516 | buf += " exceptions=\""; | 582 | buf += " exceptions=\""; |
517 | buf += recMap[ORecur::Exceptions]; | 583 | buf += recMap[ORecur::Exceptions]; |
518 | buf += "\" "; | 584 | buf += "\" "; |
519 | 585 | ||
520 | return buf; | 586 | return buf; |
521 | } | 587 | } |
522 | 588 | ||
523 | QString ORecur::rTypeString() const | 589 | QString ORecur::rTypeString() const |
524 | { | 590 | { |
525 | QString retString; | 591 | QString retString; |
526 | switch ( data->type ) { | 592 | switch ( data->type ) { |
527 | case ORecur::Daily: | 593 | case ORecur::Daily: |
528 | retString = "Daily"; | 594 | retString = "Daily"; |
529 | break; | 595 | break; |
530 | case ORecur::Weekly: | 596 | case ORecur::Weekly: |
531 | retString = "Weekly"; | 597 | retString = "Weekly"; |
532 | break; | 598 | break; |
533 | case ORecur::MonthlyDay: | 599 | case ORecur::MonthlyDay: |
534 | retString = "MonthlyDay"; | 600 | retString = "MonthlyDay"; |
535 | break; | 601 | break; |
536 | case ORecur::MonthlyDate: | 602 | case ORecur::MonthlyDate: |
537 | retString = "MonthlyDate"; | 603 | retString = "MonthlyDate"; |
538 | break; | 604 | break; |
539 | case ORecur::Yearly: | 605 | case ORecur::Yearly: |
540 | retString = "Yearly"; | 606 | retString = "Yearly"; |
541 | break; | 607 | break; |
542 | default: | 608 | default: |