-rw-r--r-- | libkcal/calendar.cpp | 10 | ||||
-rw-r--r-- | libkcal/calendar.h | 5 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 14 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
4 files changed, 27 insertions, 3 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 406cd48..ed39ddb 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -322,33 +322,41 @@ QPtrList<Event> Calendar::events( const QDateTime &qdt ) | |||
322 | } | 322 | } |
323 | 323 | ||
324 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 324 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
325 | bool inclusive) | 325 | bool inclusive) |
326 | { | 326 | { |
327 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 327 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
328 | mFilter->apply(&el); | 328 | mFilter->apply(&el); |
329 | return el; | 329 | return el; |
330 | } | 330 | } |
331 | 331 | ||
332 | QPtrList<Event> Calendar::events() | 332 | QPtrList<Event> Calendar::events() |
333 | { | 333 | { |
334 | QPtrList<Event> el = rawEvents(); | 334 | QPtrList<Event> el = rawEvents(); |
335 | mFilter->apply(&el); | 335 | mFilter->apply(&el); |
336 | return el; | 336 | return el; |
337 | } | 337 | } |
338 | 338 | void Calendar::addIncidenceBranch(Incidence *i) | |
339 | { | ||
340 | addIncidence( i ); | ||
341 | Incidence * inc; | ||
342 | QPtrList<Incidence> Relations = i->relations(); | ||
343 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
344 | addIncidenceBranch( inc ); | ||
345 | } | ||
346 | } | ||
339 | 347 | ||
340 | bool Calendar::addIncidence(Incidence *i) | 348 | bool Calendar::addIncidence(Incidence *i) |
341 | { | 349 | { |
342 | Incidence::AddVisitor<Calendar> v(this); | 350 | Incidence::AddVisitor<Calendar> v(this); |
343 | 351 | ||
344 | return i->accept(v); | 352 | return i->accept(v); |
345 | } | 353 | } |
346 | void Calendar::deleteIncidence(Incidence *in) | 354 | void Calendar::deleteIncidence(Incidence *in) |
347 | { | 355 | { |
348 | if ( in->type() == "Event" ) | 356 | if ( in->type() == "Event" ) |
349 | deleteEvent( (Event*) in ); | 357 | deleteEvent( (Event*) in ); |
350 | else if ( in->type() =="Todo" ) | 358 | else if ( in->type() =="Todo" ) |
351 | deleteTodo( (Todo*) in); | 359 | deleteTodo( (Todo*) in); |
352 | else if ( in->type() =="Journal" ) | 360 | else if ( in->type() =="Journal" ) |
353 | deleteJournal( (Journal*) in ); | 361 | deleteJournal( (Journal*) in ); |
354 | } | 362 | } |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2f2c3aa..ab40970 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -126,33 +126,36 @@ public: | |||
126 | */ | 126 | */ |
127 | QString timeZoneId() const; | 127 | QString timeZoneId() const; |
128 | /** | 128 | /** |
129 | Use local time, not UTC or a time zone. | 129 | Use local time, not UTC or a time zone. |
130 | */ | 130 | */ |
131 | void setLocalTime(); | 131 | void setLocalTime(); |
132 | /** | 132 | /** |
133 | Return whether local time is being used. | 133 | Return whether local time is being used. |
134 | */ | 134 | */ |
135 | bool isLocalTime() const; | 135 | bool isLocalTime() const; |
136 | 136 | ||
137 | /** | 137 | /** |
138 | Add an incidence to calendar. | 138 | Add an incidence to calendar. |
139 | 139 | ||
140 | @return true on success, false on error. | 140 | @return true on success, false on error. |
141 | */ | 141 | */ |
142 | virtual bool addIncidence( Incidence * ); | 142 | virtual bool addIncidence( Incidence * ); |
143 | |||
144 | // Adds an incidence and all relatedto incidences to the cal | ||
145 | void addIncidenceBranch( Incidence * ); | ||
143 | /** | 146 | /** |
144 | Return filtered list of all incidences of this calendar. | 147 | Return filtered list of all incidences of this calendar. |
145 | */ | 148 | */ |
146 | virtual QPtrList<Incidence> incidences(); | 149 | virtual QPtrList<Incidence> incidences(); |
147 | 150 | ||
148 | /** | 151 | /** |
149 | Return unfiltered list of all incidences of this calendar. | 152 | Return unfiltered list of all incidences of this calendar. |
150 | */ | 153 | */ |
151 | virtual QPtrList<Incidence> rawIncidences(); | 154 | virtual QPtrList<Incidence> rawIncidences(); |
152 | 155 | ||
153 | /** | 156 | /** |
154 | Adds a Event to this calendar object. | 157 | Adds a Event to this calendar object. |
155 | @param anEvent a pointer to the event to add | 158 | @param anEvent a pointer to the event to add |
156 | 159 | ||
157 | @return true on success, false on error. | 160 | @return true on success, false on error. |
158 | */ | 161 | */ |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 6bca12c..78fa24f 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -250,33 +250,45 @@ Incidence* Incidence::recreateCloneException( QDate d ) | |||
250 | } | 250 | } |
251 | newInc->setExDates( DateList () ); | 251 | newInc->setExDates( DateList () ); |
252 | } | 252 | } |
253 | return newInc; | 253 | return newInc; |
254 | } | 254 | } |
255 | 255 | ||
256 | void Incidence::recreate() | 256 | void Incidence::recreate() |
257 | { | 257 | { |
258 | setCreated(QDateTime::currentDateTime()); | 258 | setCreated(QDateTime::currentDateTime()); |
259 | 259 | ||
260 | setUid(CalFormat::createUniqueId()); | 260 | setUid(CalFormat::createUniqueId()); |
261 | 261 | ||
262 | setRevision(0); | 262 | setRevision(0); |
263 | setIDStr( ":" ); | 263 | setIDStr( ":" ); |
264 | setLastModified(QDateTime::currentDateTime()); | 264 | setLastModified(QDateTime::currentDateTime()); |
265 | } | 265 | } |
266 | 266 | void Incidence::cloneRelations( Incidence * newInc ) | |
267 | { | ||
268 | // newInc is already a clone of this incidence | ||
269 | Incidence * inc; | ||
270 | Incidence * cloneInc; | ||
271 | QPtrList<Incidence> Relations = relations(); | ||
272 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
273 | cloneInc = inc->clone(); | ||
274 | cloneInc->recreate(); | ||
275 | cloneInc->setRelatedTo( newInc ); | ||
276 | inc->cloneRelations( cloneInc ); | ||
277 | } | ||
278 | } | ||
267 | void Incidence::setReadOnly( bool readOnly ) | 279 | void Incidence::setReadOnly( bool readOnly ) |
268 | { | 280 | { |
269 | IncidenceBase::setReadOnly( readOnly ); | 281 | IncidenceBase::setReadOnly( readOnly ); |
270 | recurrence()->setRecurReadOnly( readOnly); | 282 | recurrence()->setRecurReadOnly( readOnly); |
271 | } | 283 | } |
272 | 284 | ||
273 | void Incidence::setCreated(QDateTime created) | 285 | void Incidence::setCreated(QDateTime created) |
274 | { | 286 | { |
275 | if (mReadOnly) return; | 287 | if (mReadOnly) return; |
276 | mCreated = getEvenTime(created); | 288 | mCreated = getEvenTime(created); |
277 | } | 289 | } |
278 | 290 | ||
279 | QDateTime Incidence::created() const | 291 | QDateTime Incidence::created() const |
280 | { | 292 | { |
281 | return mCreated; | 293 | return mCreated; |
282 | } | 294 | } |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index f8da342..60070a2 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -99,32 +99,33 @@ class Incidence : public IncidenceBase | |||
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | virtual void cloneRelations( Incidence * ); | ||
115 | 116 | ||
116 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; |
117 | void setReadOnly( bool ); | 118 | void setReadOnly( bool ); |
118 | 119 | ||
119 | /** | 120 | /** |
120 | Recreate event. The event is made a new unique event, but already stored | 121 | Recreate event. The event is made a new unique event, but already stored |
121 | event information is preserved. Sets uniquie id, creation date, last | 122 | event information is preserved. Sets uniquie id, creation date, last |
122 | modification date and revision number. | 123 | modification date and revision number. |
123 | */ | 124 | */ |
124 | void recreate(); | 125 | void recreate(); |
125 | Incidence* recreateCloneException(QDate); | 126 | Incidence* recreateCloneException(QDate); |
126 | 127 | ||
127 | /** set creation date */ | 128 | /** set creation date */ |
128 | void setCreated(QDateTime); | 129 | void setCreated(QDateTime); |
129 | /** return time and date of creation. */ | 130 | /** return time and date of creation. */ |
130 | QDateTime created() const; | 131 | QDateTime created() const; |