-rw-r--r-- | libkcal/todo.cpp | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 9c04a7e..1f54c2f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -310,14 +310,20 @@ QString Todo::statusStr() const | |||
310 | #endif | 310 | #endif |
311 | 311 | ||
312 | bool Todo::isCompleted() const | 312 | bool Todo::isCompleted() const |
313 | { | 313 | { |
314 | if (mPercentComplete == 100) return true; | 314 | if (mPercentComplete == 100) { |
315 | else return false; | 315 | return true; |
316 | } | ||
317 | else return false; | ||
316 | } | 318 | } |
317 | 319 | ||
318 | void Todo::setCompleted(bool completed) | 320 | void Todo::setCompleted(bool completed) |
319 | { | 321 | { |
322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | ||
323 | if ( !setRecurDates() ) | ||
324 | completed = false; | ||
325 | } | ||
320 | if (completed) mPercentComplete = 100; | 326 | if (completed) mPercentComplete = 100; |
321 | else { | 327 | else { |
322 | mPercentComplete = 0; | 328 | mPercentComplete = 0; |
323 | mHasCompletedDate = false; | 329 | mHasCompletedDate = false; |
@@ -356,11 +362,35 @@ bool Todo::hasCompletedDate() const | |||
356 | int Todo::percentComplete() const | 362 | int Todo::percentComplete() const |
357 | { | 363 | { |
358 | return mPercentComplete; | 364 | return mPercentComplete; |
359 | } | 365 | } |
360 | 366 | bool Todo::setRecurDates() | |
361 | void Todo::setPercentComplete(int v) | ||
362 | { | 367 | { |
368 | if ( !mHasRecurrenceID ) | ||
369 | return true; | ||
370 | int secs = mDtStart.secsTo( dtDue() ); | ||
371 | bool ok; | ||
372 | qDebug("--------------------setRecurDates() "); | ||
373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | ||
375 | if ( ok ) { | ||
376 | mRecurrenceID = next; | ||
377 | mDtStart = next; | ||
378 | setDtDue( next.addSecs( secs ) ); | ||
379 | if ( QDateTime::currentDateTime() > next) | ||
380 | return false; | ||
381 | } else { | ||
382 | setHasRecurrenceID( false ); | ||
383 | recurrence()->unsetRecurs(); | ||
384 | } | ||
385 | return true; | ||
386 | } | ||
387 | void Todo::setPercentComplete(int v) | ||
388 | { | ||
389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | ||
390 | if ( !setRecurDates() ) | ||
391 | v = 0; | ||
392 | } | ||
363 | mPercentComplete = v; | 393 | mPercentComplete = v; |
364 | if ( v != 100 ) | 394 | if ( v != 100 ) |
365 | mHasCompletedDate = false; | 395 | mHasCompletedDate = false; |
366 | updated(); | 396 | updated(); |
@@ -411,4 +441,17 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | |||
411 | return QDateTime (); | 441 | return QDateTime (); |
412 | 442 | ||
413 | } | 443 | } |
414 | 444 | ||
445 | void Todo::checkSetCompletedFalse() | ||
446 | { | ||
447 | if ( !hasRecurrenceID() ) { | ||
448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | ||
449 | } | ||
450 | // qDebug("Todo::checkSetCompletedFalse()"); | ||
451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | ||
453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
454 | setCompleted( false ); | ||
455 | qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); | ||
456 | } | ||
457 | } | ||