author | mickeyl <mickeyl> | 2004-02-24 12:46:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-24 12:46:23 (UTC) |
commit | 911473db35a9fce5f3589f03c27210456faaba86 (patch) (unidiff) | |
tree | 7d55b6117b24de6ab18747b00a4641d38001c0ed /libopie2/opiepim/core/opimtodo.cpp | |
parent | a2ead23c3614fe581261455cb4c3f31cee2098f3 (diff) | |
download | opie-911473db35a9fce5f3589f03c27210456faaba86.zip opie-911473db35a9fce5f3589f03c27210456faaba86.tar.gz opie-911473db35a9fce5f3589f03c27210456faaba86.tar.bz2 |
*phew* here is the class and file rename patch. not converted yet: backend,
but that will be not visible to application classes so we can change it later.
Diffstat (limited to 'libopie2/opiepim/core/opimtodo.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimtodo.cpp | 712 |
1 files changed, 712 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp new file mode 100644 index 0000000..34df807 --- a/dev/null +++ b/libopie2/opiepim/core/opimtodo.cpp | |||
@@ -0,0 +1,712 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
29 | |||
30 | #include "opimtodo.h" | ||
31 | |||
32 | /* OPIE */ | ||
33 | #include <opie2/opimstate.h> | ||
34 | #include <opie2/opimrecurrence.h> | ||
35 | #include <opie2/opimmaintainer.h> | ||
36 | #include <opie2/opimnotifymanager.h> | ||
37 | #include <opie2/opimresolver.h> | ||
38 | #include <qpe/palmtopuidgen.h> | ||
39 | #include <qpe/stringutil.h> | ||
40 | #include <qpe/palmtoprecord.h> | ||
41 | #include <qpe/stringutil.h> | ||
42 | #include <qpe/categories.h> | ||
43 | #include <qpe/categoryselect.h> | ||
44 | |||
45 | /* QT */ | ||
46 | #include <qobject.h> | ||
47 | #include <qshared.h> | ||
48 | |||
49 | namespace Opie | ||
50 | { | ||
51 | |||
52 | struct OPimTodo::OPimTodoData : public QShared | ||
53 | { | ||
54 | OPimTodoData() : QShared() | ||
55 | { | ||
56 | recur = 0; | ||
57 | state = 0; | ||
58 | maintainer = 0; | ||
59 | notifiers = 0; | ||
60 | }; | ||
61 | ~OPimTodoData() | ||
62 | { | ||
63 | delete recur; | ||
64 | delete maintainer; | ||
65 | delete notifiers; | ||
66 | } | ||
67 | |||
68 | QDate date; | ||
69 | bool isCompleted: 1; | ||
70 | bool hasDate: 1; | ||
71 | int priority; | ||
72 | QString desc; | ||
73 | QString sum; | ||
74 | QMap<QString, QString> extra; | ||
75 | ushort prog; | ||
76 | OPimState *state; | ||
77 | OPimRecurrence *recur; | ||
78 | OPimMaintainer *maintainer; | ||
79 | QDate start; | ||
80 | QDate completed; | ||
81 | OPimNotifyManager *notifiers; | ||
82 | }; | ||
83 | |||
84 | |||
85 | OPimTodo::OPimTodo( const OPimTodo &event ) | ||
86 | : OPimRecord( event ), data( event.data ) | ||
87 | { | ||
88 | data->ref(); | ||
89 | // qWarning("ref up"); | ||
90 | } | ||
91 | |||
92 | |||
93 | OPimTodo::~OPimTodo() | ||
94 | { | ||
95 | |||
96 | // qWarning("~OPimTodo " ); | ||
97 | if ( data->deref() ) | ||
98 | { | ||
99 | // qWarning("OPimTodo::dereffing"); | ||
100 | delete data; | ||
101 | data = 0l; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | |||
106 | OPimTodo::OPimTodo( bool completed, int priority, | ||
107 | const QArray<int> &category, | ||
108 | const QString& summary, | ||
109 | const QString &description, | ||
110 | ushort progress, | ||
111 | bool hasDate, QDate date, int uid ) | ||
112 | : OPimRecord( uid ) | ||
113 | { | ||
114 | // qWarning("OPimTodoData " + summary); | ||
115 | setCategories( category ); | ||
116 | |||
117 | data = new OPimTodoData; | ||
118 | |||
119 | data->date = date; | ||
120 | data->isCompleted = completed; | ||
121 | data->hasDate = hasDate; | ||
122 | data->priority = priority; | ||
123 | data->sum = summary; | ||
124 | data->prog = progress; | ||
125 | data->desc = Qtopia::simplifyMultiLineSpace( description ); | ||
126 | } | ||
127 | |||
128 | |||
129 | OPimTodo::OPimTodo( bool completed, int priority, | ||
130 | const QStringList &category, | ||
131 | const QString& summary, | ||
132 | const QString &description, | ||
133 | ushort progress, | ||
134 | bool hasDate, QDate date, int uid ) | ||
135 | : OPimRecord( uid ) | ||
136 | { | ||
137 | // qWarning("OPimTodoData" + summary); | ||
138 | setCategories( idsFromString( category.join( ";" ) ) ); | ||
139 | |||
140 | data = new OPimTodoData; | ||
141 | |||
142 | data->date = date; | ||
143 | data->isCompleted = completed; | ||
144 | data->hasDate = hasDate; | ||
145 | data->priority = priority; | ||
146 | data->sum = summary; | ||
147 | data->prog = progress; | ||
148 | data->desc = Qtopia::simplifyMultiLineSpace( description ); | ||
149 | } | ||
150 | |||
151 | |||
152 | bool OPimTodo::match( const QRegExp ®Exp ) const | ||
153 | { | ||
154 | if ( QString::number( data->priority ).find( regExp ) != -1 ) | ||
155 | { | ||
156 | setLastHitField( Priority ); | ||
157 | return true; | ||
158 | } | ||
159 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) | ||
160 | { | ||
161 | setLastHitField( HasDate ); | ||
162 | return true; | ||
163 | } | ||
164 | else if ( data->desc.find( regExp ) != -1 ) | ||
165 | { | ||
166 | setLastHitField( Description ); | ||
167 | return true; | ||
168 | } | ||
169 | else if ( data->sum.find( regExp ) != -1 ) | ||
170 | { | ||
171 | setLastHitField( Summary ); | ||
172 | return true; | ||
173 | } | ||
174 | return false; | ||
175 | } | ||
176 | |||
177 | |||
178 | bool OPimTodo::isCompleted() const | ||
179 | { | ||
180 | return data->isCompleted; | ||
181 | } | ||
182 | |||
183 | |||
184 | bool OPimTodo::hasDueDate() const | ||
185 | { | ||
186 | return data->hasDate; | ||
187 | } | ||
188 | |||
189 | |||
190 | bool OPimTodo::hasStartDate() const | ||
191 | { | ||
192 | return data->start.isValid(); | ||
193 | } | ||
194 | |||
195 | |||
196 | bool OPimTodo::hasCompletedDate() const | ||
197 | { | ||
198 | return data->completed.isValid(); | ||
199 | } | ||
200 | |||
201 | |||
202 | int OPimTodo::priority() const | ||
203 | { | ||
204 | return data->priority; | ||
205 | } | ||
206 | |||
207 | |||
208 | QString OPimTodo::summary() const | ||
209 | { | ||
210 | return data->sum; | ||
211 | } | ||
212 | |||
213 | |||
214 | ushort OPimTodo::progress() const | ||
215 | { | ||
216 | return data->prog; | ||
217 | } | ||
218 | |||
219 | |||
220 | QDate OPimTodo::dueDate() const | ||
221 | { | ||
222 | return data->date; | ||
223 | } | ||
224 | |||
225 | |||
226 | QDate OPimTodo::startDate() const | ||
227 | { | ||
228 | return data->start; | ||
229 | } | ||
230 | |||
231 | |||
232 | QDate OPimTodo::completedDate() const | ||
233 | { | ||
234 | return data->completed; | ||
235 | } | ||
236 | |||
237 | |||
238 | QString OPimTodo::description() const | ||
239 | { | ||
240 | return data->desc; | ||
241 | } | ||
242 | |||
243 | |||
244 | bool OPimTodo::hasState() const | ||
245 | { | ||
246 | if ( !data->state ) return false; | ||
247 | return ( data->state->state() != OPimState::Undefined ); | ||
248 | } | ||
249 | |||
250 | |||
251 | OPimState OPimTodo::state() const | ||
252 | { | ||
253 | if ( !data->state ) | ||
254 | { | ||
255 | OPimState state; | ||
256 | return state; | ||
257 | } | ||
258 | |||
259 | return ( *data->state ); | ||
260 | } | ||
261 | |||
262 | |||
263 | bool OPimTodo::hasRecurrence() const | ||
264 | { | ||
265 | if ( !data->recur ) return false; | ||
266 | return data->recur->doesRecur(); | ||
267 | } | ||
268 | |||
269 | |||
270 | OPimRecurrence OPimTodo::recurrence() const | ||
271 | { | ||
272 | if ( !data->recur ) return OPimRecurrence(); | ||
273 | |||
274 | return ( *data->recur ); | ||
275 | } | ||
276 | |||
277 | |||
278 | bool OPimTodo::hasMaintainer() const | ||
279 | { | ||
280 | if ( !data->maintainer ) return false; | ||
281 | |||
282 | return ( data->maintainer->mode() != OPimMaintainer::Undefined ); | ||
283 | } | ||
284 | |||
285 | |||
286 | OPimMaintainer OPimTodo::maintainer() const | ||
287 | { | ||
288 | if ( !data->maintainer ) return OPimMaintainer(); | ||
289 | |||
290 | return ( *data->maintainer ); | ||
291 | } | ||
292 | |||
293 | |||
294 | void OPimTodo::setCompleted( bool completed ) | ||
295 | { | ||
296 | changeOrModify(); | ||
297 | data->isCompleted = completed; | ||
298 | } | ||
299 | |||
300 | |||
301 | void OPimTodo::setHasDueDate( bool hasDate ) | ||
302 | { | ||
303 | changeOrModify(); | ||
304 | data->hasDate = hasDate; | ||
305 | } | ||
306 | |||
307 | |||
308 | void OPimTodo::setDescription( const QString &desc ) | ||
309 | { | ||
310 | // qWarning( "desc " + desc ); | ||
311 | changeOrModify(); | ||
312 | data->desc = Qtopia::simplifyMultiLineSpace( desc ); | ||
313 | } | ||
314 | |||
315 | |||
316 | void OPimTodo::setSummary( const QString& sum ) | ||
317 | { | ||
318 | changeOrModify(); | ||
319 | data->sum = sum; | ||
320 | } | ||
321 | |||
322 | |||
323 | void OPimTodo::setPriority( int prio ) | ||
324 | { | ||
325 | changeOrModify(); | ||
326 | data->priority = prio; | ||
327 | } | ||
328 | |||
329 | |||
330 | void OPimTodo::setDueDate( const QDate& date ) | ||
331 | { | ||
332 | changeOrModify(); | ||
333 | data->date = date; | ||
334 | } | ||
335 | |||
336 | |||
337 | void OPimTodo::setStartDate( const QDate& date ) | ||
338 | { | ||
339 | changeOrModify(); | ||
340 | data->start = date; | ||
341 | } | ||
342 | |||
343 | |||
344 | void OPimTodo::setCompletedDate( const QDate& date ) | ||
345 | { | ||
346 | changeOrModify(); | ||
347 | data->completed = date; | ||
348 | } | ||
349 | |||
350 | |||
351 | void OPimTodo::setState( const OPimState& state ) | ||
352 | { | ||
353 | changeOrModify(); | ||
354 | if ( data->state ) | ||
355 | ( *data->state ) = state; | ||
356 | else | ||
357 | data->state = new OPimState( state ); | ||
358 | } | ||
359 | |||
360 | |||
361 | void OPimTodo::setRecurrence( const OPimRecurrence& rec ) | ||
362 | { | ||
363 | changeOrModify(); | ||
364 | if ( data->recur ) | ||
365 | ( *data->recur ) = rec; | ||
366 | else | ||
367 | data->recur = new OPimRecurrence( rec ); | ||
368 | } | ||
369 | |||
370 | |||
371 | void OPimTodo::setMaintainer( const OPimMaintainer& pim ) | ||
372 | { | ||
373 | changeOrModify(); | ||
374 | |||
375 | if ( data->maintainer ) | ||
376 | ( *data->maintainer ) = pim; | ||
377 | else | ||
378 | data->maintainer = new OPimMaintainer( pim ); | ||
379 | } | ||
380 | |||
381 | |||
382 | bool OPimTodo::isOverdue( ) | ||
383 | { | ||
384 | if ( data->hasDate && !data->isCompleted ) | ||
385 | return QDate::currentDate() > data->date; | ||
386 | return false; | ||
387 | } | ||
388 | |||
389 | |||
390 | void OPimTodo::setProgress( ushort progress ) | ||
391 | { | ||
392 | changeOrModify(); | ||
393 | data->prog = progress; | ||
394 | } | ||
395 | |||
396 | |||
397 | QString OPimTodo::toShortText() const | ||
398 | { | ||
399 | return summary(); | ||
400 | } | ||
401 | |||
402 | |||
403 | /*! | ||
404 | Returns a richt text string | ||
405 | */ | ||
406 | QString OPimTodo::toRichText() const | ||
407 | { | ||
408 | QString text; | ||
409 | QStringList catlist; | ||
410 | |||
411 | // summary | ||
412 | text += "<b><h3><img src=\"todo/TodoList\"> "; | ||
413 | if ( !summary().isEmpty() ) | ||
414 | { | ||
415 | text += Qtopia::escapeString( summary() ).replace( QRegExp( "[\n]" ), "" ); | ||
416 | } | ||
417 | text += "</h3></b><br><hr><br>"; | ||
418 | |||
419 | // description | ||
420 | if ( !description().isEmpty() ) | ||
421 | { | ||
422 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | ||
423 | text += Qtopia::escapeString( description() ).replace( QRegExp( "[\n]" ), "<br>" ) + "<br>"; | ||
424 | } | ||
425 | |||
426 | // priority | ||
427 | int priorityval = priority(); | ||
428 | text += "<b>" + QObject::tr( "Priority:" ) + " </b><img src=\"todo/priority" + | ||
429 | QString::number( priorityval ) + "\"> "; | ||
430 | |||
431 | switch ( priorityval ) | ||
432 | { | ||
433 | case 1 : text += QObject::tr( "Very high" ); | ||
434 | break; | ||
435 | case 2 : text += QObject::tr( "High" ); | ||
436 | break; | ||
437 | case 3 : text += QObject::tr( "Normal" ); | ||
438 | break; | ||
439 | case 4 : text += QObject::tr( "Low" ); | ||
440 | break; | ||
441 | case 5 : text += QObject::tr( "Very low" ); | ||
442 | break; | ||
443 | }; | ||
444 | text += "<br>"; | ||
445 | |||
446 | // progress | ||
447 | text += "<b>" + QObject::tr( "Progress:" ) + " </b>" | ||
448 | + QString::number( progress() ) + " %<br>"; | ||
449 | |||
450 | // due date | ||
451 | if ( hasDueDate() ) | ||
452 | { | ||
453 | QDate dd = dueDate(); | ||
454 | int off = QDate::currentDate().daysTo( dd ); | ||
455 | |||
456 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | ||
457 | if ( off < 0 ) | ||
458 | text += "#FF0000"; | ||
459 | else if ( off == 0 ) | ||
460 | text += "#FFFF00"; | ||
461 | else if ( off > 0 ) | ||
462 | text += "#00FF00"; | ||
463 | |||
464 | text += "\">" + dd.toString() + "</font><br>"; | ||
465 | } | ||
466 | |||
467 | // categories | ||
468 | text += "<b>" + QObject::tr( "Category:" ) + "</b> "; | ||
469 | text += categoryNames( "Todo List" ).join( ", " ); | ||
470 | text += "<br>"; | ||
471 | |||
472 | return text; | ||
473 | } | ||
474 | |||
475 | |||
476 | bool OPimTodo::hasNotifiers() const | ||
477 | { | ||
478 | if ( !data->notifiers ) return false; | ||
479 | return !data->notifiers->isEmpty(); | ||
480 | } | ||
481 | |||
482 | |||
483 | OPimNotifyManager& OPimTodo::notifiers() | ||
484 | { | ||
485 | if ( !data->notifiers ) | ||
486 | data->notifiers = new OPimNotifyManager; | ||
487 | return ( *data->notifiers ); | ||
488 | } | ||
489 | |||
490 | |||
491 | const OPimNotifyManager& OPimTodo::notifiers() const | ||
492 | { | ||
493 | if ( !data->notifiers ) | ||
494 | data->notifiers = new OPimNotifyManager; | ||
495 | |||
496 | return ( *data->notifiers ); | ||
497 | } | ||
498 | |||
499 | |||
500 | bool OPimTodo::operator<( const OPimTodo &toDoEvent ) const | ||
501 | { | ||
502 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | ||
503 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | ||
504 | if ( hasDueDate() && toDoEvent.hasDueDate() ) | ||
505 | { | ||
506 | if ( dueDate() == toDoEvent.dueDate() ) | ||
507 | { // let's the priority decide | ||
508 | return priority() < toDoEvent.priority(); | ||
509 | } | ||
510 | else | ||
511 | { | ||
512 | return dueDate() < toDoEvent.dueDate(); | ||
513 | } | ||
514 | } | ||
515 | return false; | ||
516 | } | ||
517 | |||
518 | |||
519 | bool OPimTodo::operator<=( const OPimTodo &toDoEvent ) const | ||
520 | { | ||
521 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | ||
522 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | ||
523 | if ( hasDueDate() && toDoEvent.hasDueDate() ) | ||
524 | { | ||
525 | if ( dueDate() == toDoEvent.dueDate() ) | ||
526 | { // let's the priority decide | ||
527 | return priority() <= toDoEvent.priority(); | ||
528 | } | ||
529 | else | ||
530 | { | ||
531 | return dueDate() <= toDoEvent.dueDate(); | ||
532 | } | ||
533 | } | ||
534 | return true; | ||
535 | } | ||
536 | |||
537 | |||
538 | bool OPimTodo::operator>( const OPimTodo &toDoEvent ) const | ||
539 | { | ||
540 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | ||
541 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | ||
542 | if ( hasDueDate() && toDoEvent.hasDueDate() ) | ||
543 | { | ||
544 | if ( dueDate() == toDoEvent.dueDate() ) | ||
545 | { // let's the priority decide | ||
546 | return priority() > toDoEvent.priority(); | ||
547 | } | ||
548 | else | ||
549 | { | ||
550 | return dueDate() > toDoEvent.dueDate(); | ||
551 | } | ||
552 | } | ||
553 | return false; | ||
554 | } | ||
555 | |||
556 | |||
557 | bool OPimTodo::operator>=( const OPimTodo &toDoEvent ) const | ||
558 | { | ||
559 | if ( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | ||
560 | if ( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | ||
561 | if ( hasDueDate() && toDoEvent.hasDueDate() ) | ||
562 | { | ||
563 | if ( dueDate() == toDoEvent.dueDate() ) | ||
564 | { // let's the priority decide | ||
565 | return priority() > toDoEvent.priority(); | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | return dueDate() > toDoEvent.dueDate(); | ||
570 | } | ||
571 | } | ||
572 | return true; | ||
573 | } | ||
574 | |||
575 | |||
576 | bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const | ||
577 | { | ||
578 | if ( data->priority != toDoEvent.data->priority ) return false; | ||
579 | if ( data->priority != toDoEvent.data->prog ) return false; | ||
580 | if ( data->isCompleted != toDoEvent.data->isCompleted ) return false; | ||
581 | if ( data->hasDate != toDoEvent.data->hasDate ) return false; | ||
582 | if ( data->date != toDoEvent.data->date ) return false; | ||
583 | if ( data->sum != toDoEvent.data->sum ) return false; | ||
584 | if ( data->desc != toDoEvent.data->desc ) return false; | ||
585 | if ( data->maintainer != toDoEvent.data->maintainer ) | ||
586 | return false; | ||
587 | |||
588 | return OPimRecord::operator==( toDoEvent ); | ||
589 | } | ||
590 | |||
591 | |||
592 | void OPimTodo::deref() | ||
593 | { | ||
594 | |||
595 | // qWarning("deref in ToDoEvent"); | ||
596 | if ( data->deref() ) | ||
597 | { | ||
598 | // qWarning("deleting"); | ||
599 | delete data; | ||
600 | data = 0; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | |||
605 | OPimTodo &OPimTodo::operator=( const OPimTodo &item ) | ||
606 | { | ||
607 | if ( this == &item ) return * this; | ||
608 | |||
609 | OPimRecord::operator=( item ); | ||
610 | //qWarning("operator= ref "); | ||
611 | item.data->ref(); | ||
612 | deref(); | ||
613 | data = item.data; | ||
614 | |||
615 | return *this; | ||
616 | } | ||
617 | |||
618 | |||
619 | QMap<int, QString> OPimTodo::toMap() const | ||
620 | { | ||
621 | QMap<int, QString> map; | ||
622 | |||
623 | map.insert( Uid, QString::number( uid() ) ); | ||
624 | map.insert( Category, idsToString( categories() ) ); | ||
625 | map.insert( HasDate, QString::number( data->hasDate ) ); | ||
626 | map.insert( Completed, QString::number( data->isCompleted ) ); | ||
627 | map.insert( Description, data->desc ); | ||
628 | map.insert( Summary, data->sum ); | ||
629 | map.insert( Priority, QString::number( data->priority ) ); | ||
630 | map.insert( DateDay, QString::number( data->date.day() ) ); | ||
631 | map.insert( DateMonth, QString::number( data->date.month() ) ); | ||
632 | map.insert( DateYear, QString::number( data->date.year() ) ); | ||
633 | map.insert( Progress, QString::number( data->prog ) ); | ||
634 | // map.insert( CrossReference, crossToString() ); | ||
635 | /* FIXME!!! map.insert( State, ); | ||
636 | map.insert( Recurrence, ); | ||
637 | map.insert( Reminders, ); | ||
638 | map. | ||
639 | */ | ||
640 | return map; | ||
641 | } | ||
642 | |||
643 | |||
644 | /** | ||
645 | * change or modify looks at the ref count and either | ||
646 | * creates a new QShared Object or it can modify it | ||
647 | * right in place | ||
648 | */ | ||
649 | void OPimTodo::changeOrModify() | ||
650 | { | ||
651 | if ( data->count != 1 ) | ||
652 | { | ||
653 | qWarning( "changeOrModify" ); | ||
654 | data->deref(); | ||
655 | OPimTodoData* d2 = new OPimTodoData(); | ||
656 | copy( data, d2 ); | ||
657 | data = d2; | ||
658 | } | ||
659 | } | ||
660 | |||
661 | |||
662 | // WATCHOUT | ||
663 | /* | ||
664 | * if you add something to the Data struct | ||
665 | * be sure to copy it here | ||
666 | */ | ||
667 | void OPimTodo::copy( OPimTodoData* src, OPimTodoData* dest ) | ||
668 | { | ||
669 | dest->date = src->date; | ||
670 | dest->isCompleted = src->isCompleted; | ||
671 | dest->hasDate = src->hasDate; | ||
672 | dest->priority = src->priority; | ||
673 | dest->desc = src->desc; | ||
674 | dest->sum = src->sum; | ||
675 | dest->extra = src->extra; | ||
676 | dest->prog = src->prog; | ||
677 | |||
678 | if ( src->state ) | ||
679 | dest->state = new OPimState( *src->state ); | ||
680 | |||
681 | if ( src->recur ) | ||
682 | dest->recur = new OPimRecurrence( *src->recur ); | ||
683 | |||
684 | if ( src->maintainer ) | ||
685 | dest->maintainer = new OPimMaintainer( *src->maintainer ) | ||
686 | ; | ||
687 | dest->start = src->start; | ||
688 | dest->completed = src->completed; | ||
689 | |||
690 | if ( src->notifiers ) | ||
691 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | ||
692 | } | ||
693 | |||
694 | |||
695 | QString OPimTodo::type() const | ||
696 | { | ||
697 | return QString::fromLatin1( "OPimTodo" ); | ||
698 | } | ||
699 | |||
700 | |||
701 | QString OPimTodo::recordField( int /*id*/ ) const | ||
702 | { | ||
703 | return QString::null; | ||
704 | } | ||
705 | |||
706 | |||
707 | int OPimTodo::rtti() | ||
708 | { | ||
709 | return OPimResolver::TodoList; | ||
710 | } | ||
711 | |||
712 | } | ||