summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
Unidiff
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index cc1c5ae..5a0c32e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -562,122 +562,122 @@ int Todo::percentComplete() const
562 return mPercentComplete; 562 return mPercentComplete;
563} 563}
564bool Todo::setRecurDates() 564bool Todo::setRecurDates()
565{ 565{
566 if ( !mHasRecurrenceID ) 566 if ( !mHasRecurrenceID )
567 return true; 567 return true;
568 int secs = mDtStart.secsTo( dtDue() ); 568 int secs = mDtStart.secsTo( dtDue() );
569 bool ok; 569 bool ok;
570 qDebug("T:setRecurDates() "); 570 qDebug("T:setRecurDates() ");
571 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 571 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
572 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 572 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
573 if ( ok ) { 573 if ( ok ) {
574 mRecurrenceID = next; 574 mRecurrenceID = next;
575 mDtStart = next; 575 mDtStart = next;
576 setDtDue( next.addSecs( secs ) ); 576 setDtDue( next.addSecs( secs ) );
577 if ( QDateTime::currentDateTime() > next) 577 if ( QDateTime::currentDateTime() > next)
578 return false; 578 return false;
579 } else { 579 } else {
580 setHasRecurrenceID( false ); 580 setHasRecurrenceID( false );
581 recurrence()->unsetRecurs(); 581 recurrence()->unsetRecurs();
582 } 582 }
583 return true; 583 return true;
584} 584}
585void Todo::setPercentComplete(int v) 585void Todo::setPercentComplete(int v)
586{ 586{
587 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 587 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
588 if ( !setRecurDates() ) 588 if ( !setRecurDates() )
589 v = 0; 589 v = 0;
590 } 590 }
591 mPercentComplete = v; 591 mPercentComplete = v;
592 if ( v != 100 ) 592 if ( v != 100 )
593 mHasCompletedDate = false; 593 mHasCompletedDate = false;
594 updated(); 594 updated();
595} 595}
596QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const 596QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const
597{ 597{
598 *ok = false; 598 *ok = false;
599 if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) { 599 if ( ! hasDueDate() || cancelled() || !alarmEnabled() ) {
600 return QDateTime (); 600 return QDateTime ();
601 } 601 }
602 // if the recurring todo is set to complete and requested time < start time of todo 602 // if the recurring todo is set to complete and requested time < start time of todo
603 // we want to get the alarm. 603 // we want to get the alarm.
604 bool iscompleted = isCompleted(); 604 bool iscompleted = isCompleted();
605 if ( iscompleted && doesRecur() ) { 605 if ( iscompleted && doesRecur() ) {
606 Todo * to = (Todo*) this; 606 Todo * to = (Todo*) this;
607 to->checkSetCompletedFalse(); 607 to->checkSetCompletedFalse();
608 iscompleted = isCompleted(); 608 iscompleted = isCompleted();
609 if ( hasStartDate() && start_dt < dtStart() ){ 609 if ( hasStartDate() && start_dt < dtStart() ){
610 iscompleted = false; 610 iscompleted = false;
611 } 611 }
612 } 612 }
613 if ( iscompleted ) { 613 if ( iscompleted ) {
614 return QDateTime (); 614 return QDateTime ();
615 } 615 }
616 QDateTime incidenceStart; 616 QDateTime incidenceStart;
617 incidenceStart = dtDue(); 617 incidenceStart = dtDue();
618 bool enabled = false; 618 bool enabled = false;
619 Alarm* alarm; 619 Alarm* alarm;
620 int off = 0; 620 int off = 0;
621 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 621 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
622 // if ( QDateTime::currentDateTime() > incidenceStart ){ 622 // if ( QDateTime::currentDateTime() > incidenceStart ){
623// *ok = false; 623// *ok = false;
624// return incidenceStart; 624// return incidenceStart;
625// } 625// }
626 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 626 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
627 if (alarm->enabled()) { 627 if (alarm->enabled()) {
628 if ( alarm->hasTime () ) { 628 if ( alarm->hasTime () ) {
629 if ( alarm->time() < alarmStart ) { 629 if ( alarm->time() < alarmStart ) {
630 alarmStart = alarm->time(); 630 alarmStart = alarm->time();
631 enabled = true; 631 enabled = true;
632 off = alarmStart.secsTo( incidenceStart ); 632 off = alarmStart.secsTo( incidenceStart );
633 } 633 }
634 634
635 } else { 635 } else {
636 int secs = alarm->startOffset().asSeconds(); 636 int secs = alarm->startOffset().asSeconds();
637 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 637 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
638 alarmStart = incidenceStart.addSecs( secs ); 638 alarmStart = incidenceStart.addSecs( secs );
639 enabled = true; 639 enabled = true;
640 off = -secs; 640 off = -secs;
641 } 641 }
642 } 642 }
643 } 643 }
644 } 644 }
645 if ( enabled ) { 645 if ( enabled ) {
646 if ( alarmStart > start_dt ) { 646 if ( alarmStart > start_dt ) {
647 *ok = true; 647 *ok = true;
648 * offset = off; 648 * offset = off;
649 return alarmStart; 649 return alarmStart;
650 } 650 }
651 } 651 }
652 *ok = false; 652 *ok = false;
653 return QDateTime (); 653 return QDateTime ();
654 654
655} 655}
656 656
657void Todo::checkSetCompletedFalse() 657void Todo::checkSetCompletedFalse()
658{ 658{
659 if ( !mHasRecurrenceID ) { 659 if ( !mHasRecurrenceID ) {
660 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 660 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
661 return; 661 return;
662 } 662 }
663 // qDebug("Todo::checkSetCompletedFalse()"); 663 // qDebug("Todo::checkSetCompletedFalse()");
664 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 664 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
665 if ( mPercentComplete == 100 ) { 665 if ( mPercentComplete == 100 ) {
666 QDateTime dt = QDateTime::currentDateTime(); 666 QDateTime dt = QDateTime::currentDateTime();
667 if ( dt > mDtStart && dt > mRecurrenceID ) { 667 if ( dt > mDtStart && dt > mRecurrenceID ) {
668 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 668 qDebug("start: %s --due: %s --recID: %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
669 setCompleted( false ); 669 setCompleted( false );
670 qDebug("Todo::checkSetCompletedFalse "); 670 qDebug("Todo::checkSetCompletedFalse ");
671 } 671 }
672 } 672 }
673} 673}
674QString Todo::durationText() 674QString Todo::durationText()
675{ 675{
676 if ( mHasDueDate && hasStartDate() ) { 676 if ( mHasDueDate && hasStartDate() ) {
677 int sec = dtStart().secsTo( dtDue() ); 677 int sec = dtStart().secsTo( dtDue() );
678 if ( doesFloat() ) 678 if ( doesFloat() )
679 sec += 86400; 679 sec += 86400;
680 return durationText4Time( sec ); 680 return durationText4Time( sec );
681 } 681 }
682 return "---"; 682 return "---";
683} 683}