author | zautrix <zautrix> | 2005-07-01 04:42:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-01 04:42:26 (UTC) |
commit | 4a47a69978fd392be65ea67c5153d5e2ade74c19 (patch) (unidiff) | |
tree | 4208a2955c206adc826209c7854e0c628c1c5441 | |
parent | d401e425af46703a89eb80802606edeea06c9538 (diff) | |
download | kdepimpi-4a47a69978fd392be65ea67c5153d5e2ade74c19.zip kdepimpi-4a47a69978fd392be65ea67c5153d5e2ade74c19.tar.gz kdepimpi-4a47a69978fd392be65ea67c5153d5e2ade74c19.tar.bz2 |
alarm fixx
-rw-r--r-- | libkcal/todo.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 5260051..4ada2d8 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -516,50 +516,64 @@ bool Todo::setRecurDates() | |||
516 | mRecurrenceID = next; | 516 | mRecurrenceID = next; |
517 | mDtStart = next; | 517 | mDtStart = next; |
518 | setDtDue( next.addSecs( secs ) ); | 518 | setDtDue( next.addSecs( secs ) ); |
519 | if ( QDateTime::currentDateTime() > next) | 519 | if ( QDateTime::currentDateTime() > next) |
520 | return false; | 520 | return false; |
521 | } else { | 521 | } else { |
522 | setHasRecurrenceID( false ); | 522 | setHasRecurrenceID( false ); |
523 | recurrence()->unsetRecurs(); | 523 | recurrence()->unsetRecurs(); |
524 | } | 524 | } |
525 | return true; | 525 | return true; |
526 | } | 526 | } |
527 | void Todo::setPercentComplete(int v) | 527 | void Todo::setPercentComplete(int v) |
528 | { | 528 | { |
529 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | 529 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { |
530 | if ( !setRecurDates() ) | 530 | if ( !setRecurDates() ) |
531 | v = 0; | 531 | v = 0; |
532 | } | 532 | } |
533 | mPercentComplete = v; | 533 | mPercentComplete = v; |
534 | if ( v != 100 ) | 534 | if ( v != 100 ) |
535 | mHasCompletedDate = false; | 535 | mHasCompletedDate = false; |
536 | updated(); | 536 | updated(); |
537 | } | 537 | } |
538 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 538 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
539 | { | 539 | { |
540 | if ( isCompleted() || ! hasDueDate() || cancelled() || !alarmEnabled() ) { | ||
541 | *ok = false; | 540 | *ok = false; |
541 | if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { | ||
542 | return QDateTime (); | ||
543 | } | ||
544 | // if the recurring todo is set to complete and requested time < start time of todo | ||
545 | // we want to get the alarm. | ||
546 | bool iscompleted = isCompleted(); | ||
547 | if ( iscompleted && doesRecur() ) { | ||
548 | Todo * to = (Todo*) this; | ||
549 | to->checkSetCompletedFalse(); | ||
550 | iscompleted = isCompleted(); | ||
551 | if ( hasStartDate() && start_dt < dtStart() ){ | ||
552 | iscompleted = false; | ||
553 | } | ||
554 | } | ||
555 | if ( iscompleted ) { | ||
542 | return QDateTime (); | 556 | return QDateTime (); |
543 | } | 557 | } |
544 | QDateTime incidenceStart; | 558 | QDateTime incidenceStart; |
545 | incidenceStart = dtDue(); | 559 | incidenceStart = dtDue(); |
546 | bool enabled = false; | 560 | bool enabled = false; |
547 | Alarm* alarm; | 561 | Alarm* alarm; |
548 | int off = 0; | 562 | int off = 0; |
549 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 563 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
550 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 564 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
551 | // *ok = false; | 565 | // *ok = false; |
552 | // return incidenceStart; | 566 | // return incidenceStart; |
553 | // } | 567 | // } |
554 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 568 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
555 | if (alarm->enabled()) { | 569 | if (alarm->enabled()) { |
556 | if ( alarm->hasTime () ) { | 570 | if ( alarm->hasTime () ) { |
557 | if ( alarm->time() < alarmStart ) { | 571 | if ( alarm->time() < alarmStart ) { |
558 | alarmStart = alarm->time(); | 572 | alarmStart = alarm->time(); |
559 | enabled = true; | 573 | enabled = true; |
560 | off = alarmStart.secsTo( incidenceStart ); | 574 | off = alarmStart.secsTo( incidenceStart ); |
561 | } | 575 | } |
562 | 576 | ||
563 | } else { | 577 | } else { |
564 | int secs = alarm->startOffset().asSeconds(); | 578 | int secs = alarm->startOffset().asSeconds(); |
565 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 579 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |