summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
Unidiff
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 5092d1a..a662eeb 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -385,104 +385,104 @@ Incidence* Calendar::incidence( const QString& uid )
385 if( (i = journal( uid )) != 0 ) 385 if( (i = journal( uid )) != 0 )
386 return i; 386 return i;
387 387
388 return 0; 388 return 0;
389} 389}
390 390
391QPtrList<Todo> Calendar::todos() 391QPtrList<Todo> Calendar::todos()
392{ 392{
393 QPtrList<Todo> tl = rawTodos(); 393 QPtrList<Todo> tl = rawTodos();
394 mFilter->apply( &tl ); 394 mFilter->apply( &tl );
395 return tl; 395 return tl;
396} 396}
397 397
398// When this is called, the todo have already been added to the calendar. 398// When this is called, the todo have already been added to the calendar.
399// This method is only about linking related todos 399// This method is only about linking related todos
400void Calendar::setupRelations( Incidence *incidence ) 400void Calendar::setupRelations( Incidence *incidence )
401{ 401{
402 QString uid = incidence->uid(); 402 QString uid = incidence->uid();
403 //qDebug("Calendar::setupRelations "); 403 //qDebug("Calendar::setupRelations ");
404 // First, go over the list of orphans and see if this is their parent 404 // First, go over the list of orphans and see if this is their parent
405 while( Incidence* i = mOrphans[ uid ] ) { 405 while( Incidence* i = mOrphans[ uid ] ) {
406 mOrphans.remove( uid ); 406 mOrphans.remove( uid );
407 i->setRelatedTo( incidence ); 407 i->setRelatedTo( incidence );
408 incidence->addRelation( i ); 408 incidence->addRelation( i );
409 mOrphanUids.remove( i->uid() ); 409 mOrphanUids.remove( i->uid() );
410 } 410 }
411 411
412 // Now see about this incidences parent 412 // Now see about this incidences parent
413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
414 // This incidence has a uid it is related to, but is not registered to it yet 414 // This incidence has a uid it is related to, but is not registered to it yet
415 // Try to find it 415 // Try to find it
416 Incidence* parent = this->incidence( incidence->relatedToUid() ); 416 Incidence* parent = this->incidence( incidence->relatedToUid() );
417 if( parent ) { 417 if( parent ) {
418 // Found it 418 // Found it
419 incidence->setRelatedTo( parent ); 419 incidence->setRelatedTo( parent );
420 parent->addRelation( incidence ); 420 parent->addRelation( incidence );
421 } else { 421 } else {
422 // Not found, put this in the mOrphans list 422 // Not found, put this in the mOrphans list
423 mOrphans.insert( incidence->relatedToUid(), incidence ); 423 mOrphans.insert( incidence->relatedToUid(), incidence );
424 mOrphanUids.insert( incidence->uid(), incidence ); 424 mOrphanUids.insert( incidence->uid(), incidence );
425 } 425 }
426 } 426 }
427} 427}
428 428
429// If a task with subtasks is deleted, move it's subtasks to the orphans list 429// If a task with subtasks is deleted, move it's subtasks to the orphans list
430void Calendar::removeRelations( Incidence *incidence ) 430void Calendar::removeRelations( Incidence *incidence )
431{ 431{
432 // qDebug("Calendar::removeRelations "); 432 // qDebug("Calendar::removeRelations ");
433 QString uid = incidence->uid(); 433 QString uid = incidence->uid();
434 434
435 QPtrList<Incidence> relations = incidence->relations(); 435 QPtrList<Incidence> relations = incidence->relations();
436 for( Incidence* i = relations.first(); i; i = relations.next() ) 436 for( Incidence* i = relations.first(); i; i = relations.next() )
437 if( !mOrphanUids.find( i->uid() ) ) { 437 if( !mOrphanUids.find( i->uid() ) ) {
438 mOrphans.insert( uid, i ); 438 mOrphans.insert( uid, i );
439 mOrphanUids.insert( i->uid(), i ); 439 mOrphanUids.insert( i->uid(), i );
440 i->setRelatedTo( 0 ); 440 i->setRelatedTo( 0 );
441 i->setRelatedToUid( uid ); 441 i->setRelatedToUid( uid );
442 } 442 }
443 443
444 // If this incidence is related to something else, tell that about it 444 // If this incidence is related to something else, tell that about it
445 if( incidence->relatedTo() ) 445 if( incidence->relatedTo() )
446 incidence->relatedTo()->removeRelation( incidence ); 446 incidence->relatedTo()->removeRelation( incidence );
447 447
448 // Remove this one from the orphans list 448 // Remove this one from the orphans list
449 if( mOrphanUids.remove( uid ) ) 449 if( mOrphanUids.remove( uid ) )
450 // This incidence is located in the orphans list - it should be removed 450 // This incidence is located in the orphans list - it should be removed
451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
452 // Removing wasn't that easy 452 // Removing wasn't that easy
453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
454 if( it.current()->uid() == uid ) { 454 if( it.current()->uid() == uid ) {
455 mOrphans.remove( it.currentKey() ); 455 mOrphans.remove( it.currentKey() );
456 break; 456 break;
457 } 457 }
458 } 458 }
459 } 459 }
460} 460}
461 461
462void Calendar::registerObserver( Observer *observer ) 462void Calendar::registerObserver( Observer *observer )
463{ 463{
464 mObserver = observer; 464 mObserver = observer;
465 mNewObserver = true; 465 mNewObserver = true;
466} 466}
467 467
468void Calendar::setModified( bool modified ) 468void Calendar::setModified( bool modified )
469{ 469{
470 if ( mObserver ) mObserver->calendarModified( modified, this ); 470 if ( mObserver ) mObserver->calendarModified( modified, this );
471 if ( modified != mModified || mNewObserver ) { 471 if ( modified != mModified || mNewObserver ) {
472 mNewObserver = false; 472 mNewObserver = false;
473 // if ( mObserver ) mObserver->calendarModified( modified, this ); 473 // if ( mObserver ) mObserver->calendarModified( modified, this );
474 mModified = modified; 474 mModified = modified;
475 } 475 }
476} 476}
477 477
478void Calendar::setLoadedProductId( const QString &id ) 478void Calendar::setLoadedProductId( const QString &id )
479{ 479{
480 mLoadedProductId = id; 480 mLoadedProductId = id;
481} 481}
482 482
483QString Calendar::loadedProductId() 483QString Calendar::loadedProductId()
484{ 484{
485 return mLoadedProductId; 485 return mLoadedProductId;
486} 486}
487 487
488//#include "calendar.moc" 488//#include "calendar.moc"