-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 | |||
@@ -242,193 +242,201 @@ CalFilter *Calendar::filter() | |||
242 | } | 242 | } |
243 | 243 | ||
244 | QPtrList<Incidence> Calendar::incidences() | 244 | QPtrList<Incidence> Calendar::incidences() |
245 | { | 245 | { |
246 | QPtrList<Incidence> incidences; | 246 | QPtrList<Incidence> incidences; |
247 | 247 | ||
248 | Incidence *i; | 248 | Incidence *i; |
249 | 249 | ||
250 | QPtrList<Event> e = events(); | 250 | QPtrList<Event> e = events(); |
251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 251 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
252 | 252 | ||
253 | QPtrList<Todo> t = todos(); | 253 | QPtrList<Todo> t = todos(); |
254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 254 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
255 | 255 | ||
256 | QPtrList<Journal> j = journals(); | 256 | QPtrList<Journal> j = journals(); |
257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 257 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
258 | 258 | ||
259 | return incidences; | 259 | return incidences; |
260 | } | 260 | } |
261 | 261 | ||
262 | void Calendar::resetPilotStat(int id ) | 262 | void Calendar::resetPilotStat(int id ) |
263 | { | 263 | { |
264 | QPtrList<Incidence> incidences; | 264 | QPtrList<Incidence> incidences; |
265 | 265 | ||
266 | Incidence *i; | 266 | Incidence *i; |
267 | 267 | ||
268 | QPtrList<Event> e = rawEvents(); | 268 | QPtrList<Event> e = rawEvents(); |
269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 269 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
270 | 270 | ||
271 | QPtrList<Todo> t = rawTodos(); | 271 | QPtrList<Todo> t = rawTodos(); |
272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 272 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
273 | 273 | ||
274 | QPtrList<Journal> j = journals(); | 274 | QPtrList<Journal> j = journals(); |
275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 275 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
276 | } | 276 | } |
277 | void Calendar::resetTempSyncStat() | 277 | void Calendar::resetTempSyncStat() |
278 | { | 278 | { |
279 | QPtrList<Incidence> incidences; | 279 | QPtrList<Incidence> incidences; |
280 | 280 | ||
281 | Incidence *i; | 281 | Incidence *i; |
282 | 282 | ||
283 | QPtrList<Event> e = rawEvents(); | 283 | QPtrList<Event> e = rawEvents(); |
284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 284 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
285 | 285 | ||
286 | QPtrList<Todo> t = rawTodos(); | 286 | QPtrList<Todo> t = rawTodos(); |
287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 287 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
288 | 288 | ||
289 | QPtrList<Journal> j = journals(); | 289 | QPtrList<Journal> j = journals(); |
290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 290 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
291 | } | 291 | } |
292 | QPtrList<Incidence> Calendar::rawIncidences() | 292 | QPtrList<Incidence> Calendar::rawIncidences() |
293 | { | 293 | { |
294 | QPtrList<Incidence> incidences; | 294 | QPtrList<Incidence> incidences; |
295 | 295 | ||
296 | Incidence *i; | 296 | Incidence *i; |
297 | 297 | ||
298 | QPtrList<Event> e = rawEvents(); | 298 | QPtrList<Event> e = rawEvents(); |
299 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 299 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
300 | 300 | ||
301 | QPtrList<Todo> t = rawTodos(); | 301 | QPtrList<Todo> t = rawTodos(); |
302 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 302 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
303 | 303 | ||
304 | QPtrList<Journal> j = journals(); | 304 | QPtrList<Journal> j = journals(); |
305 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 305 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
306 | 306 | ||
307 | return incidences; | 307 | return incidences; |
308 | } | 308 | } |
309 | 309 | ||
310 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 310 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
311 | { | 311 | { |
312 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 312 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
313 | mFilter->apply(&el); | 313 | mFilter->apply(&el); |
314 | return el; | 314 | return el; |
315 | } | 315 | } |
316 | 316 | ||
317 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 317 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
318 | { | 318 | { |
319 | QPtrList<Event> el = rawEventsForDate(qdt); | 319 | QPtrList<Event> el = rawEventsForDate(qdt); |
320 | mFilter->apply(&el); | 320 | mFilter->apply(&el); |
321 | return el; | 321 | return el; |
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 | } |
355 | 363 | ||
356 | Incidence* Calendar::incidence( const QString& uid ) | 364 | Incidence* Calendar::incidence( const QString& uid ) |
357 | { | 365 | { |
358 | Incidence* i; | 366 | Incidence* i; |
359 | 367 | ||
360 | if( (i = todo( uid )) != 0 ) | 368 | if( (i = todo( uid )) != 0 ) |
361 | return i; | 369 | return i; |
362 | if( (i = event( uid )) != 0 ) | 370 | if( (i = event( uid )) != 0 ) |
363 | return i; | 371 | return i; |
364 | if( (i = journal( uid )) != 0 ) | 372 | if( (i = journal( uid )) != 0 ) |
365 | return i; | 373 | return i; |
366 | 374 | ||
367 | return 0; | 375 | return 0; |
368 | } | 376 | } |
369 | 377 | ||
370 | QPtrList<Todo> Calendar::todos() | 378 | QPtrList<Todo> Calendar::todos() |
371 | { | 379 | { |
372 | QPtrList<Todo> tl = rawTodos(); | 380 | QPtrList<Todo> tl = rawTodos(); |
373 | mFilter->apply( &tl ); | 381 | mFilter->apply( &tl ); |
374 | return tl; | 382 | return tl; |
375 | } | 383 | } |
376 | 384 | ||
377 | // When this is called, the todo have already been added to the calendar. | 385 | // When this is called, the todo have already been added to the calendar. |
378 | // This method is only about linking related todos | 386 | // This method is only about linking related todos |
379 | void Calendar::setupRelations( Incidence *incidence ) | 387 | void Calendar::setupRelations( Incidence *incidence ) |
380 | { | 388 | { |
381 | QString uid = incidence->uid(); | 389 | QString uid = incidence->uid(); |
382 | //qDebug("Calendar::setupRelations "); | 390 | //qDebug("Calendar::setupRelations "); |
383 | // First, go over the list of orphans and see if this is their parent | 391 | // First, go over the list of orphans and see if this is their parent |
384 | while( Incidence* i = mOrphans[ uid ] ) { | 392 | while( Incidence* i = mOrphans[ uid ] ) { |
385 | mOrphans.remove( uid ); | 393 | mOrphans.remove( uid ); |
386 | i->setRelatedTo( incidence ); | 394 | i->setRelatedTo( incidence ); |
387 | incidence->addRelation( i ); | 395 | incidence->addRelation( i ); |
388 | mOrphanUids.remove( i->uid() ); | 396 | mOrphanUids.remove( i->uid() ); |
389 | } | 397 | } |
390 | 398 | ||
391 | // Now see about this incidences parent | 399 | // Now see about this incidences parent |
392 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 400 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
393 | // This incidence has a uid it is related to, but is not registered to it yet | 401 | // This incidence has a uid it is related to, but is not registered to it yet |
394 | // Try to find it | 402 | // Try to find it |
395 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 403 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
396 | if( parent ) { | 404 | if( parent ) { |
397 | // Found it | 405 | // Found it |
398 | incidence->setRelatedTo( parent ); | 406 | incidence->setRelatedTo( parent ); |
399 | parent->addRelation( incidence ); | 407 | parent->addRelation( incidence ); |
400 | } else { | 408 | } else { |
401 | // Not found, put this in the mOrphans list | 409 | // Not found, put this in the mOrphans list |
402 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 410 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
403 | mOrphanUids.insert( incidence->uid(), incidence ); | 411 | mOrphanUids.insert( incidence->uid(), incidence ); |
404 | } | 412 | } |
405 | } | 413 | } |
406 | } | 414 | } |
407 | 415 | ||
408 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 416 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
409 | void Calendar::removeRelations( Incidence *incidence ) | 417 | void Calendar::removeRelations( Incidence *incidence ) |
410 | { | 418 | { |
411 | // qDebug("Calendar::removeRelations "); | 419 | // qDebug("Calendar::removeRelations "); |
412 | QString uid = incidence->uid(); | 420 | QString uid = incidence->uid(); |
413 | 421 | ||
414 | QPtrList<Incidence> relations = incidence->relations(); | 422 | QPtrList<Incidence> relations = incidence->relations(); |
415 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 423 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
416 | if( !mOrphanUids.find( i->uid() ) ) { | 424 | if( !mOrphanUids.find( i->uid() ) ) { |
417 | mOrphans.insert( uid, i ); | 425 | mOrphans.insert( uid, i ); |
418 | mOrphanUids.insert( i->uid(), i ); | 426 | mOrphanUids.insert( i->uid(), i ); |
419 | i->setRelatedTo( 0 ); | 427 | i->setRelatedTo( 0 ); |
420 | i->setRelatedToUid( uid ); | 428 | i->setRelatedToUid( uid ); |
421 | } | 429 | } |
422 | 430 | ||
423 | // If this incidence is related to something else, tell that about it | 431 | // If this incidence is related to something else, tell that about it |
424 | if( incidence->relatedTo() ) | 432 | if( incidence->relatedTo() ) |
425 | incidence->relatedTo()->removeRelation( incidence ); | 433 | incidence->relatedTo()->removeRelation( incidence ); |
426 | 434 | ||
427 | // Remove this one from the orphans list | 435 | // Remove this one from the orphans list |
428 | if( mOrphanUids.remove( uid ) ) | 436 | if( mOrphanUids.remove( uid ) ) |
429 | // This incidence is located in the orphans list - it should be removed | 437 | // This incidence is located in the orphans list - it should be removed |
430 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 438 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
431 | // Removing wasn't that easy | 439 | // Removing wasn't that easy |
432 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 440 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
433 | if( it.current()->uid() == uid ) { | 441 | if( it.current()->uid() == uid ) { |
434 | mOrphans.remove( it.currentKey() ); | 442 | mOrphans.remove( it.currentKey() ); |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 2f2c3aa..ab40970 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -46,193 +46,196 @@ namespace KCal { | |||
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | Incidence * undoIncidence() { return mUndoIncidence; }; | 68 | Incidence * undoIncidence() { return mUndoIncidence; }; |
69 | bool undoDeleteIncidence(); | 69 | bool undoDeleteIncidence(); |
70 | void deleteIncidence(Incidence *in); | 70 | void deleteIncidence(Incidence *in); |
71 | void resetTempSyncStat(); | 71 | void resetTempSyncStat(); |
72 | void resetPilotStat(int id); | 72 | void resetPilotStat(int id); |
73 | /** | 73 | /** |
74 | Clears out the current calendar, freeing all used memory etc. | 74 | Clears out the current calendar, freeing all used memory etc. |
75 | */ | 75 | */ |
76 | virtual void close() = 0; | 76 | virtual void close() = 0; |
77 | 77 | ||
78 | /** | 78 | /** |
79 | Sync changes in memory to persistant storage. | 79 | Sync changes in memory to persistant storage. |
80 | */ | 80 | */ |
81 | virtual void save() = 0; | 81 | virtual void save() = 0; |
82 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 82 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
83 | virtual void removeSyncInfo( QString syncProfile) = 0; | 83 | virtual void removeSyncInfo( QString syncProfile) = 0; |
84 | virtual bool isSaving() { return false; } | 84 | virtual bool isSaving() { return false; } |
85 | 85 | ||
86 | /** | 86 | /** |
87 | Return the owner of the calendar's full name. | 87 | Return the owner of the calendar's full name. |
88 | */ | 88 | */ |
89 | const QString &getOwner() const; | 89 | const QString &getOwner() const; |
90 | /** | 90 | /** |
91 | Set the owner of the calendar. Should be owner's full name. | 91 | Set the owner of the calendar. Should be owner's full name. |
92 | */ | 92 | */ |
93 | void setOwner( const QString &os ); | 93 | void setOwner( const QString &os ); |
94 | /** | 94 | /** |
95 | Return the email address of the calendar owner. | 95 | Return the email address of the calendar owner. |
96 | */ | 96 | */ |
97 | const QString &getEmail(); | 97 | const QString &getEmail(); |
98 | /** | 98 | /** |
99 | Set the email address of the calendar owner. | 99 | Set the email address of the calendar owner. |
100 | */ | 100 | */ |
101 | void setEmail( const QString & ); | 101 | void setEmail( const QString & ); |
102 | 102 | ||
103 | /** | 103 | /** |
104 | Set time zone from a timezone string (e.g. -2:00) | 104 | Set time zone from a timezone string (e.g. -2:00) |
105 | */ | 105 | */ |
106 | void setTimeZone( const QString &tz ); | 106 | void setTimeZone( const QString &tz ); |
107 | /** | 107 | /** |
108 | Set time zone from a minutes value (e.g. -60) | 108 | Set time zone from a minutes value (e.g. -60) |
109 | */ | 109 | */ |
110 | void setTimeZone( int tz ); | 110 | void setTimeZone( int tz ); |
111 | /** | 111 | /** |
112 | Return time zone as offest in minutes. | 112 | Return time zone as offest in minutes. |
113 | */ | 113 | */ |
114 | int getTimeZone() const; | 114 | int getTimeZone() const; |
115 | /** | 115 | /** |
116 | Compute an ISO 8601 format string from the time zone. | 116 | Compute an ISO 8601 format string from the time zone. |
117 | */ | 117 | */ |
118 | QString getTimeZoneStr() const; | 118 | QString getTimeZoneStr() const; |
119 | /** | 119 | /** |
120 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 120 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
121 | values). | 121 | values). |
122 | */ | 122 | */ |
123 | void setTimeZoneId( const QString & ); | 123 | void setTimeZoneId( const QString & ); |
124 | /** | 124 | /** |
125 | Return time zone id. | 125 | Return time zone id. |
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 | */ |
159 | virtual bool addEventNoDup( Event *event ) = 0; | 162 | virtual bool addEventNoDup( Event *event ) = 0; |
160 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 163 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
161 | virtual bool addEvent( Event *anEvent ) = 0; | 164 | virtual bool addEvent( Event *anEvent ) = 0; |
162 | /** | 165 | /** |
163 | Delete event from calendar. | 166 | Delete event from calendar. |
164 | */ | 167 | */ |
165 | virtual void deleteEvent( Event * ) = 0; | 168 | virtual void deleteEvent( Event * ) = 0; |
166 | /** | 169 | /** |
167 | Retrieves an event on the basis of the unique string ID. | 170 | Retrieves an event on the basis of the unique string ID. |
168 | */ | 171 | */ |
169 | virtual Event *event( const QString &UniqueStr ) = 0; | 172 | virtual Event *event( const QString &UniqueStr ) = 0; |
170 | virtual Event *event( QString, QString ) = 0; | 173 | virtual Event *event( QString, QString ) = 0; |
171 | /** | 174 | /** |
172 | Builds and then returns a list of all events that match for the | 175 | Builds and then returns a list of all events that match for the |
173 | date specified. useful for dayView, etc. etc. | 176 | date specified. useful for dayView, etc. etc. |
174 | The calendar filter is applied. | 177 | The calendar filter is applied. |
175 | */ | 178 | */ |
176 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 179 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
177 | /** | 180 | /** |
178 | Get events, which occur on the given date. | 181 | Get events, which occur on the given date. |
179 | The calendar filter is applied. | 182 | The calendar filter is applied. |
180 | */ | 183 | */ |
181 | QPtrList<Event> events( const QDateTime &qdt ); | 184 | QPtrList<Event> events( const QDateTime &qdt ); |
182 | /** | 185 | /** |
183 | Get events in a range of dates. If inclusive is set to true, only events | 186 | Get events in a range of dates. If inclusive is set to true, only events |
184 | are returned, which are completely included in the range. | 187 | are returned, which are completely included in the range. |
185 | The calendar filter is applied. | 188 | The calendar filter is applied. |
186 | */ | 189 | */ |
187 | QPtrList<Event> events( const QDate &start, const QDate &end, | 190 | QPtrList<Event> events( const QDate &start, const QDate &end, |
188 | bool inclusive = false); | 191 | bool inclusive = false); |
189 | /** | 192 | /** |
190 | Return filtered list of all events in calendar. | 193 | Return filtered list of all events in calendar. |
191 | */ | 194 | */ |
192 | virtual QPtrList<Event> events(); | 195 | virtual QPtrList<Event> events(); |
193 | /** | 196 | /** |
194 | Return unfiltered list of all events in calendar. | 197 | Return unfiltered list of all events in calendar. |
195 | */ | 198 | */ |
196 | virtual QPtrList<Event> rawEvents() = 0; | 199 | virtual QPtrList<Event> rawEvents() = 0; |
197 | 200 | ||
198 | /** | 201 | /** |
199 | Add a todo to the todolist. | 202 | Add a todo to the todolist. |
200 | 203 | ||
201 | @return true on success, false on error. | 204 | @return true on success, false on error. |
202 | */ | 205 | */ |
203 | virtual bool addTodo( Todo *todo ) = 0; | 206 | virtual bool addTodo( Todo *todo ) = 0; |
204 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 207 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
205 | /** | 208 | /** |
206 | Remove a todo from the todolist. | 209 | Remove a todo from the todolist. |
207 | */ | 210 | */ |
208 | virtual void deleteTodo( Todo * ) = 0; | 211 | virtual void deleteTodo( Todo * ) = 0; |
209 | virtual void deleteJournal( Journal * ) = 0; | 212 | virtual void deleteJournal( Journal * ) = 0; |
210 | /** | 213 | /** |
211 | Return filterd list of todos. | 214 | Return filterd list of todos. |
212 | */ | 215 | */ |
213 | virtual QPtrList<Todo> todos(); | 216 | virtual QPtrList<Todo> todos(); |
214 | /** | 217 | /** |
215 | Searches todolist for an event with this unique string identifier, | 218 | Searches todolist for an event with this unique string identifier, |
216 | returns a pointer or null. | 219 | returns a pointer or null. |
217 | */ | 220 | */ |
218 | virtual Todo *todo( const QString &uid ) = 0; | 221 | virtual Todo *todo( const QString &uid ) = 0; |
219 | virtual Todo *todo( QString, QString ) = 0; | 222 | virtual Todo *todo( QString, QString ) = 0; |
220 | /** | 223 | /** |
221 | Returns list of todos due on the specified date. | 224 | Returns list of todos due on the specified date. |
222 | */ | 225 | */ |
223 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 226 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
224 | /** | 227 | /** |
225 | Return unfiltered list of todos. | 228 | Return unfiltered list of todos. |
226 | */ | 229 | */ |
227 | virtual QPtrList<Todo> rawTodos() = 0; | 230 | virtual QPtrList<Todo> rawTodos() = 0; |
228 | 231 | ||
229 | /** | 232 | /** |
230 | Add a Journal entry to calendar. | 233 | Add a Journal entry to calendar. |
231 | 234 | ||
232 | @return true on success, false on error. | 235 | @return true on success, false on error. |
233 | */ | 236 | */ |
234 | virtual bool addJournal( Journal * ) = 0; | 237 | virtual bool addJournal( Journal * ) = 0; |
235 | /** | 238 | /** |
236 | Return Journal for given date. | 239 | Return Journal for given date. |
237 | */ | 240 | */ |
238 | virtual Journal *journal( const QDate & ) = 0; | 241 | virtual Journal *journal( const QDate & ) = 0; |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 6bca12c..78fa24f 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -170,193 +170,205 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | |||
170 | } | 170 | } |
171 | if ( i1.alarms().count() > 0 ) { | 171 | if ( i1.alarms().count() > 0 ) { |
172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 172 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
173 | { | 173 | { |
174 | qDebug("alarm not equal "); | 174 | qDebug("alarm not equal "); |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | } | 177 | } |
178 | #if 0 | 178 | #if 0 |
179 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 179 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
180 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 180 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 181 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
182 | if( *a1.current() == *a2.current() ) { | 182 | if( *a1.current() == *a2.current() ) { |
183 | continue; | 183 | continue; |
184 | } | 184 | } |
185 | else { | 185 | else { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | } | 188 | } |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 191 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
192 | if ( i1.hasRecurrenceID() ) { | 192 | if ( i1.hasRecurrenceID() ) { |
193 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 193 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
194 | return false; | 194 | return false; |
195 | } | 195 | } |
196 | 196 | ||
197 | } else { | 197 | } else { |
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | 200 | ||
201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 201 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
202 | return false; | 202 | return false; |
203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 203 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
204 | if ( i1.hasStartDate() ) { | 204 | if ( i1.hasStartDate() ) { |
205 | if ( i1.dtStart() != i2.dtStart() ) | 205 | if ( i1.dtStart() != i2.dtStart() ) |
206 | return false; | 206 | return false; |
207 | } | 207 | } |
208 | } else { | 208 | } else { |
209 | return false; | 209 | return false; |
210 | } | 210 | } |
211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 211 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
212 | qDebug("recurrence is NOT equal "); | 212 | qDebug("recurrence is NOT equal "); |
213 | return false; | 213 | return false; |
214 | } | 214 | } |
215 | return | 215 | return |
216 | // i1.created() == i2.created() && | 216 | // i1.created() == i2.created() && |
217 | stringCompare( i1.description(), i2.description() ) && | 217 | stringCompare( i1.description(), i2.description() ) && |
218 | stringCompare( i1.summary(), i2.summary() ) && | 218 | stringCompare( i1.summary(), i2.summary() ) && |
219 | i1.categories() == i2.categories() && | 219 | i1.categories() == i2.categories() && |
220 | // no need to compare mRelatedTo | 220 | // no need to compare mRelatedTo |
221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 221 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
222 | // i1.relations() == i2.relations() && | 222 | // i1.relations() == i2.relations() && |
223 | i1.exDates() == i2.exDates() && | 223 | i1.exDates() == i2.exDates() && |
224 | i1.attachments() == i2.attachments() && | 224 | i1.attachments() == i2.attachments() && |
225 | i1.resources() == i2.resources() && | 225 | i1.resources() == i2.resources() && |
226 | i1.secrecy() == i2.secrecy() && | 226 | i1.secrecy() == i2.secrecy() && |
227 | i1.priority() == i2.priority() && | 227 | i1.priority() == i2.priority() && |
228 | i1.cancelled() == i2.cancelled() && | 228 | i1.cancelled() == i2.cancelled() && |
229 | stringCompare( i1.location(), i2.location() ); | 229 | stringCompare( i1.location(), i2.location() ); |
230 | } | 230 | } |
231 | 231 | ||
232 | Incidence* Incidence::recreateCloneException( QDate d ) | 232 | Incidence* Incidence::recreateCloneException( QDate d ) |
233 | { | 233 | { |
234 | Incidence* newInc = clone(); | 234 | Incidence* newInc = clone(); |
235 | newInc->recreate(); | 235 | newInc->recreate(); |
236 | if ( doesRecur() ) { | 236 | if ( doesRecur() ) { |
237 | addExDate( d ); | 237 | addExDate( d ); |
238 | newInc->recurrence()->unsetRecurs(); | 238 | newInc->recurrence()->unsetRecurs(); |
239 | if ( type() == "Event") { | 239 | if ( type() == "Event") { |
240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 240 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
241 | QTime tim = dtStart().time(); | 241 | QTime tim = dtStart().time(); |
242 | newInc->setDtStart( QDateTime(d, tim) ); | 242 | newInc->setDtStart( QDateTime(d, tim) ); |
243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 243 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
244 | } else { | 244 | } else { |
245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 245 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
246 | QTime tim = ((Todo*)this)->dtDue().time(); | 246 | QTime tim = ((Todo*)this)->dtDue().time(); |
247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 247 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 248 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
249 | ((Todo*)this)->setRecurDates(); | 249 | ((Todo*)this)->setRecurDates(); |
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 | } |
283 | 295 | ||
284 | void Incidence::setRevision(int rev) | 296 | void Incidence::setRevision(int rev) |
285 | { | 297 | { |
286 | if (mReadOnly) return; | 298 | if (mReadOnly) return; |
287 | mRevision = rev; | 299 | mRevision = rev; |
288 | 300 | ||
289 | updated(); | 301 | updated(); |
290 | } | 302 | } |
291 | 303 | ||
292 | int Incidence::revision() const | 304 | int Incidence::revision() const |
293 | { | 305 | { |
294 | return mRevision; | 306 | return mRevision; |
295 | } | 307 | } |
296 | 308 | ||
297 | void Incidence::setDtStart(const QDateTime &dtStart) | 309 | void Incidence::setDtStart(const QDateTime &dtStart) |
298 | { | 310 | { |
299 | 311 | ||
300 | QDateTime dt = getEvenTime(dtStart); | 312 | QDateTime dt = getEvenTime(dtStart); |
301 | recurrence()->setRecurStart( dt); | 313 | recurrence()->setRecurStart( dt); |
302 | IncidenceBase::setDtStart( dt ); | 314 | IncidenceBase::setDtStart( dt ); |
303 | } | 315 | } |
304 | 316 | ||
305 | void Incidence::setDescription(const QString &description) | 317 | void Incidence::setDescription(const QString &description) |
306 | { | 318 | { |
307 | if (mReadOnly) return; | 319 | if (mReadOnly) return; |
308 | mDescription = description; | 320 | mDescription = description; |
309 | updated(); | 321 | updated(); |
310 | } | 322 | } |
311 | 323 | ||
312 | QString Incidence::description() const | 324 | QString Incidence::description() const |
313 | { | 325 | { |
314 | return mDescription; | 326 | return mDescription; |
315 | } | 327 | } |
316 | 328 | ||
317 | 329 | ||
318 | void Incidence::setSummary(const QString &summary) | 330 | void Incidence::setSummary(const QString &summary) |
319 | { | 331 | { |
320 | if (mReadOnly) return; | 332 | if (mReadOnly) return; |
321 | mSummary = summary; | 333 | mSummary = summary; |
322 | updated(); | 334 | updated(); |
323 | } | 335 | } |
324 | 336 | ||
325 | QString Incidence::summary() const | 337 | QString Incidence::summary() const |
326 | { | 338 | { |
327 | return mSummary; | 339 | return mSummary; |
328 | } | 340 | } |
329 | void Incidence::checkCategories() | 341 | void Incidence::checkCategories() |
330 | { | 342 | { |
331 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 343 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
332 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 344 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
333 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 345 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
334 | } | 346 | } |
335 | 347 | ||
336 | void Incidence::setCategories(const QStringList &categories) | 348 | void Incidence::setCategories(const QStringList &categories) |
337 | { | 349 | { |
338 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
339 | mCategories = categories; | 351 | mCategories = categories; |
340 | checkCategories(); | 352 | checkCategories(); |
341 | updated(); | 353 | updated(); |
342 | } | 354 | } |
343 | 355 | ||
344 | // TODO: remove setCategories(QString) function | 356 | // TODO: remove setCategories(QString) function |
345 | void Incidence::setCategories(const QString &catStr) | 357 | void Incidence::setCategories(const QString &catStr) |
346 | { | 358 | { |
347 | if (mReadOnly) return; | 359 | if (mReadOnly) return; |
348 | mCategories.clear(); | 360 | mCategories.clear(); |
349 | 361 | ||
350 | if (catStr.isEmpty()) return; | 362 | if (catStr.isEmpty()) return; |
351 | 363 | ||
352 | mCategories = QStringList::split(",",catStr); | 364 | mCategories = QStringList::split(",",catStr); |
353 | 365 | ||
354 | QStringList::Iterator it; | 366 | QStringList::Iterator it; |
355 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 367 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
356 | *it = (*it).stripWhiteSpace(); | 368 | *it = (*it).stripWhiteSpace(); |
357 | } | 369 | } |
358 | checkCategories(); | 370 | checkCategories(); |
359 | updated(); | 371 | updated(); |
360 | } | 372 | } |
361 | 373 | ||
362 | QStringList Incidence::categories() const | 374 | QStringList Incidence::categories() const |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index f8da342..60070a2 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -19,192 +19,193 @@ | |||
19 | */ | 19 | */ |
20 | #ifndef INCIDENCE_H | 20 | #ifndef INCIDENCE_H |
21 | #define INCIDENCE_H | 21 | #define INCIDENCE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | 29 | ||
30 | #include "recurrence.h" | 30 | #include "recurrence.h" |
31 | #include "alarm.h" | 31 | #include "alarm.h" |
32 | #include "attachment.h" | 32 | #include "attachment.h" |
33 | #include "listbase.h" | 33 | #include "listbase.h" |
34 | #include "incidencebase.h" | 34 | #include "incidencebase.h" |
35 | 35 | ||
36 | namespace KCal { | 36 | namespace KCal { |
37 | 37 | ||
38 | class Event; | 38 | class Event; |
39 | class Todo; | 39 | class Todo; |
40 | class Journal; | 40 | class Journal; |
41 | 41 | ||
42 | /** | 42 | /** |
43 | This class provides the base class common to all calendar components. | 43 | This class provides the base class common to all calendar components. |
44 | */ | 44 | */ |
45 | class Incidence : public IncidenceBase | 45 | class Incidence : public IncidenceBase |
46 | { | 46 | { |
47 | public: | 47 | public: |
48 | /** | 48 | /** |
49 | This class provides the interface for a visitor of calendar components. It | 49 | This class provides the interface for a visitor of calendar components. It |
50 | serves as base class for concrete visitors, which implement certain actions on | 50 | serves as base class for concrete visitors, which implement certain actions on |
51 | calendar components. It allows to add functions, which operate on the concrete | 51 | calendar components. It allows to add functions, which operate on the concrete |
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
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; |
131 | 132 | ||
132 | /** set the number of revisions this event has seen */ | 133 | /** set the number of revisions this event has seen */ |
133 | void setRevision(int rev); | 134 | void setRevision(int rev); |
134 | /** return the number of revisions this event has seen */ | 135 | /** return the number of revisions this event has seen */ |
135 | int revision() const; | 136 | int revision() const; |
136 | 137 | ||
137 | /** Set starting date/time. */ | 138 | /** Set starting date/time. */ |
138 | virtual void setDtStart(const QDateTime &dtStart); | 139 | virtual void setDtStart(const QDateTime &dtStart); |
139 | /** Return the incidence's ending date/time as a QDateTime. */ | 140 | /** Return the incidence's ending date/time as a QDateTime. */ |
140 | virtual QDateTime dtEnd() const { return QDateTime(); } | 141 | virtual QDateTime dtEnd() const { return QDateTime(); } |
141 | 142 | ||
142 | /** sets the event's lengthy description. */ | 143 | /** sets the event's lengthy description. */ |
143 | void setDescription(const QString &description); | 144 | void setDescription(const QString &description); |
144 | /** returns a reference to the event's description. */ | 145 | /** returns a reference to the event's description. */ |
145 | QString description() const; | 146 | QString description() const; |
146 | 147 | ||
147 | /** sets the event's short summary. */ | 148 | /** sets the event's short summary. */ |
148 | void setSummary(const QString &summary); | 149 | void setSummary(const QString &summary); |
149 | /** returns a reference to the event's summary. */ | 150 | /** returns a reference to the event's summary. */ |
150 | QString summary() const; | 151 | QString summary() const; |
151 | 152 | ||
152 | /** set event's applicable categories */ | 153 | /** set event's applicable categories */ |
153 | void setCategories(const QStringList &categories); | 154 | void setCategories(const QStringList &categories); |
154 | /** set event's categories based on a comma delimited string */ | 155 | /** set event's categories based on a comma delimited string */ |
155 | void setCategories(const QString &catStr); | 156 | void setCategories(const QString &catStr); |
156 | /** return categories in a list */ | 157 | /** return categories in a list */ |
157 | QStringList categories() const; | 158 | QStringList categories() const; |
158 | /** return categories as a comma separated string */ | 159 | /** return categories as a comma separated string */ |
159 | QString categoriesStr(); | 160 | QString categoriesStr(); |
160 | 161 | ||
161 | /** point at some other event to which the event relates. This function should | 162 | /** point at some other event to which the event relates. This function should |
162 | * only be used when constructing a calendar before the related Event | 163 | * only be used when constructing a calendar before the related Event |
163 | * exists. */ | 164 | * exists. */ |
164 | void setRelatedToUid(const QString &); | 165 | void setRelatedToUid(const QString &); |
165 | /** what event does this one relate to? This function should | 166 | /** what event does this one relate to? This function should |
166 | * only be used when constructing a calendar before the related Event | 167 | * only be used when constructing a calendar before the related Event |
167 | * exists. */ | 168 | * exists. */ |
168 | QString relatedToUid() const; | 169 | QString relatedToUid() const; |
169 | /** point at some other event to which the event relates */ | 170 | /** point at some other event to which the event relates */ |
170 | void setRelatedTo(Incidence *relatedTo); | 171 | void setRelatedTo(Incidence *relatedTo); |
171 | /** what event does this one relate to? */ | 172 | /** what event does this one relate to? */ |
172 | Incidence *relatedTo() const; | 173 | Incidence *relatedTo() const; |
173 | /** All events that are related to this event */ | 174 | /** All events that are related to this event */ |
174 | QPtrList<Incidence> relations() const; | 175 | QPtrList<Incidence> relations() const; |
175 | /** Add an event which is related to this event */ | 176 | /** Add an event which is related to this event */ |
176 | void addRelation(Incidence *); | 177 | void addRelation(Incidence *); |
177 | /** Remove event that is related to this event */ | 178 | /** Remove event that is related to this event */ |
178 | void removeRelation(Incidence *); | 179 | void removeRelation(Incidence *); |
179 | 180 | ||
180 | /** returns the list of dates which are exceptions to the recurrence rule */ | 181 | /** returns the list of dates which are exceptions to the recurrence rule */ |
181 | DateList exDates() const; | 182 | DateList exDates() const; |
182 | /** sets the list of dates which are exceptions to the recurrence rule */ | 183 | /** sets the list of dates which are exceptions to the recurrence rule */ |
183 | void setExDates(const DateList &_exDates); | 184 | void setExDates(const DateList &_exDates); |
184 | void setExDates(const char *dates); | 185 | void setExDates(const char *dates); |
185 | /** Add a date to the list of exceptions of the recurrence rule. */ | 186 | /** Add a date to the list of exceptions of the recurrence rule. */ |
186 | void addExDate(const QDate &date); | 187 | void addExDate(const QDate &date); |
187 | 188 | ||
188 | /** returns true if there is an exception for this date in the recurrence | 189 | /** returns true if there is an exception for this date in the recurrence |
189 | rule set, or false otherwise. */ | 190 | rule set, or false otherwise. */ |
190 | bool isException(const QDate &qd) const; | 191 | bool isException(const QDate &qd) const; |
191 | 192 | ||
192 | /** add attachment to this event */ | 193 | /** add attachment to this event */ |
193 | void addAttachment(Attachment *attachment); | 194 | void addAttachment(Attachment *attachment); |
194 | /** remove and delete a specific attachment */ | 195 | /** remove and delete a specific attachment */ |
195 | void deleteAttachment(Attachment *attachment); | 196 | void deleteAttachment(Attachment *attachment); |
196 | /** remove and delete all attachments with this mime type */ | 197 | /** remove and delete all attachments with this mime type */ |
197 | void deleteAttachments(const QString& mime); | 198 | void deleteAttachments(const QString& mime); |
198 | /** return list of all associated attachments */ | 199 | /** return list of all associated attachments */ |
199 | QPtrList<Attachment> attachments() const; | 200 | QPtrList<Attachment> attachments() const; |
200 | /** find a list of attachments with this mime type */ | 201 | /** find a list of attachments with this mime type */ |
201 | QPtrList<Attachment> attachments(const QString& mime) const; | 202 | QPtrList<Attachment> attachments(const QString& mime) const; |
202 | 203 | ||
203 | /** sets the event's status the value specified. See the enumeration | 204 | /** sets the event's status the value specified. See the enumeration |
204 | * above for possible values. */ | 205 | * above for possible values. */ |
205 | void setSecrecy(int); | 206 | void setSecrecy(int); |
206 | /** return the event's secrecy. */ | 207 | /** return the event's secrecy. */ |
207 | int secrecy() const; | 208 | int secrecy() const; |
208 | /** return the event's secrecy in string format. */ | 209 | /** return the event's secrecy in string format. */ |
209 | QString secrecyStr() const; | 210 | QString secrecyStr() const; |
210 | /** return list of all availbale secrecy classes */ | 211 | /** return list of all availbale secrecy classes */ |