author | zautrix <zautrix> | 2005-11-28 01:23:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 01:23:07 (UTC) |
commit | 084180efc1bccba341bf3f2f718fd10cdfdaf18e (patch) (unidiff) | |
tree | d464e19dd4b3e72bf553b7d083fb493e9e8405e6 | |
parent | e08811c2246f63b2b63f9db6b65701344460f3d7 (diff) | |
download | kdepimpi-084180efc1bccba341bf3f2f718fd10cdfdaf18e.zip kdepimpi-084180efc1bccba341bf3f2f718fd10cdfdaf18e.tar.gz kdepimpi-084180efc1bccba341bf3f2f718fd10cdfdaf18e.tar.bz2 |
ync
-rw-r--r-- | libkcal/calendar.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 1350f6d..9b38d3f 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -374,119 +374,119 @@ void Calendar::addIncidenceBranch(Incidence *i) | |||
374 | addIncidenceBranch( inc ); | 374 | addIncidenceBranch( inc ); |
375 | } | 375 | } |
376 | } | 376 | } |
377 | 377 | ||
378 | bool Calendar::addIncidence(Incidence *i) | 378 | bool Calendar::addIncidence(Incidence *i) |
379 | { | 379 | { |
380 | Incidence::AddVisitor<Calendar> v(this); | 380 | Incidence::AddVisitor<Calendar> v(this); |
381 | if ( i->calID() == 0 ) | 381 | if ( i->calID() == 0 ) |
382 | i->setCalID_block( mDefaultCalendar ); | 382 | i->setCalID_block( mDefaultCalendar ); |
383 | i->setCalEnabled( true ); | 383 | i->setCalEnabled( true ); |
384 | return i->accept(v); | 384 | return i->accept(v); |
385 | } | 385 | } |
386 | void Calendar::deleteIncidence(Incidence *in) | 386 | void Calendar::deleteIncidence(Incidence *in) |
387 | { | 387 | { |
388 | if ( in->typeID() == eventID ) | 388 | if ( in->typeID() == eventID ) |
389 | deleteEvent( (Event*) in ); | 389 | deleteEvent( (Event*) in ); |
390 | else if ( in->typeID() == todoID ) | 390 | else if ( in->typeID() == todoID ) |
391 | deleteTodo( (Todo*) in); | 391 | deleteTodo( (Todo*) in); |
392 | else if ( in->typeID() == journalID ) | 392 | else if ( in->typeID() == journalID ) |
393 | deleteJournal( (Journal*) in ); | 393 | deleteJournal( (Journal*) in ); |
394 | } | 394 | } |
395 | 395 | ||
396 | Incidence* Calendar::incidence( const QString& uid ) | 396 | Incidence* Calendar::incidence( const QString& uid ) |
397 | { | 397 | { |
398 | Incidence* i; | 398 | Incidence* i; |
399 | 399 | ||
400 | if( (i = todo( uid )) != 0 ) | 400 | if( (i = todo( uid )) != 0 ) |
401 | return i; | 401 | return i; |
402 | if( (i = event( uid )) != 0 ) | 402 | if( (i = event( uid )) != 0 ) |
403 | return i; | 403 | return i; |
404 | if( (i = journal( uid )) != 0 ) | 404 | if( (i = journal( uid )) != 0 ) |
405 | return i; | 405 | return i; |
406 | 406 | ||
407 | return 0; | 407 | return 0; |
408 | } | 408 | } |
409 | 409 | ||
410 | QPtrList<Todo> Calendar::todos() | 410 | QPtrList<Todo> Calendar::todos() |
411 | { | 411 | { |
412 | QPtrList<Todo> tl = rawTodos(); | 412 | QPtrList<Todo> tl = rawTodos(); |
413 | mFilter->apply( &tl ); | 413 | mFilter->apply( &tl ); |
414 | return tl; | 414 | return tl; |
415 | } | 415 | } |
416 | 416 | ||
417 | // When this is called, the todo have already been added to the calendar. | 417 | // When this is called, the todo have already been added to the calendar. |
418 | // This method is only about linking related todos | 418 | // This method is only about linking related todos |
419 | void Calendar::setupRelations( Incidence *incidence ) | 419 | void Calendar::setupRelations( Incidence *incidence ) |
420 | { | 420 | { |
421 | QString uid = incidence->uid(); | 421 | QString uid = incidence->uid(); |
422 | //qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); | 422 | qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); |
423 | // First, go over the list of orphans and see if this is their parent | 423 | // First, go over the list of orphans and see if this is their parent |
424 | while( Incidence* i = mOrphans[ uid ] ) { | 424 | while( Incidence* i = mOrphans[ uid ] ) { |
425 | mOrphans.remove( uid ); | 425 | mOrphans.remove( uid ); |
426 | i->setRelatedTo( incidence ); | 426 | i->setRelatedTo( incidence ); |
427 | //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); | 427 | qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); |
428 | incidence->addRelation( i ); | 428 | incidence->addRelation( i ); |
429 | mOrphanUids.remove( i->uid() ); | 429 | mOrphanUids.remove( i->uid() ); |
430 | } | 430 | } |
431 | 431 | ||
432 | // Now see about this incidences parent | 432 | // Now see about this incidences parent |
433 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 433 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
434 | // This incidence has a uid it is related to, but is not registered to it yet | 434 | // This incidence has a uid it is related to, but is not registered to it yet |
435 | // Try to find it | 435 | // Try to find it |
436 | //qDebug("Test parent for %s", incidence->summary().latin1()); | 436 | qDebug("Test parent for %s", incidence->summary().latin1()); |
437 | Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); | 437 | Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); |
438 | if( parent ) { | 438 | if( parent ) { |
439 | // Found it | 439 | // Found it |
440 | // qDebug("parent found for for %s", incidence->summary().latin1()); | 440 | qDebug("parent found for for %s", incidence->summary().latin1()); |
441 | incidence->setRelatedTo( parent ); | 441 | incidence->setRelatedTo( parent ); |
442 | parent->addRelation( incidence ); | 442 | parent->addRelation( incidence ); |
443 | } else { | 443 | } else { |
444 | // qDebug("NO parent found for for %s", incidence->summary().latin1()); | 444 | qDebug("NO parent found for for %s", incidence->summary().latin1()); |
445 | // Not found, put this in the mOrphans list | 445 | // Not found, put this in the mOrphans list |
446 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 446 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
447 | mOrphanUids.insert( incidence->uid(), incidence ); | 447 | mOrphanUids.insert( incidence->uid(), incidence ); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | } | 450 | } |
451 | 451 | ||
452 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 452 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
453 | void Calendar::removeRelations( Incidence *incidence ) | 453 | void Calendar::removeRelations( Incidence *incidence ) |
454 | { | 454 | { |
455 | // qDebug("Calendar::removeRelations "); | 455 | // qDebug("Calendar::removeRelations "); |
456 | QString uid = incidence->uid(); | 456 | QString uid = incidence->uid(); |
457 | 457 | ||
458 | QPtrList<Incidence> relations = incidence->relations(); | 458 | QPtrList<Incidence> relations = incidence->relations(); |
459 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 459 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
460 | if( !mOrphanUids.find( i->uid() ) ) { | 460 | if( !mOrphanUids.find( i->uid() ) ) { |
461 | mOrphans.insert( uid, i ); | 461 | mOrphans.insert( uid, i ); |
462 | mOrphanUids.insert( i->uid(), i ); | 462 | mOrphanUids.insert( i->uid(), i ); |
463 | i->setRelatedTo( 0 ); | 463 | i->setRelatedTo( 0 ); |
464 | i->setRelatedToUid( uid ); | 464 | i->setRelatedToUid( uid ); |
465 | } | 465 | } |
466 | 466 | ||
467 | // If this incidence is related to something else, tell that about it | 467 | // If this incidence is related to something else, tell that about it |
468 | if( incidence->relatedTo() ) | 468 | if( incidence->relatedTo() ) |
469 | incidence->relatedTo()->removeRelation( incidence ); | 469 | incidence->relatedTo()->removeRelation( incidence ); |
470 | 470 | ||
471 | // Remove this one from the orphans list | 471 | // Remove this one from the orphans list |
472 | if( mOrphanUids.remove( uid ) ) { | 472 | if( mOrphanUids.remove( uid ) ) { |
473 | QString r2uid = incidence->relatedToUid(); | 473 | QString r2uid = incidence->relatedToUid(); |
474 | QPtrList<Incidence> tempList; | 474 | QPtrList<Incidence> tempList; |
475 | while( Incidence* i = mOrphans[ r2uid ] ) { | 475 | while( Incidence* i = mOrphans[ r2uid ] ) { |
476 | mOrphans.remove( r2uid ); | 476 | mOrphans.remove( r2uid ); |
477 | if ( i != incidence ) tempList.append( i ); | 477 | if ( i != incidence ) tempList.append( i ); |
478 | } | 478 | } |
479 | Incidence* inc = tempList.first(); | 479 | Incidence* inc = tempList.first(); |
480 | while ( inc ) { | 480 | while ( inc ) { |
481 | mOrphans.insert( r2uid, inc ); | 481 | mOrphans.insert( r2uid, inc ); |
482 | inc = tempList.next(); | 482 | inc = tempList.next(); |
483 | } | 483 | } |
484 | } | 484 | } |
485 | // LR: and another big bad bug found | 485 | // LR: and another big bad bug found |
486 | #if 0 | 486 | #if 0 |
487 | // This incidence is located in the orphans list - it should be removed | 487 | // This incidence is located in the orphans list - it should be removed |
488 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 488 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
489 | // Removing wasn't that easy | 489 | // Removing wasn't that easy |
490 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 490 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
491 | if( it.current()->uid() == uid ) { | 491 | if( it.current()->uid() == uid ) { |
492 | mOrphans.remove( it.currentKey() ); | 492 | mOrphans.remove( it.currentKey() ); |