-rw-r--r-- | libkcal/calendar.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index a662eeb..b7990d4 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -299,129 +299,130 @@ void Calendar::resetTempSyncStat() | |||
299 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 299 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
300 | 300 | ||
301 | QPtrList<Journal> j = journals(); | 301 | QPtrList<Journal> j = journals(); |
302 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 302 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
303 | } | 303 | } |
304 | QPtrList<Incidence> Calendar::rawIncidences() | 304 | QPtrList<Incidence> Calendar::rawIncidences() |
305 | { | 305 | { |
306 | QPtrList<Incidence> incidences; | 306 | QPtrList<Incidence> incidences; |
307 | 307 | ||
308 | Incidence *i; | 308 | Incidence *i; |
309 | 309 | ||
310 | QPtrList<Event> e = rawEvents(); | 310 | QPtrList<Event> e = rawEvents(); |
311 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 311 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
312 | 312 | ||
313 | QPtrList<Todo> t = rawTodos(); | 313 | QPtrList<Todo> t = rawTodos(); |
314 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 314 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
315 | 315 | ||
316 | QPtrList<Journal> j = journals(); | 316 | QPtrList<Journal> j = journals(); |
317 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 317 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
318 | 318 | ||
319 | return incidences; | 319 | return incidences; |
320 | } | 320 | } |
321 | 321 | ||
322 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 322 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
323 | { | 323 | { |
324 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 324 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
325 | mFilter->apply(&el); | 325 | mFilter->apply(&el); |
326 | return el; | 326 | return el; |
327 | } | 327 | } |
328 | 328 | ||
329 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 329 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
330 | { | 330 | { |
331 | QPtrList<Event> el = rawEventsForDate(qdt); | 331 | QPtrList<Event> el = rawEventsForDate(qdt); |
332 | mFilter->apply(&el); | 332 | mFilter->apply(&el); |
333 | return el; | 333 | return el; |
334 | } | 334 | } |
335 | 335 | ||
336 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 336 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
337 | bool inclusive) | 337 | bool inclusive) |
338 | { | 338 | { |
339 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 339 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
340 | mFilter->apply(&el); | 340 | mFilter->apply(&el); |
341 | return el; | 341 | return el; |
342 | } | 342 | } |
343 | 343 | ||
344 | QPtrList<Event> Calendar::events() | 344 | QPtrList<Event> Calendar::events() |
345 | { | 345 | { |
346 | QPtrList<Event> el = rawEvents(); | 346 | QPtrList<Event> el = rawEvents(); |
347 | mFilter->apply(&el); | 347 | mFilter->apply(&el); |
348 | return el; | 348 | return el; |
349 | } | 349 | } |
350 | void Calendar::addIncidenceBranch(Incidence *i) | 350 | void Calendar::addIncidenceBranch(Incidence *i) |
351 | { | 351 | { |
352 | addIncidence( i ); | 352 | addIncidence( i ); |
353 | Incidence * inc; | 353 | Incidence * inc; |
354 | QPtrList<Incidence> Relations = i->relations(); | 354 | QPtrList<Incidence> Relations = i->relations(); |
355 | for (inc=Relations.first();inc;inc=Relations.next()) { | 355 | for (inc=Relations.first();inc;inc=Relations.next()) { |
356 | addIncidenceBranch( inc ); | 356 | addIncidenceBranch( inc ); |
357 | } | 357 | } |
358 | } | 358 | } |
359 | 359 | ||
360 | bool Calendar::addIncidence(Incidence *i) | 360 | bool Calendar::addIncidence(Incidence *i) |
361 | { | 361 | { |
362 | Incidence::AddVisitor<Calendar> v(this); | 362 | Incidence::AddVisitor<Calendar> v(this); |
363 | i->setCalID( mDefaultCalendar ); | 363 | if ( i->calID() == 0 ) |
364 | i->setCalID( mDefaultCalendar ); | ||
364 | i->setCalEnabled( true ); | 365 | i->setCalEnabled( true ); |
365 | return i->accept(v); | 366 | return i->accept(v); |
366 | } | 367 | } |
367 | void Calendar::deleteIncidence(Incidence *in) | 368 | void Calendar::deleteIncidence(Incidence *in) |
368 | { | 369 | { |
369 | if ( in->typeID() == eventID ) | 370 | if ( in->typeID() == eventID ) |
370 | deleteEvent( (Event*) in ); | 371 | deleteEvent( (Event*) in ); |
371 | else if ( in->typeID() == todoID ) | 372 | else if ( in->typeID() == todoID ) |
372 | deleteTodo( (Todo*) in); | 373 | deleteTodo( (Todo*) in); |
373 | else if ( in->typeID() == journalID ) | 374 | else if ( in->typeID() == journalID ) |
374 | deleteJournal( (Journal*) in ); | 375 | deleteJournal( (Journal*) in ); |
375 | } | 376 | } |
376 | 377 | ||
377 | Incidence* Calendar::incidence( const QString& uid ) | 378 | Incidence* Calendar::incidence( const QString& uid ) |
378 | { | 379 | { |
379 | Incidence* i; | 380 | Incidence* i; |
380 | 381 | ||
381 | if( (i = todo( uid )) != 0 ) | 382 | if( (i = todo( uid )) != 0 ) |
382 | return i; | 383 | return i; |
383 | if( (i = event( uid )) != 0 ) | 384 | if( (i = event( uid )) != 0 ) |
384 | return i; | 385 | return i; |
385 | if( (i = journal( uid )) != 0 ) | 386 | if( (i = journal( uid )) != 0 ) |
386 | return i; | 387 | return i; |
387 | 388 | ||
388 | return 0; | 389 | return 0; |
389 | } | 390 | } |
390 | 391 | ||
391 | QPtrList<Todo> Calendar::todos() | 392 | QPtrList<Todo> Calendar::todos() |
392 | { | 393 | { |
393 | QPtrList<Todo> tl = rawTodos(); | 394 | QPtrList<Todo> tl = rawTodos(); |
394 | mFilter->apply( &tl ); | 395 | mFilter->apply( &tl ); |
395 | return tl; | 396 | return tl; |
396 | } | 397 | } |
397 | 398 | ||
398 | // When this is called, the todo have already been added to the calendar. | 399 | // When this is called, the todo have already been added to the calendar. |
399 | // This method is only about linking related todos | 400 | // This method is only about linking related todos |
400 | void Calendar::setupRelations( Incidence *incidence ) | 401 | void Calendar::setupRelations( Incidence *incidence ) |
401 | { | 402 | { |
402 | QString uid = incidence->uid(); | 403 | QString uid = incidence->uid(); |
403 | //qDebug("Calendar::setupRelations "); | 404 | //qDebug("Calendar::setupRelations "); |
404 | // First, go over the list of orphans and see if this is their parent | 405 | // First, go over the list of orphans and see if this is their parent |
405 | while( Incidence* i = mOrphans[ uid ] ) { | 406 | while( Incidence* i = mOrphans[ uid ] ) { |
406 | mOrphans.remove( uid ); | 407 | mOrphans.remove( uid ); |
407 | i->setRelatedTo( incidence ); | 408 | i->setRelatedTo( incidence ); |
408 | incidence->addRelation( i ); | 409 | incidence->addRelation( i ); |
409 | mOrphanUids.remove( i->uid() ); | 410 | mOrphanUids.remove( i->uid() ); |
410 | } | 411 | } |
411 | 412 | ||
412 | // Now see about this incidences parent | 413 | // Now see about this incidences parent |
413 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 414 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
414 | // This incidence has a uid it is related to, but is not registered to it yet | 415 | // This incidence has a uid it is related to, but is not registered to it yet |
415 | // Try to find it | 416 | // Try to find it |
416 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 417 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
417 | if( parent ) { | 418 | if( parent ) { |
418 | // Found it | 419 | // Found it |
419 | incidence->setRelatedTo( parent ); | 420 | incidence->setRelatedTo( parent ); |
420 | parent->addRelation( incidence ); | 421 | parent->addRelation( incidence ); |
421 | } else { | 422 | } else { |
422 | // Not found, put this in the mOrphans list | 423 | // Not found, put this in the mOrphans list |
423 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 424 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
424 | mOrphanUids.insert( incidence->uid(), incidence ); | 425 | mOrphanUids.insert( incidence->uid(), incidence ); |
425 | } | 426 | } |
426 | } | 427 | } |
427 | } | 428 | } |