author | zautrix <zautrix> | 2005-07-28 17:20:12 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-28 17:20:12 (UTC) |
commit | 21e3b4936180fe45ba9545cb3fe28b574f86f1b5 (patch) (unidiff) | |
tree | 59667b0b2738776f69206209c4653dc2e4487d3f | |
parent | 1f1a6829b042c804e5b547b181dc50c4539d5551 (diff) | |
download | kdepimpi-21e3b4936180fe45ba9545cb3fe28b574f86f1b5.zip kdepimpi-21e3b4936180fe45ba9545cb3fe28b574f86f1b5.tar.gz kdepimpi-21e3b4936180fe45ba9545cb3fe28b574f86f1b5.tar.bz2 |
rec fix
-rw-r--r-- | libkcal/incidence.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 201f593..52d94fb 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -563,278 +563,279 @@ void Incidence::setExDates(const DateList &exDates) | |||
563 | if (mReadOnly) return; | 563 | if (mReadOnly) return; |
564 | mExDates = exDates; | 564 | mExDates = exDates; |
565 | recurrence()->setRecurExDatesCount(mExDates.count()); | 565 | recurrence()->setRecurExDatesCount(mExDates.count()); |
566 | 566 | ||
567 | updated(); | 567 | updated(); |
568 | } | 568 | } |
569 | 569 | ||
570 | void Incidence::addExDate(const QDate &date) | 570 | void Incidence::addExDate(const QDate &date) |
571 | { | 571 | { |
572 | if (mReadOnly) return; | 572 | if (mReadOnly) return; |
573 | mExDates.append(date); | 573 | mExDates.append(date); |
574 | 574 | ||
575 | recurrence()->setRecurExDatesCount(mExDates.count()); | 575 | recurrence()->setRecurExDatesCount(mExDates.count()); |
576 | 576 | ||
577 | updated(); | 577 | updated(); |
578 | } | 578 | } |
579 | 579 | ||
580 | DateList Incidence::exDates() const | 580 | DateList Incidence::exDates() const |
581 | { | 581 | { |
582 | return mExDates; | 582 | return mExDates; |
583 | } | 583 | } |
584 | 584 | ||
585 | bool Incidence::isException(const QDate &date) const | 585 | bool Incidence::isException(const QDate &date) const |
586 | { | 586 | { |
587 | DateList::ConstIterator it; | 587 | DateList::ConstIterator it; |
588 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 588 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
589 | if ( (*it) == date ) { | 589 | if ( (*it) == date ) { |
590 | return true; | 590 | return true; |
591 | } | 591 | } |
592 | } | 592 | } |
593 | 593 | ||
594 | return false; | 594 | return false; |
595 | } | 595 | } |
596 | 596 | ||
597 | void Incidence::addAttachment(Attachment *attachment) | 597 | void Incidence::addAttachment(Attachment *attachment) |
598 | { | 598 | { |
599 | if (mReadOnly || !attachment) return; | 599 | if (mReadOnly || !attachment) return; |
600 | mAttachments.append(attachment); | 600 | mAttachments.append(attachment); |
601 | updated(); | 601 | updated(); |
602 | } | 602 | } |
603 | 603 | ||
604 | void Incidence::deleteAttachment(Attachment *attachment) | 604 | void Incidence::deleteAttachment(Attachment *attachment) |
605 | { | 605 | { |
606 | mAttachments.removeRef(attachment); | 606 | mAttachments.removeRef(attachment); |
607 | } | 607 | } |
608 | 608 | ||
609 | void Incidence::deleteAttachments(const QString& mime) | 609 | void Incidence::deleteAttachments(const QString& mime) |
610 | { | 610 | { |
611 | Attachment *at = mAttachments.first(); | 611 | Attachment *at = mAttachments.first(); |
612 | while (at) { | 612 | while (at) { |
613 | if (at->mimeType() == mime) | 613 | if (at->mimeType() == mime) |
614 | mAttachments.remove(); | 614 | mAttachments.remove(); |
615 | else | 615 | else |
616 | at = mAttachments.next(); | 616 | at = mAttachments.next(); |
617 | } | 617 | } |
618 | } | 618 | } |
619 | 619 | ||
620 | QPtrList<Attachment> Incidence::attachments() const | 620 | QPtrList<Attachment> Incidence::attachments() const |
621 | { | 621 | { |
622 | return mAttachments; | 622 | return mAttachments; |
623 | } | 623 | } |
624 | 624 | ||
625 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 625 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
626 | { | 626 | { |
627 | QPtrList<Attachment> attachments; | 627 | QPtrList<Attachment> attachments; |
628 | QPtrListIterator<Attachment> it( mAttachments ); | 628 | QPtrListIterator<Attachment> it( mAttachments ); |
629 | Attachment *at; | 629 | Attachment *at; |
630 | while ( (at = it.current()) ) { | 630 | while ( (at = it.current()) ) { |
631 | if (at->mimeType() == mime) | 631 | if (at->mimeType() == mime) |
632 | attachments.append(at); | 632 | attachments.append(at); |
633 | ++it; | 633 | ++it; |
634 | } | 634 | } |
635 | 635 | ||
636 | return attachments; | 636 | return attachments; |
637 | } | 637 | } |
638 | 638 | ||
639 | void Incidence::setResources(const QStringList &resources) | 639 | void Incidence::setResources(const QStringList &resources) |
640 | { | 640 | { |
641 | if (mReadOnly) return; | 641 | if (mReadOnly) return; |
642 | mResources = resources; | 642 | mResources = resources; |
643 | updated(); | 643 | updated(); |
644 | } | 644 | } |
645 | 645 | ||
646 | QStringList Incidence::resources() const | 646 | QStringList Incidence::resources() const |
647 | { | 647 | { |
648 | return mResources; | 648 | return mResources; |
649 | } | 649 | } |
650 | 650 | ||
651 | 651 | ||
652 | void Incidence::setPriority(int priority) | 652 | void Incidence::setPriority(int priority) |
653 | { | 653 | { |
654 | if (mReadOnly) return; | 654 | if (mReadOnly) return; |
655 | mPriority = priority; | 655 | mPriority = priority; |
656 | updated(); | 656 | updated(); |
657 | } | 657 | } |
658 | 658 | ||
659 | int Incidence::priority() const | 659 | int Incidence::priority() const |
660 | { | 660 | { |
661 | return mPriority; | 661 | return mPriority; |
662 | } | 662 | } |
663 | 663 | ||
664 | void Incidence::setSecrecy(int sec) | 664 | void Incidence::setSecrecy(int sec) |
665 | { | 665 | { |
666 | if (mReadOnly) return; | 666 | if (mReadOnly) return; |
667 | mSecrecy = sec; | 667 | mSecrecy = sec; |
668 | updated(); | 668 | updated(); |
669 | } | 669 | } |
670 | 670 | ||
671 | int Incidence::secrecy() const | 671 | int Incidence::secrecy() const |
672 | { | 672 | { |
673 | return mSecrecy; | 673 | return mSecrecy; |
674 | } | 674 | } |
675 | 675 | ||
676 | QString Incidence::secrecyStr() const | 676 | QString Incidence::secrecyStr() const |
677 | { | 677 | { |
678 | return secrecyName(mSecrecy); | 678 | return secrecyName(mSecrecy); |
679 | } | 679 | } |
680 | 680 | ||
681 | QString Incidence::secrecyName(int secrecy) | 681 | QString Incidence::secrecyName(int secrecy) |
682 | { | 682 | { |
683 | switch (secrecy) { | 683 | switch (secrecy) { |
684 | case SecrecyPublic: | 684 | case SecrecyPublic: |
685 | return i18n("Public"); | 685 | return i18n("Public"); |
686 | break; | 686 | break; |
687 | case SecrecyPrivate: | 687 | case SecrecyPrivate: |
688 | return i18n("Private"); | 688 | return i18n("Private"); |
689 | break; | 689 | break; |
690 | case SecrecyConfidential: | 690 | case SecrecyConfidential: |
691 | return i18n("Confidential"); | 691 | return i18n("Confidential"); |
692 | break; | 692 | break; |
693 | default: | 693 | default: |
694 | return i18n("Undefined"); | 694 | return i18n("Undefined"); |
695 | break; | 695 | break; |
696 | } | 696 | } |
697 | } | 697 | } |
698 | 698 | ||
699 | QStringList Incidence::secrecyList() | 699 | QStringList Incidence::secrecyList() |
700 | { | 700 | { |
701 | QStringList list; | 701 | QStringList list; |
702 | list << secrecyName(SecrecyPublic); | 702 | list << secrecyName(SecrecyPublic); |
703 | list << secrecyName(SecrecyPrivate); | 703 | list << secrecyName(SecrecyPrivate); |
704 | list << secrecyName(SecrecyConfidential); | 704 | list << secrecyName(SecrecyConfidential); |
705 | 705 | ||
706 | return list; | 706 | return list; |
707 | } | 707 | } |
708 | 708 | ||
709 | 709 | ||
710 | QPtrList<Alarm> Incidence::alarms() const | 710 | QPtrList<Alarm> Incidence::alarms() const |
711 | { | 711 | { |
712 | return mAlarms; | 712 | return mAlarms; |
713 | } | 713 | } |
714 | 714 | ||
715 | Alarm* Incidence::newAlarm() | 715 | Alarm* Incidence::newAlarm() |
716 | { | 716 | { |
717 | Alarm* alarm = new Alarm(this); | 717 | Alarm* alarm = new Alarm(this); |
718 | mAlarms.append(alarm); | 718 | mAlarms.append(alarm); |
719 | // updated(); | 719 | // updated(); |
720 | return alarm; | 720 | return alarm; |
721 | } | 721 | } |
722 | 722 | ||
723 | void Incidence::addAlarm(Alarm *alarm) | 723 | void Incidence::addAlarm(Alarm *alarm) |
724 | { | 724 | { |
725 | mAlarms.append(alarm); | 725 | mAlarms.append(alarm); |
726 | updated(); | 726 | updated(); |
727 | } | 727 | } |
728 | 728 | ||
729 | void Incidence::removeAlarm(Alarm *alarm) | 729 | void Incidence::removeAlarm(Alarm *alarm) |
730 | { | 730 | { |
731 | mAlarms.removeRef(alarm); | 731 | mAlarms.removeRef(alarm); |
732 | updated(); | 732 | updated(); |
733 | } | 733 | } |
734 | 734 | ||
735 | void Incidence::clearAlarms() | 735 | void Incidence::clearAlarms() |
736 | { | 736 | { |
737 | mAlarms.clear(); | 737 | mAlarms.clear(); |
738 | updated(); | 738 | updated(); |
739 | } | 739 | } |
740 | 740 | ||
741 | bool Incidence::isAlarmEnabled() const | 741 | bool Incidence::isAlarmEnabled() const |
742 | { | 742 | { |
743 | Alarm* alarm; | 743 | Alarm* alarm; |
744 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 744 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
745 | if (alarm->enabled()) | 745 | if (alarm->enabled()) |
746 | return true; | 746 | return true; |
747 | } | 747 | } |
748 | return false; | 748 | return false; |
749 | } | 749 | } |
750 | #include <stdlib.h> | 750 | #include <stdlib.h> |
751 | Recurrence *Incidence::recurrence() | 751 | Recurrence *Incidence::recurrence() |
752 | { | 752 | { |
753 | if ( ! mRecurrence ) { | 753 | if ( ! mRecurrence ) { |
754 | mRecurrence = new Recurrence(this); | 754 | mRecurrence = new Recurrence(this); |
755 | qDebug("creating new recurence "); | 755 | mRecurrence->setRecurStart( dtStart() ); |
756 | //qDebug("creating new recurence "); | ||
756 | //abort(); | 757 | //abort(); |
757 | } | 758 | } |
758 | return mRecurrence; | 759 | return mRecurrence; |
759 | } | 760 | } |
760 | void Incidence::setRecurrence( Recurrence * r) | 761 | void Incidence::setRecurrence( Recurrence * r) |
761 | { | 762 | { |
762 | if ( mRecurrence ) | 763 | if ( mRecurrence ) |
763 | delete mRecurrence; | 764 | delete mRecurrence; |
764 | mRecurrence = r; | 765 | mRecurrence = r; |
765 | } | 766 | } |
766 | 767 | ||
767 | void Incidence::setLocation(const QString &location) | 768 | void Incidence::setLocation(const QString &location) |
768 | { | 769 | { |
769 | if (mReadOnly) return; | 770 | if (mReadOnly) return; |
770 | mLocation = location; | 771 | mLocation = location; |
771 | updated(); | 772 | updated(); |
772 | } | 773 | } |
773 | 774 | ||
774 | QString Incidence::location() const | 775 | QString Incidence::location() const |
775 | { | 776 | { |
776 | return mLocation; | 777 | return mLocation; |
777 | } | 778 | } |
778 | QString Incidence::recurrenceText() const | 779 | QString Incidence::recurrenceText() const |
779 | { | 780 | { |
780 | if ( mRecurrence ) return mRecurrence->recurrenceText(); | 781 | if ( mRecurrence ) return mRecurrence->recurrenceText(); |
781 | return i18n("No"); | 782 | return i18n("No"); |
782 | } | 783 | } |
783 | 784 | ||
784 | ushort Incidence::doesRecur() const | 785 | ushort Incidence::doesRecur() const |
785 | { | 786 | { |
786 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 787 | if ( mRecurrence ) return mRecurrence->doesRecur(); |
787 | else return Recurrence::rNone; | 788 | else return Recurrence::rNone; |
788 | } | 789 | } |
789 | 790 | ||
790 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | 791 | QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const |
791 | { | 792 | { |
792 | QDateTime incidenceStart = dt; | 793 | QDateTime incidenceStart = dt; |
793 | *ok = false; | 794 | *ok = false; |
794 | if ( doesRecur() ) { | 795 | if ( doesRecur() ) { |
795 | bool last; | 796 | bool last; |
796 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); | 797 | mRecurrence->getPreviousDateTime( incidenceStart , &last ); |
797 | int count = 0; | 798 | int count = 0; |
798 | if ( !last ) { | 799 | if ( !last ) { |
799 | while ( !last ) { | 800 | while ( !last ) { |
800 | ++count; | 801 | ++count; |
801 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); | 802 | incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); |
802 | if ( recursOn( incidenceStart.date() ) ) { | 803 | if ( recursOn( incidenceStart.date() ) ) { |
803 | last = true; // exit while llop | 804 | last = true; // exit while llop |
804 | } else { | 805 | } else { |
805 | if ( last ) { // no alarm on last recurrence | 806 | if ( last ) { // no alarm on last recurrence |
806 | return QDateTime (); | 807 | return QDateTime (); |
807 | } | 808 | } |
808 | int year = incidenceStart.date().year(); | 809 | int year = incidenceStart.date().year(); |
809 | // workaround for bug in recurrence | 810 | // workaround for bug in recurrence |
810 | if ( count == 100 || year < 1000 || year > 5000 ) { | 811 | if ( count == 100 || year < 1000 || year > 5000 ) { |
811 | return QDateTime (); | 812 | return QDateTime (); |
812 | } | 813 | } |
813 | incidenceStart = incidenceStart.addSecs( 1 ); | 814 | incidenceStart = incidenceStart.addSecs( 1 ); |
814 | } | 815 | } |
815 | } | 816 | } |
816 | } else { | 817 | } else { |
817 | return QDateTime (); | 818 | return QDateTime (); |
818 | } | 819 | } |
819 | } else { | 820 | } else { |
820 | if ( hasStartDate () ) { | 821 | if ( hasStartDate () ) { |
821 | incidenceStart = dtStart(); | 822 | incidenceStart = dtStart(); |
822 | } | 823 | } |
823 | if ( typeID() == todoID ) { | 824 | if ( typeID() == todoID ) { |
824 | if ( ((Todo*)this)->hasDueDate() ) | 825 | if ( ((Todo*)this)->hasDueDate() ) |
825 | incidenceStart = ((Todo*)this)->dtDue(); | 826 | incidenceStart = ((Todo*)this)->dtDue(); |
826 | } | 827 | } |
827 | } | 828 | } |
828 | if ( incidenceStart > dt ) | 829 | if ( incidenceStart > dt ) |
829 | *ok = true; | 830 | *ok = true; |
830 | return incidenceStart; | 831 | return incidenceStart; |
831 | } | 832 | } |
832 | QDateTime Incidence::dtStart() const | 833 | QDateTime Incidence::dtStart() const |
833 | { | 834 | { |
834 | if ( doesRecur() ) { | 835 | if ( doesRecur() ) { |
835 | if ( typeID() == todoID ) { | 836 | if ( typeID() == todoID ) { |
836 | ((Todo*)this)->checkSetCompletedFalse(); | 837 | ((Todo*)this)->checkSetCompletedFalse(); |
837 | } | 838 | } |
838 | } | 839 | } |
839 | return mDtStart; | 840 | return mDtStart; |
840 | } | 841 | } |