summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index f9e1e9e..dbc159c 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -34,16 +34,17 @@ Incidence::Incidence() :
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 35{
36 mRecurrence = new Recurrence(this); 36 mRecurrence = 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} 43}
43 44
44Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 45Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
45{ 46{
46// TODO: reenable attributes currently commented out. 47// TODO: reenable attributes currently commented out.
47 mRevision = i.mRevision; 48 mRevision = i.mRevision;
48 mCreated = i.mCreated; 49 mCreated = i.mCreated;
49 mDescription = i.mDescription; 50 mDescription = i.mDescription;
@@ -66,32 +67,53 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
66 while( (a = it.current()) ) { 67 while( (a = it.current()) ) {
67 Alarm *b = new Alarm( *a ); 68 Alarm *b = new Alarm( *a );
68 b->setParent( this ); 69 b->setParent( this );
69 mAlarms.append( b ); 70 mAlarms.append( b );
70 71
71 ++it; 72 ++it;
72 } 73 }
73 mAlarms.setAutoDelete(true); 74 mAlarms.setAutoDelete(true);
74 75 mHasRecurrenceID = i.mHasRecurrenceID;
76 mRecurrenceID = i.mRecurrenceID;
75 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 77 mRecurrence = new Recurrence( *(i.mRecurrence), this );
76} 78}
77 79
78Incidence::~Incidence() 80Incidence::~Incidence()
79{ 81{
80 82
81 Incidence *ev; 83 Incidence *ev;
82 QPtrList<Incidence> Relations = relations(); 84 QPtrList<Incidence> Relations = relations();
83 for (ev=Relations.first();ev;ev=Relations.next()) { 85 for (ev=Relations.first();ev;ev=Relations.next()) {
84 if (ev->relatedTo() == this) ev->setRelatedTo(0); 86 if (ev->relatedTo() == this) ev->setRelatedTo(0);
85 } 87 }
86 if (relatedTo()) relatedTo()->removeRelation(this); 88 if (relatedTo()) relatedTo()->removeRelation(this);
87 delete mRecurrence; 89 delete mRecurrence;
88 90
89} 91}
92bool Incidence::hasRecurrenceID() const
93{
94 return mHasRecurrenceID;
95}
96
97void Incidence::setHasRecurrenceID( bool b )
98{
99 mHasRecurrenceID = b;
100}
101
102void Incidence::setRecurrenceID(QDateTime d)
103{
104 mRecurrenceID = d;
105 mHasRecurrenceID = true;
106 updated();
107}
108QDateTime Incidence::recurrenceID () const
109{
110 return mRecurrenceID;
111}
90 112
91bool Incidence::cancelled() const 113bool Incidence::cancelled() const
92{ 114{
93 return mCancelled; 115 return mCancelled;
94} 116}
95void Incidence::setCancelled( bool b ) 117void Incidence::setCancelled( bool b )
96{ 118{
97 mCancelled = b; 119 mCancelled = b;
@@ -138,16 +160,26 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
138 continue; 160 continue;
139 } 161 }
140 else { 162 else {
141 return false; 163 return false;
142 } 164 }
143 } 165 }
144#endif 166#endif
145 167
168 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
169 if ( i1.hasRecurrenceID() ) {
170 if ( i1.recurrenceID() != i2.recurrenceID() )
171 return false;
172 }
173
174 } else {
175 return false;
176 }
177
146 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 178 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
147 return false; 179 return false;
148 if ( i1.hasStartDate() == i2.hasStartDate() ) { 180 if ( i1.hasStartDate() == i2.hasStartDate() ) {
149 if ( i1.hasStartDate() ) { 181 if ( i1.hasStartDate() ) {
150 if ( i1.dtStart() != i2.dtStart() ) 182 if ( i1.dtStart() != i2.dtStart() )
151 return false; 183 return false;
152 } 184 }
153 } else { 185 } else {
@@ -165,16 +197,17 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
165 // no need to compare mRelatedTo 197 // no need to compare mRelatedTo
166 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 198 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
167 // i1.relations() == i2.relations() && 199 // i1.relations() == i2.relations() &&
168 i1.exDates() == i2.exDates() && 200 i1.exDates() == i2.exDates() &&
169 i1.attachments() == i2.attachments() && 201 i1.attachments() == i2.attachments() &&
170 i1.resources() == i2.resources() && 202 i1.resources() == i2.resources() &&
171 i1.secrecy() == i2.secrecy() && 203 i1.secrecy() == i2.secrecy() &&
172 i1.priority() == i2.priority() && 204 i1.priority() == i2.priority() &&
205 i1.cancelled() == i2.cancelled() &&
173 stringCompare( i1.location(), i2.location() ); 206 stringCompare( i1.location(), i2.location() );
174} 207}
175 208
176Incidence* Incidence::recreateCloneException( QDate d ) 209Incidence* Incidence::recreateCloneException( QDate d )
177{ 210{
178 Incidence* newInc = clone(); 211 Incidence* newInc = clone();
179 newInc->recreate(); 212 newInc->recreate();
180 if ( doesRecur() ) { 213 if ( doesRecur() ) {