-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 | |||
@@ -554,96 +554,105 @@ void Incidence::addAlarm(Alarm *alarm) | |||
554 | mAlarms.append(alarm); | 554 | mAlarms.append(alarm); |
555 | updated(); | 555 | updated(); |
556 | } | 556 | } |
557 | 557 | ||
558 | void Incidence::removeAlarm(Alarm *alarm) | 558 | void Incidence::removeAlarm(Alarm *alarm) |
559 | { | 559 | { |
560 | mAlarms.removeRef(alarm); | 560 | mAlarms.removeRef(alarm); |
561 | updated(); | 561 | updated(); |
562 | } | 562 | } |
563 | 563 | ||
564 | void Incidence::clearAlarms() | 564 | void Incidence::clearAlarms() |
565 | { | 565 | { |
566 | mAlarms.clear(); | 566 | mAlarms.clear(); |
567 | updated(); | 567 | updated(); |
568 | } | 568 | } |
569 | 569 | ||
570 | bool Incidence::isAlarmEnabled() const | 570 | bool Incidence::isAlarmEnabled() const |
571 | { | 571 | { |
572 | Alarm* alarm; | 572 | Alarm* alarm; |
573 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 573 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
574 | if (alarm->enabled()) | 574 | if (alarm->enabled()) |
575 | return true; | 575 | return true; |
576 | } | 576 | } |
577 | return false; | 577 | return false; |
578 | } | 578 | } |
579 | 579 | ||
580 | Recurrence *Incidence::recurrence() const | 580 | Recurrence *Incidence::recurrence() const |
581 | { | 581 | { |
582 | return mRecurrence; | 582 | return mRecurrence; |
583 | } | 583 | } |
584 | void Incidence::setRecurrence( Recurrence * r) | 584 | void Incidence::setRecurrence( Recurrence * r) |
585 | { | 585 | { |
586 | delete mRecurrence; | 586 | delete mRecurrence; |
587 | mRecurrence = r; | 587 | mRecurrence = r; |
588 | } | 588 | } |
589 | 589 | ||
590 | void Incidence::setLocation(const QString &location) | 590 | void Incidence::setLocation(const QString &location) |
591 | { | 591 | { |
592 | if (mReadOnly) return; | 592 | if (mReadOnly) return; |
593 | mLocation = location; | 593 | mLocation = location; |
594 | updated(); | 594 | updated(); |
595 | } | 595 | } |
596 | 596 | ||
597 | QString Incidence::location() const | 597 | QString Incidence::location() const |
598 | { | 598 | { |
599 | return mLocation; | 599 | return mLocation; |
600 | } | 600 | } |
601 | 601 | ||
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 | } | ||