-rw-r--r-- | libkcal/todo.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7bf756a..e4508a0 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -553,64 +553,74 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d | |||
553 | iscompleted = false; | 553 | iscompleted = false; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | if ( iscompleted ) { | 556 | if ( iscompleted ) { |
557 | return QDateTime (); | 557 | return QDateTime (); |
558 | } | 558 | } |
559 | QDateTime incidenceStart; | 559 | QDateTime incidenceStart; |
560 | incidenceStart = dtDue(); | 560 | incidenceStart = dtDue(); |
561 | bool enabled = false; | 561 | bool enabled = false; |
562 | Alarm* alarm; | 562 | Alarm* alarm; |
563 | int off = 0; | 563 | int off = 0; |
564 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; | 564 | QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; |
565 | // if ( QDateTime::currentDateTime() > incidenceStart ){ | 565 | // if ( QDateTime::currentDateTime() > incidenceStart ){ |
566 | // *ok = false; | 566 | // *ok = false; |
567 | // return incidenceStart; | 567 | // return incidenceStart; |
568 | // } | 568 | // } |
569 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 569 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
570 | if (alarm->enabled()) { | 570 | if (alarm->enabled()) { |
571 | if ( alarm->hasTime () ) { | 571 | if ( alarm->hasTime () ) { |
572 | if ( alarm->time() < alarmStart ) { | 572 | if ( alarm->time() < alarmStart ) { |
573 | alarmStart = alarm->time(); | 573 | alarmStart = alarm->time(); |
574 | enabled = true; | 574 | enabled = true; |
575 | off = alarmStart.secsTo( incidenceStart ); | 575 | off = alarmStart.secsTo( incidenceStart ); |
576 | } | 576 | } |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | int secs = alarm->startOffset().asSeconds(); | 579 | int secs = alarm->startOffset().asSeconds(); |
580 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { | 580 | if ( incidenceStart.addSecs( secs ) < alarmStart ) { |
581 | alarmStart = incidenceStart.addSecs( secs ); | 581 | alarmStart = incidenceStart.addSecs( secs ); |
582 | enabled = true; | 582 | enabled = true; |
583 | off = -secs; | 583 | off = -secs; |
584 | } | 584 | } |
585 | } | 585 | } |
586 | } | 586 | } |
587 | } | 587 | } |
588 | if ( enabled ) { | 588 | if ( enabled ) { |
589 | if ( alarmStart > start_dt ) { | 589 | if ( alarmStart > start_dt ) { |
590 | *ok = true; | 590 | *ok = true; |
591 | * offset = off; | 591 | * offset = off; |
592 | return alarmStart; | 592 | return alarmStart; |
593 | } | 593 | } |
594 | } | 594 | } |
595 | *ok = false; | 595 | *ok = false; |
596 | return QDateTime (); | 596 | return QDateTime (); |
597 | 597 | ||
598 | } | 598 | } |
599 | 599 | ||
600 | void Todo::checkSetCompletedFalse() | 600 | void Todo::checkSetCompletedFalse() |
601 | { | 601 | { |
602 | if ( !mHasRecurrenceID ) { | 602 | if ( !mHasRecurrenceID ) { |
603 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | 603 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); |
604 | return; | 604 | return; |
605 | } | 605 | } |
606 | // qDebug("Todo::checkSetCompletedFalse()"); | 606 | // qDebug("Todo::checkSetCompletedFalse()"); |
607 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 607 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
608 | if ( mPercentComplete == 100 ) { | 608 | if ( mPercentComplete == 100 ) { |
609 | QDateTime dt = QDateTime::currentDateTime(); | 609 | QDateTime dt = QDateTime::currentDateTime(); |
610 | if ( dt > mDtStart && dt > mRecurrenceID ) { | 610 | if ( dt > mDtStart && dt > mRecurrenceID ) { |
611 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | 611 | qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); |
612 | setCompleted( false ); | 612 | setCompleted( false ); |
613 | qDebug("Todo::checkSetCompletedFalse "); | 613 | qDebug("Todo::checkSetCompletedFalse "); |
614 | } | 614 | } |
615 | } | 615 | } |
616 | } | 616 | } |
617 | QString Todo::durationText() | ||
618 | { | ||
619 | if ( mHasDueDate && hasStartDate() ) { | ||
620 | int sec = dtStart().secsTo( dtDue() ); | ||
621 | if ( doesFloat() ) | ||
622 | sec += 86400; | ||
623 | return durationText4Time( sec ); | ||
624 | } | ||
625 | return "---"; | ||
626 | } | ||