-rw-r--r-- | libkcal/todo.cpp | 2 |
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 | |||
@@ -498,186 +498,186 @@ QString Todo::statusStr() const | |||
498 | break; | 498 | break; |
499 | case COMPLETED: | 499 | case COMPLETED: |
500 | return QString("COMPLETED"); | 500 | return QString("COMPLETED"); |
501 | break; | 501 | break; |
502 | case DELEGATED: | 502 | case DELEGATED: |
503 | return QString("DELEGATED"); | 503 | return QString("DELEGATED"); |
504 | break; | 504 | break; |
505 | } | 505 | } |
506 | return QString(""); | 506 | return QString(""); |
507 | } | 507 | } |
508 | #endif | 508 | #endif |
509 | 509 | ||
510 | bool Todo::isCompleted() const | 510 | bool Todo::isCompleted() const |
511 | { | 511 | { |
512 | if (mPercentComplete == 100) { | 512 | if (mPercentComplete == 100) { |
513 | return true; | 513 | return true; |
514 | } | 514 | } |
515 | else return false; | 515 | else return false; |
516 | } | 516 | } |
517 | 517 | ||
518 | void Todo::setCompleted(bool completed) | 518 | void Todo::setCompleted(bool completed) |
519 | { | 519 | { |
520 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | 520 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { |
521 | if ( !setRecurDates() ) | 521 | if ( !setRecurDates() ) |
522 | completed = false; | 522 | completed = false; |
523 | } | 523 | } |
524 | if (completed) mPercentComplete = 100; | 524 | if (completed) mPercentComplete = 100; |
525 | else { | 525 | else { |
526 | mPercentComplete = 0; | 526 | mPercentComplete = 0; |
527 | mHasCompletedDate = false; | 527 | mHasCompletedDate = false; |
528 | } | 528 | } |
529 | updated(); | 529 | updated(); |
530 | } | 530 | } |
531 | 531 | ||
532 | QDateTime Todo::completed() const | 532 | QDateTime Todo::completed() const |
533 | { | 533 | { |
534 | return mCompleted; | 534 | return mCompleted; |
535 | } | 535 | } |
536 | 536 | ||
537 | QString Todo::completedStr( bool shortF ) const | 537 | QString Todo::completedStr( bool shortF ) const |
538 | { | 538 | { |
539 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); | 539 | return KGlobal::locale()->formatDateTime(mCompleted, shortF); |
540 | } | 540 | } |
541 | 541 | ||
542 | void Todo::setCompleted(const QDateTime &completed) | 542 | void Todo::setCompleted(const QDateTime &completed) |
543 | { | 543 | { |
544 | //qDebug("Todo::setCompleted "); | 544 | //qDebug("Todo::setCompleted "); |
545 | if ( mHasCompletedDate ) { | 545 | if ( mHasCompletedDate ) { |
546 | // qDebug("has completed data - return "); | 546 | // qDebug("has completed data - return "); |
547 | return; | 547 | return; |
548 | } | 548 | } |
549 | mHasCompletedDate = true; | 549 | mHasCompletedDate = true; |
550 | mPercentComplete = 100; | 550 | mPercentComplete = 100; |
551 | mCompleted = getEvenTime(completed); | 551 | mCompleted = getEvenTime(completed); |
552 | updated(); | 552 | updated(); |
553 | } | 553 | } |
554 | 554 | ||
555 | bool Todo::hasCompletedDate() const | 555 | bool Todo::hasCompletedDate() const |
556 | { | 556 | { |
557 | return mHasCompletedDate; | 557 | return mHasCompletedDate; |
558 | } | 558 | } |
559 | 559 | ||
560 | int Todo::percentComplete() const | 560 | int Todo::percentComplete() const |
561 | { | 561 | { |
562 | return mPercentComplete; | 562 | return mPercentComplete; |
563 | } | 563 | } |
564 | bool Todo::setRecurDates() | 564 | bool 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 | } |
585 | void Todo::setPercentComplete(int v) | 585 | void 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 | } |
596 | QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 596 | QDateTime 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 | ||
657 | void Todo::checkSetCompletedFalse() | 657 | void 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 | } |
674 | QString Todo::durationText() | 674 | QString 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 | } |