-rw-r--r-- | libkcal/incidence.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index dbc159c..0684af2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -602,48 +602,57 @@ QString Incidence::location() const | |||
602 | ushort Incidence::doesRecur() const | 602 | ushort Incidence::doesRecur() const |
603 | { | 603 | { |
604 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 604 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
605 | else return Recurrence::rNone; | 605 | else return Recurrence::rNone; |
606 | } | 606 | } |
607 | 607 | ||
608 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 608 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
609 | { | 609 | { |
610 | QDateTime incidenceStart = dt; | 610 | QDateTime incidenceStart = dt; |
611 | *ok = false; | 611 | *ok = false; |
612 | if ( doesRecur() ) { | 612 | if ( doesRecur() ) { |
613 | bool last; | 613 | bool last; |
614 | recurrence()->getPreviousDateTime( incidenceStart , &last ); | 614 | recurrence()->getPreviousDateTime( incidenceStart , &last ); |
615 | int count = 0; | 615 | int count = 0; |
616 | if ( !last ) { | 616 | if ( !last ) { |
617 | while ( !last ) { | 617 | while ( !last ) { |
618 | ++count; | 618 | ++count; |
619 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); | 619 | incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); |
620 | if ( recursOn( incidenceStart.date() ) ) { | 620 | if ( recursOn( incidenceStart.date() ) ) { |
621 | last = true; // exit while llop | 621 | last = true; // exit while llop |
622 | } else { | 622 | } else { |
623 | if ( last ) { // no alarm on last recurrence | 623 | if ( last ) { // no alarm on last recurrence |
624 | return QDateTime (); | 624 | return QDateTime (); |
625 | } | 625 | } |
626 | int year = incidenceStart.date().year(); | 626 | int year = incidenceStart.date().year(); |
627 | // workaround for bug in recurrence | 627 | // workaround for bug in recurrence |
628 | if ( count == 100 || year < 1000 || year > 5000 ) { | 628 | if ( count == 100 || year < 1000 || year > 5000 ) { |
629 | return QDateTime (); | 629 | return QDateTime (); |
630 | } | 630 | } |
631 | incidenceStart = incidenceStart.addSecs( 1 ); | 631 | incidenceStart = incidenceStart.addSecs( 1 ); |
632 | } | 632 | } |
633 | } | 633 | } |
634 | } else { | 634 | } else { |
635 | return QDateTime (); | 635 | return QDateTime (); |
636 | } | 636 | } |
637 | } else { | 637 | } else { |
638 | if ( hasStartDate () ) { | 638 | if ( hasStartDate () ) { |
639 | incidenceStart = dtStart(); | 639 | incidenceStart = dtStart(); |
640 | } | 640 | } |
641 | if ( type() =="Todo" ) { | 641 | if ( type() =="Todo" ) { |
642 | if ( ((Todo*)this)->hasDueDate() ) | 642 | if ( ((Todo*)this)->hasDueDate() ) |
643 | incidenceStart = ((Todo*)this)->dtDue(); | 643 | incidenceStart = ((Todo*)this)->dtDue(); |
644 | } | 644 | } |
645 | } | 645 | } |
646 | if ( incidenceStart > dt ) | 646 | if ( incidenceStart > dt ) |
647 | *ok = true; | 647 | *ok = true; |
648 | return incidenceStart; | 648 | return incidenceStart; |
649 | } | 649 | } |
650 | QDateTime Incidence::dtStart() const | ||
651 | { | ||
652 | if ( doesRecur() ) { | ||
653 | if ( type() == "Todo" ) { | ||
654 | ((Todo*)this)->checkSetCompletedFalse(); | ||
655 | } | ||
656 | } | ||
657 | return mDtStart; | ||
658 | } | ||