-rw-r--r-- | libkcal/incidence.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 549014e..39c14f5 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -27,68 +27,75 @@ | |||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = 0;//new Recurrence(this); | 36 | mRecurrence = 0;//new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | mAttachments = i.mAttachments; | 62 | QPtrListIterator<Attachment> itat( i.mAttachments ); |
63 | Attachment *at; | ||
64 | while( (at = itat.current()) ) { | ||
65 | Attachment *a = new Attachment( *at ); | ||
66 | mAttachments.append( a ); | ||
67 | ++itat; | ||
68 | } | ||
69 | mAttachments.setAutoDelete( true ); | ||
63 | mResources = i.mResources; | 70 | mResources = i.mResources; |
64 | mSecrecy = i.mSecrecy; | 71 | mSecrecy = i.mSecrecy; |
65 | mPriority = i.mPriority; | 72 | mPriority = i.mPriority; |
66 | mLocation = i.mLocation; | 73 | mLocation = i.mLocation; |
67 | mCancelled = i.mCancelled; | 74 | mCancelled = i.mCancelled; |
68 | mHasStartDate = i.mHasStartDate; | 75 | mHasStartDate = i.mHasStartDate; |
69 | QPtrListIterator<Alarm> it( i.mAlarms ); | 76 | QPtrListIterator<Alarm> it( i.mAlarms ); |
70 | const Alarm *a; | 77 | const Alarm *a; |
71 | while( (a = it.current()) ) { | 78 | while( (a = it.current()) ) { |
72 | Alarm *b = new Alarm( *a ); | 79 | Alarm *b = new Alarm( *a ); |
73 | b->setParent( this ); | 80 | b->setParent( this ); |
74 | mAlarms.append( b ); | 81 | mAlarms.append( b ); |
75 | 82 | ||
76 | ++it; | 83 | ++it; |
77 | } | 84 | } |
78 | mAlarms.setAutoDelete(true); | 85 | mAlarms.setAutoDelete(true); |
79 | mHasRecurrenceID = i.mHasRecurrenceID; | 86 | mHasRecurrenceID = i.mHasRecurrenceID; |
80 | mRecurrenceID = i.mRecurrenceID; | 87 | mRecurrenceID = i.mRecurrenceID; |
81 | if ( i.mRecurrence ) | 88 | if ( i.mRecurrence ) |
82 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 89 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
83 | else | 90 | else |
84 | mRecurrence = 0; | 91 | mRecurrence = 0; |
85 | mHoliday = i.mHoliday ; | 92 | mHoliday = i.mHoliday ; |
86 | mBirthday = i.mBirthday; | 93 | mBirthday = i.mBirthday; |
87 | mAnniversary = i.mAnniversary; | 94 | mAnniversary = i.mAnniversary; |
88 | } | 95 | } |
89 | 96 | ||
90 | Incidence::~Incidence() | 97 | Incidence::~Incidence() |
91 | { | 98 | { |
92 | 99 | ||
93 | Incidence *ev; | 100 | Incidence *ev; |
94 | QPtrList<Incidence> Relations = relations(); | 101 | QPtrList<Incidence> Relations = relations(); |
@@ -728,64 +735,65 @@ void Incidence::addAlarm(Alarm *alarm) | |||
728 | { | 735 | { |
729 | mAlarms.append(alarm); | 736 | mAlarms.append(alarm); |
730 | updated(); | 737 | updated(); |
731 | } | 738 | } |
732 | 739 | ||
733 | void Incidence::removeAlarm(Alarm *alarm) | 740 | void Incidence::removeAlarm(Alarm *alarm) |
734 | { | 741 | { |
735 | mAlarms.removeRef(alarm); | 742 | mAlarms.removeRef(alarm); |
736 | updated(); | 743 | updated(); |
737 | } | 744 | } |
738 | 745 | ||
739 | void Incidence::clearAlarms() | 746 | void Incidence::clearAlarms() |
740 | { | 747 | { |
741 | mAlarms.clear(); | 748 | mAlarms.clear(); |
742 | updated(); | 749 | updated(); |
743 | } | 750 | } |
744 | 751 | ||
745 | bool Incidence::isAlarmEnabled() const | 752 | bool Incidence::isAlarmEnabled() const |
746 | { | 753 | { |
747 | Alarm* alarm; | 754 | Alarm* alarm; |
748 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 755 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
749 | if (alarm->enabled()) | 756 | if (alarm->enabled()) |
750 | return true; | 757 | return true; |
751 | } | 758 | } |
752 | return false; | 759 | return false; |
753 | } | 760 | } |
754 | #include <stdlib.h> | 761 | #include <stdlib.h> |
755 | Recurrence *Incidence::recurrence() | 762 | Recurrence *Incidence::recurrence() |
756 | { | 763 | { |
757 | if ( ! mRecurrence ) { | 764 | if ( ! mRecurrence ) { |
758 | mRecurrence = new Recurrence(this); | 765 | mRecurrence = new Recurrence(this); |
759 | mRecurrence->setRecurStart( dtStart() ); | 766 | mRecurrence->setRecurStart( dtStart() ); |
767 | mRecurrence->setRecurReadOnly( isReadOnly()); | ||
760 | //qDebug("creating new recurence "); | 768 | //qDebug("creating new recurence "); |
761 | //abort(); | 769 | //abort(); |
762 | } | 770 | } |
763 | return mRecurrence; | 771 | return mRecurrence; |
764 | } | 772 | } |
765 | void Incidence::setRecurrence( Recurrence * r) | 773 | void Incidence::setRecurrence( Recurrence * r) |
766 | { | 774 | { |
767 | if ( mRecurrence ) | 775 | if ( mRecurrence ) |
768 | delete mRecurrence; | 776 | delete mRecurrence; |
769 | mRecurrence = r; | 777 | mRecurrence = r; |
770 | } | 778 | } |
771 | 779 | ||
772 | void Incidence::setLocation(const QString &location) | 780 | void Incidence::setLocation(const QString &location) |
773 | { | 781 | { |
774 | if (mReadOnly) return; | 782 | if (mReadOnly) return; |
775 | mLocation = location; | 783 | mLocation = location; |
776 | updated(); | 784 | updated(); |
777 | } | 785 | } |
778 | 786 | ||
779 | QString Incidence::location() const | 787 | QString Incidence::location() const |
780 | { | 788 | { |
781 | return mLocation; | 789 | return mLocation; |
782 | } | 790 | } |
783 | QString Incidence::recurrenceText() const | 791 | QString Incidence::recurrenceText() const |
784 | { | 792 | { |
785 | if ( mRecurrence ) return mRecurrence->recurrenceText(); | 793 | if ( mRecurrence ) return mRecurrence->recurrenceText(); |
786 | return i18n("No"); | 794 | return i18n("No"); |
787 | } | 795 | } |
788 | 796 | ||
789 | ushort Incidence::doesRecur() const | 797 | ushort Incidence::doesRecur() const |
790 | { | 798 | { |
791 | if ( mRecurrence ) return mRecurrence->doesRecur(); | 799 | if ( mRecurrence ) return mRecurrence->doesRecur(); |