-rw-r--r-- | libopie2/opiepim/otodo.cpp | 294 |
1 files changed, 228 insertions, 66 deletions
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index 3eb0026..f534067 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -27,9 +27,13 @@ | |||
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qobject.h> | ||
30 | #include <qshared.h> | ||
31 | |||
32 | 29 | ||
30 | #include "otodo.h" | ||
33 | 31 | ||
32 | /* OPIE */ | ||
33 | #include <opie2/opimstate.h> | ||
34 | #include <opie2/orecur.h> | ||
35 | #include <opie2/opimmaintainer.h> | ||
36 | #include <opie2/opimnotifymanager.h> | ||
37 | #include <opie2/opimresolver.h> | ||
34 | #include <qpe/palmtopuidgen.h> | 38 | #include <qpe/palmtopuidgen.h> |
35 | #include <qpe/stringutil.h> | 39 | #include <qpe/stringutil.h> |
@@ -39,17 +43,15 @@ | |||
39 | #include <qpe/categoryselect.h> | 43 | #include <qpe/categoryselect.h> |
40 | 44 | ||
45 | /* QT */ | ||
46 | #include <qobject.h> | ||
47 | #include <qshared.h> | ||
41 | 48 | ||
42 | #include <opie2/opimstate.h> | 49 | namespace Opie |
43 | #include <opie2/orecur.h> | 50 | { |
44 | #include <opie2/opimmaintainer.h> | ||
45 | #include <opie2/opimnotifymanager.h> | ||
46 | #include <opie2/opimresolver.h> | ||
47 | |||
48 | #include <opie2/otodo.h> | ||
49 | |||
50 | namespace Opie { | ||
51 | 51 | ||
52 | struct OTodo::OTodoData : public QShared { | 52 | struct OTodo::OTodoData : public QShared |
53 | OTodoData() : QShared() { | 53 | { |
54 | OTodoData() : QShared() | ||
55 | { | ||
54 | recur = 0; | 56 | recur = 0; |
55 | state = 0; | 57 | state = 0; |
@@ -57,5 +59,6 @@ struct OTodo::OTodoData : public QShared { | |||
57 | notifiers = 0; | 59 | notifiers = 0; |
58 | }; | 60 | }; |
59 | ~OTodoData() { | 61 | ~OTodoData() |
62 | { | ||
60 | delete recur; | 63 | delete recur; |
61 | delete maintainer; | 64 | delete maintainer; |
@@ -79,4 +82,5 @@ struct OTodo::OTodoData : public QShared { | |||
79 | }; | 82 | }; |
80 | 83 | ||
84 | |||
81 | OTodo::OTodo(const OTodo &event ) | 85 | OTodo::OTodo(const OTodo &event ) |
82 | : OPimRecord( event ), data( event.data ) | 86 | : OPimRecord( event ), data( event.data ) |
@@ -85,8 +89,12 @@ OTodo::OTodo(const OTodo &event ) | |||
85 | // qWarning("ref up"); | 89 | // qWarning("ref up"); |
86 | } | 90 | } |
87 | OTodo::~OTodo() { | 91 | |
92 | |||
93 | OTodo::~OTodo() | ||
94 | { | ||
88 | 95 | ||
89 | // qWarning("~OTodo " ); | 96 | // qWarning("~OTodo " ); |
90 | if ( data->deref() ) { | 97 | if ( data->deref() ) |
98 | { | ||
91 | // qWarning("OTodo::dereffing"); | 99 | // qWarning("OTodo::dereffing"); |
92 | delete data; | 100 | delete data; |
@@ -94,4 +102,6 @@ OTodo::~OTodo() { | |||
94 | } | 102 | } |
95 | } | 103 | } |
104 | |||
105 | |||
96 | OTodo::OTodo(bool completed, int priority, | 106 | OTodo::OTodo(bool completed, int priority, |
97 | const QArray<int> &category, | 107 | const QArray<int> &category, |
@@ -115,4 +125,6 @@ OTodo::OTodo(bool completed, int priority, | |||
115 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 125 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
116 | } | 126 | } |
127 | |||
128 | |||
117 | OTodo::OTodo(bool completed, int priority, | 129 | OTodo::OTodo(bool completed, int priority, |
118 | const QStringList &category, | 130 | const QStringList &category, |
@@ -136,16 +148,25 @@ OTodo::OTodo(bool completed, int priority, | |||
136 | data->desc = Qtopia::simplifyMultiLineSpace(description ); | 148 | data->desc = Qtopia::simplifyMultiLineSpace(description ); |
137 | } | 149 | } |
150 | |||
151 | |||
138 | bool OTodo::match( const QRegExp ®Exp )const | 152 | bool OTodo::match( const QRegExp ®Exp )const |
139 | { | 153 | { |
140 | if( QString::number( data->priority ).find( regExp ) != -1 ){ | 154 | if ( QString::number( data->priority ).find( regExp ) != -1 ) |
155 | { | ||
141 | setLastHitField( Priority ); | 156 | setLastHitField( Priority ); |
142 | return true; | 157 | return true; |
143 | }else if( data->hasDate && data->date.toString().find( regExp) != -1 ){ | 158 | } |
159 | else if ( data->hasDate && data->date.toString().find( regExp ) != -1 ) | ||
160 | { | ||
144 | setLastHitField( HasDate ); | 161 | setLastHitField( HasDate ); |
145 | return true; | 162 | return true; |
146 | }else if(data->desc.find( regExp ) != -1 ){ | 163 | } |
164 | else if ( data->desc.find( regExp ) != -1 ) | ||
165 | { | ||
147 | setLastHitField( Description ); | 166 | setLastHitField( Description ); |
148 | return true; | 167 | return true; |
149 | }else if(data->sum.find( regExp ) != -1 ) { | 168 | } |
169 | else if ( data->sum.find( regExp ) != -1 ) | ||
170 | { | ||
150 | setLastHitField( Summary ); | 171 | setLastHitField( Summary ); |
151 | return true; | 172 | return true; |
@@ -153,50 +174,83 @@ bool OTodo::match( const QRegExp ®Exp )const | |||
153 | return false; | 174 | return false; |
154 | } | 175 | } |
176 | |||
177 | |||
155 | bool OTodo::isCompleted() const | 178 | bool OTodo::isCompleted() const |
156 | { | 179 | { |
157 | return data->isCompleted; | 180 | return data->isCompleted; |
158 | } | 181 | } |
182 | |||
183 | |||
159 | bool OTodo::hasDueDate() const | 184 | bool OTodo::hasDueDate() const |
160 | { | 185 | { |
161 | return data->hasDate; | 186 | return data->hasDate; |
162 | } | 187 | } |
163 | bool OTodo::hasStartDate()const { | 188 | |
189 | |||
190 | bool OTodo::hasStartDate() const | ||
191 | { | ||
164 | return data->start.isValid(); | 192 | return data->start.isValid(); |
165 | } | 193 | } |
166 | bool OTodo::hasCompletedDate()const { | 194 | |
195 | |||
196 | bool OTodo::hasCompletedDate() const | ||
197 | { | ||
167 | return data->completed.isValid(); | 198 | return data->completed.isValid(); |
168 | } | 199 | } |
200 | |||
201 | |||
169 | int OTodo::priority()const | 202 | int OTodo::priority()const |
170 | { | 203 | { |
171 | return data->priority; | 204 | return data->priority; |
172 | } | 205 | } |
206 | |||
207 | |||
173 | QString OTodo::summary() const | 208 | QString OTodo::summary() const |
174 | { | 209 | { |
175 | return data->sum; | 210 | return data->sum; |
176 | } | 211 | } |
212 | |||
213 | |||
177 | ushort OTodo::progress() const | 214 | ushort OTodo::progress() const |
178 | { | 215 | { |
179 | return data->prog; | 216 | return data->prog; |
180 | } | 217 | } |
218 | |||
219 | |||
181 | QDate OTodo::dueDate()const | 220 | QDate OTodo::dueDate()const |
182 | { | 221 | { |
183 | return data->date; | 222 | return data->date; |
184 | } | 223 | } |
185 | QDate OTodo::startDate()const { | 224 | |
225 | |||
226 | QDate OTodo::startDate() const | ||
227 | { | ||
186 | return data->start; | 228 | return data->start; |
187 | } | 229 | } |
188 | QDate OTodo::completedDate()const { | 230 | |
231 | |||
232 | QDate OTodo::completedDate() const | ||
233 | { | ||
189 | return data->completed; | 234 | return data->completed; |
190 | } | 235 | } |
236 | |||
237 | |||
191 | QString OTodo::description()const | 238 | QString OTodo::description()const |
192 | { | 239 | { |
193 | return data->desc; | 240 | return data->desc; |
194 | } | 241 | } |
195 | bool OTodo::hasState() const{ | 242 | |
243 | |||
244 | bool OTodo::hasState() const | ||
245 | { | ||
196 | if (!data->state ) return false; | 246 | if (!data->state ) return false; |
197 | return ( data->state->state() != OPimState::Undefined ); | 247 | return ( data->state->state() != OPimState::Undefined ); |
198 | } | 248 | } |
199 | OPimState OTodo::state()const { | 249 | |
200 | if (!data->state ) { | 250 | |
251 | OPimState OTodo::state() const | ||
252 | { | ||
253 | if ( !data->state ) | ||
254 | { | ||
201 | OPimState state; | 255 | OPimState state; |
202 | return state; | 256 | return state; |
@@ -205,23 +259,37 @@ OPimState OTodo::state()const { | |||
205 | return (*data->state); | 259 | return (*data->state); |
206 | } | 260 | } |
207 | bool OTodo::hasRecurrence()const { | 261 | |
262 | |||
263 | bool OTodo::hasRecurrence() const | ||
264 | { | ||
208 | if (!data->recur) return false; | 265 | if (!data->recur) return false; |
209 | return data->recur->doesRecur(); | 266 | return data->recur->doesRecur(); |
210 | } | 267 | } |
211 | ORecur OTodo::recurrence()const { | 268 | |
269 | |||
270 | ORecur OTodo::recurrence() const | ||
271 | { | ||
212 | if (!data->recur) return ORecur(); | 272 | if (!data->recur) return ORecur(); |
213 | 273 | ||
214 | return (*data->recur); | 274 | return (*data->recur); |
215 | } | 275 | } |
216 | bool OTodo::hasMaintainer()const { | 276 | |
277 | |||
278 | bool OTodo::hasMaintainer() const | ||
279 | { | ||
217 | if (!data->maintainer) return false; | 280 | if (!data->maintainer) return false; |
218 | 281 | ||
219 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); | 282 | return (data->maintainer->mode() != OPimMaintainer::Undefined ); |
220 | } | 283 | } |
221 | OPimMaintainer OTodo::maintainer()const { | 284 | |
285 | |||
286 | OPimMaintainer OTodo::maintainer() const | ||
287 | { | ||
222 | if (!data->maintainer) return OPimMaintainer(); | 288 | if (!data->maintainer) return OPimMaintainer(); |
223 | 289 | ||
224 | return (*data->maintainer); | 290 | return (*data->maintainer); |
225 | } | 291 | } |
292 | |||
293 | |||
226 | void OTodo::setCompleted( bool completed ) | 294 | void OTodo::setCompleted( bool completed ) |
227 | { | 295 | { |
@@ -229,4 +297,6 @@ void OTodo::setCompleted( bool completed ) | |||
229 | data->isCompleted = completed; | 297 | data->isCompleted = completed; |
230 | } | 298 | } |
299 | |||
300 | |||
231 | void OTodo::setHasDueDate( bool hasDate ) | 301 | void OTodo::setHasDueDate( bool hasDate ) |
232 | { | 302 | { |
@@ -234,4 +304,6 @@ void OTodo::setHasDueDate( bool hasDate ) | |||
234 | data->hasDate = hasDate; | 304 | data->hasDate = hasDate; |
235 | } | 305 | } |
306 | |||
307 | |||
236 | void OTodo::setDescription(const QString &desc ) | 308 | void OTodo::setDescription(const QString &desc ) |
237 | { | 309 | { |
@@ -240,4 +312,6 @@ void OTodo::setDescription(const QString &desc ) | |||
240 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); | 312 | data->desc = Qtopia::simplifyMultiLineSpace(desc ); |
241 | } | 313 | } |
314 | |||
315 | |||
242 | void OTodo::setSummary( const QString& sum ) | 316 | void OTodo::setSummary( const QString& sum ) |
243 | { | 317 | { |
@@ -245,4 +319,6 @@ void OTodo::setSummary( const QString& sum ) | |||
245 | data->sum = sum; | 319 | data->sum = sum; |
246 | } | 320 | } |
321 | |||
322 | |||
247 | void OTodo::setPriority(int prio ) | 323 | void OTodo::setPriority(int prio ) |
248 | { | 324 | { |
@@ -250,4 +326,6 @@ void OTodo::setPriority(int prio ) | |||
250 | data->priority = prio; | 326 | data->priority = prio; |
251 | } | 327 | } |
328 | |||
329 | |||
252 | void OTodo::setDueDate( const QDate& date ) | 330 | void OTodo::setDueDate( const QDate& date ) |
253 | { | 331 | { |
@@ -255,13 +333,22 @@ void OTodo::setDueDate( const QDate& date ) | |||
255 | data->date = date; | 333 | data->date = date; |
256 | } | 334 | } |
257 | void OTodo::setStartDate( const QDate& date ) { | 335 | |
336 | |||
337 | void OTodo::setStartDate( const QDate& date ) | ||
338 | { | ||
258 | changeOrModify(); | 339 | changeOrModify(); |
259 | data->start = date; | 340 | data->start = date; |
260 | } | 341 | } |
261 | void OTodo::setCompletedDate( const QDate& date ) { | 342 | |
343 | |||
344 | void OTodo::setCompletedDate( const QDate& date ) | ||
345 | { | ||
262 | changeOrModify(); | 346 | changeOrModify(); |
263 | data->completed = date; | 347 | data->completed = date; |
264 | } | 348 | } |
265 | void OTodo::setState( const OPimState& state ) { | 349 | |
350 | |||
351 | void OTodo::setState( const OPimState& state ) | ||
352 | { | ||
266 | changeOrModify(); | 353 | changeOrModify(); |
267 | if (data->state ) | 354 | if (data->state ) |
@@ -270,5 +357,8 @@ void OTodo::setState( const OPimState& state ) { | |||
270 | data->state = new OPimState( state ); | 357 | data->state = new OPimState( state ); |
271 | } | 358 | } |
272 | void OTodo::setRecurrence( const ORecur& rec) { | 359 | |
360 | |||
361 | void OTodo::setRecurrence( const ORecur& rec ) | ||
362 | { | ||
273 | changeOrModify(); | 363 | changeOrModify(); |
274 | if (data->recur ) | 364 | if (data->recur ) |
@@ -277,5 +367,8 @@ void OTodo::setRecurrence( const ORecur& rec) { | |||
277 | data->recur = new ORecur( rec ); | 367 | data->recur = new ORecur( rec ); |
278 | } | 368 | } |
279 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 369 | |
370 | |||
371 | void OTodo::setMaintainer( const OPimMaintainer& pim ) | ||
372 | { | ||
280 | changeOrModify(); | 373 | changeOrModify(); |
281 | 374 | ||
@@ -285,4 +378,6 @@ void OTodo::setMaintainer( const OPimMaintainer& pim ) { | |||
285 | data->maintainer = new OPimMaintainer( pim ); | 378 | data->maintainer = new OPimMaintainer( pim ); |
286 | } | 379 | } |
380 | |||
381 | |||
287 | bool OTodo::isOverdue( ) | 382 | bool OTodo::isOverdue( ) |
288 | { | 383 | { |
@@ -291,4 +386,6 @@ bool OTodo::isOverdue( ) | |||
291 | return false; | 386 | return false; |
292 | } | 387 | } |
388 | |||
389 | |||
293 | void OTodo::setProgress(ushort progress ) | 390 | void OTodo::setProgress(ushort progress ) |
294 | { | 391 | { |
@@ -296,7 +393,12 @@ void OTodo::setProgress(ushort progress ) | |||
296 | data->prog = progress; | 393 | data->prog = progress; |
297 | } | 394 | } |
298 | QString OTodo::toShortText() const { | 395 | |
396 | |||
397 | QString OTodo::toShortText() const | ||
398 | { | ||
299 | return summary(); | 399 | return summary(); |
300 | } | 400 | } |
401 | |||
402 | |||
301 | /*! | 403 | /*! |
302 | Returns a richt text string | 404 | Returns a richt text string |
@@ -309,5 +411,6 @@ QString OTodo::toRichText() const | |||
309 | // summary | 411 | // summary |
310 | text += "<b><h3><img src=\"todo/TodoList\"> "; | 412 | text += "<b><h3><img src=\"todo/TodoList\"> "; |
311 | if ( !summary().isEmpty() ) { | 413 | if ( !summary().isEmpty() ) |
414 | { | ||
312 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); | 415 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); |
313 | } | 416 | } |
@@ -315,5 +418,6 @@ QString OTodo::toRichText() const | |||
315 | 418 | ||
316 | // description | 419 | // description |
317 | if( !description().isEmpty() ){ | 420 | if ( !description().isEmpty() ) |
421 | { | ||
318 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 422 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
319 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 423 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
@@ -345,5 +449,6 @@ QString OTodo::toRichText() const | |||
345 | 449 | ||
346 | // due date | 450 | // due date |
347 | if (hasDueDate() ){ | 451 | if ( hasDueDate() ) |
452 | { | ||
348 | QDate dd = dueDate(); | 453 | QDate dd = dueDate(); |
349 | int off = QDate::currentDate().daysTo( dd ); | 454 | int off = QDate::currentDate().daysTo( dd ); |
@@ -367,14 +472,23 @@ QString OTodo::toRichText() const | |||
367 | return text; | 472 | return text; |
368 | } | 473 | } |
369 | bool OTodo::hasNotifiers()const { | 474 | |
475 | |||
476 | bool OTodo::hasNotifiers() const | ||
477 | { | ||
370 | if (!data->notifiers) return false; | 478 | if (!data->notifiers) return false; |
371 | return !data->notifiers->isEmpty(); | 479 | return !data->notifiers->isEmpty(); |
372 | } | 480 | } |
373 | OPimNotifyManager& OTodo::notifiers() { | 481 | |
482 | |||
483 | OPimNotifyManager& OTodo::notifiers() | ||
484 | { | ||
374 | if (!data->notifiers ) | 485 | if (!data->notifiers ) |
375 | data->notifiers = new OPimNotifyManager; | 486 | data->notifiers = new OPimNotifyManager; |
376 | return (*data->notifiers); | 487 | return (*data->notifiers); |
377 | } | 488 | } |
378 | const OPimNotifyManager& OTodo::notifiers()const{ | 489 | |
490 | |||
491 | const OPimNotifyManager& OTodo::notifiers() const | ||
492 | { | ||
379 | if (!data->notifiers ) | 493 | if (!data->notifiers ) |
380 | data->notifiers = new OPimNotifyManager; | 494 | data->notifiers = new OPimNotifyManager; |
@@ -383,11 +497,17 @@ const OPimNotifyManager& OTodo::notifiers()const{ | |||
383 | } | 497 | } |
384 | 498 | ||
385 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 499 | |
500 | bool OTodo::operator<( const OTodo &toDoEvent ) const | ||
501 | { | ||
386 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 502 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
387 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 503 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
388 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 504 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
389 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 505 | { |
506 | if ( dueDate() == toDoEvent.dueDate() ) | ||
507 | { // let's the priority decide | ||
390 | return priority() < toDoEvent.priority(); | 508 | return priority() < toDoEvent.priority(); |
391 | }else{ | 509 | } |
510 | else | ||
511 | { | ||
392 | return dueDate() < toDoEvent.dueDate(); | 512 | return dueDate() < toDoEvent.dueDate(); |
393 | } | 513 | } |
@@ -395,12 +515,18 @@ bool OTodo::operator<( const OTodo &toDoEvent )const{ | |||
395 | return false; | 515 | return false; |
396 | } | 516 | } |
517 | |||
518 | |||
397 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 519 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
398 | { | 520 | { |
399 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 521 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
400 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 522 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
401 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 523 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
402 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 524 | { |
525 | if ( dueDate() == toDoEvent.dueDate() ) | ||
526 | { // let's the priority decide | ||
403 | return priority() <= toDoEvent.priority(); | 527 | return priority() <= toDoEvent.priority(); |
404 | }else{ | 528 | } |
529 | else | ||
530 | { | ||
405 | return dueDate() <= toDoEvent.dueDate(); | 531 | return dueDate() <= toDoEvent.dueDate(); |
406 | } | 532 | } |
@@ -408,12 +534,18 @@ bool OTodo::operator<=(const OTodo &toDoEvent )const | |||
408 | return true; | 534 | return true; |
409 | } | 535 | } |
536 | |||
537 | |||
410 | bool OTodo::operator>(const OTodo &toDoEvent )const | 538 | bool OTodo::operator>(const OTodo &toDoEvent )const |
411 | { | 539 | { |
412 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; | 540 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return false; |
413 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 541 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
414 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 542 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
415 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 543 | { |
544 | if ( dueDate() == toDoEvent.dueDate() ) | ||
545 | { // let's the priority decide | ||
416 | return priority() > toDoEvent.priority(); | 546 | return priority() > toDoEvent.priority(); |
417 | }else{ | 547 | } |
548 | else | ||
549 | { | ||
418 | return dueDate() > toDoEvent.dueDate(); | 550 | return dueDate() > toDoEvent.dueDate(); |
419 | } | 551 | } |
@@ -421,12 +553,18 @@ bool OTodo::operator>(const OTodo &toDoEvent )const | |||
421 | return false; | 553 | return false; |
422 | } | 554 | } |
555 | |||
556 | |||
423 | bool OTodo::operator>=(const OTodo &toDoEvent )const | 557 | bool OTodo::operator>=(const OTodo &toDoEvent )const |
424 | { | 558 | { |
425 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 559 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
426 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 560 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
427 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 561 | if ( hasDueDate() && toDoEvent.hasDueDate() ) |
428 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 562 | { |
563 | if ( dueDate() == toDoEvent.dueDate() ) | ||
564 | { // let's the priority decide | ||
429 | return priority() > toDoEvent.priority(); | 565 | return priority() > toDoEvent.priority(); |
430 | }else{ | 566 | } |
567 | else | ||
568 | { | ||
431 | return dueDate() > toDoEvent.dueDate(); | 569 | return dueDate() > toDoEvent.dueDate(); |
432 | } | 570 | } |
@@ -434,4 +572,6 @@ bool OTodo::operator>=(const OTodo &toDoEvent )const | |||
434 | return true; | 572 | return true; |
435 | } | 573 | } |
574 | |||
575 | |||
436 | bool OTodo::operator==(const OTodo &toDoEvent )const | 576 | bool OTodo::operator==(const OTodo &toDoEvent )const |
437 | { | 577 | { |
@@ -448,8 +588,12 @@ bool OTodo::operator==(const OTodo &toDoEvent )const | |||
448 | return OPimRecord::operator==( toDoEvent ); | 588 | return OPimRecord::operator==( toDoEvent ); |
449 | } | 589 | } |
450 | void OTodo::deref() { | 590 | |
591 | |||
592 | void OTodo::deref() | ||
593 | { | ||
451 | 594 | ||
452 | // qWarning("deref in ToDoEvent"); | 595 | // qWarning("deref in ToDoEvent"); |
453 | if ( data->deref() ) { | 596 | if ( data->deref() ) |
597 | { | ||
454 | // qWarning("deleting"); | 598 | // qWarning("deleting"); |
455 | delete data; | 599 | delete data; |
@@ -457,4 +601,6 @@ void OTodo::deref() { | |||
457 | } | 601 | } |
458 | } | 602 | } |
603 | |||
604 | |||
459 | OTodo &OTodo::operator=(const OTodo &item ) | 605 | OTodo &OTodo::operator=(const OTodo &item ) |
460 | { | 606 | { |
@@ -470,5 +616,7 @@ OTodo &OTodo::operator=(const OTodo &item ) | |||
470 | } | 616 | } |
471 | 617 | ||
472 | QMap<int, QString> OTodo::toMap() const { | 618 | |
619 | QMap<int, QString> OTodo::toMap() const | ||
620 | { | ||
473 | QMap<int, QString> map; | 621 | QMap<int, QString> map; |
474 | 622 | ||
@@ -493,4 +641,5 @@ QMap<int, QString> OTodo::toMap() const { | |||
493 | } | 641 | } |
494 | 642 | ||
643 | |||
495 | /** | 644 | /** |
496 | * change or modify looks at the ref count and either | 645 | * change or modify looks at the ref count and either |
@@ -498,6 +647,8 @@ QMap<int, QString> OTodo::toMap() const { | |||
498 | * right in place | 647 | * right in place |
499 | */ | 648 | */ |
500 | void OTodo::changeOrModify() { | 649 | void OTodo::changeOrModify() |
501 | if ( data->count != 1 ) { | 650 | { |
651 | if ( data->count != 1 ) | ||
652 | { | ||
502 | qWarning("changeOrModify"); | 653 | qWarning("changeOrModify"); |
503 | data->deref(); | 654 | data->deref(); |
@@ -507,4 +658,6 @@ void OTodo::changeOrModify() { | |||
507 | } | 658 | } |
508 | } | 659 | } |
660 | |||
661 | |||
509 | // WATCHOUT | 662 | // WATCHOUT |
510 | /* | 663 | /* |
@@ -512,5 +665,6 @@ void OTodo::changeOrModify() { | |||
512 | * be sure to copy it here | 665 | * be sure to copy it here |
513 | */ | 666 | */ |
514 | void OTodo::copy( OTodoData* src, OTodoData* dest ) { | 667 | void OTodo::copy( OTodoData* src, OTodoData* dest ) |
668 | { | ||
515 | dest->date = src->date; | 669 | dest->date = src->date; |
516 | dest->isCompleted = src->isCompleted; | 670 | dest->isCompleted = src->isCompleted; |
@@ -537,12 +691,20 @@ void OTodo::copy( OTodoData* src, OTodoData* dest ) { | |||
537 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); | 691 | dest->notifiers = new OPimNotifyManager( *src->notifiers ); |
538 | } | 692 | } |
539 | QString OTodo::type() const { | 693 | |
694 | |||
695 | QString OTodo::type() const | ||
696 | { | ||
540 | return QString::fromLatin1("OTodo"); | 697 | return QString::fromLatin1("OTodo"); |
541 | } | 698 | } |
542 | QString OTodo::recordField(int /*id*/ )const { | 699 | |
700 | |||
701 | QString OTodo::recordField( int /*id*/ ) const | ||
702 | { | ||
543 | return QString::null; | 703 | return QString::null; |
544 | } | 704 | } |
545 | 705 | ||
546 | int OTodo::rtti(){ | 706 | |
707 | int OTodo::rtti() | ||
708 | { | ||
547 | return OPimResolver::TodoList; | 709 | return OPimResolver::TodoList; |
548 | } | 710 | } |