-rw-r--r-- | libkcal/calendar.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index b7990d4..b1806ee 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -105,19 +105,38 @@ void Calendar::init() | |||
105 | #endif | 105 | #endif |
106 | 106 | ||
107 | // KOPrefs::instance()->writeConfig(); | 107 | // KOPrefs::instance()->writeConfig(); |
108 | } | 108 | } |
109 | 109 | ||
110 | Calendar::~Calendar() | 110 | Calendar::~Calendar() |
111 | { | 111 | { |
112 | delete mDefaultFilter; | 112 | delete mDefaultFilter; |
113 | if ( mUndoIncidence ) | 113 | clearUndo( 0 ); |
114 | delete mUndoIncidence; | 114 | } |
115 | } | 115 | void Calendar::clearUndo( Incidence * newUndo ) |
116 | { | ||
117 | |||
118 | if ( mUndoIncidence ) { | ||
119 | if ( mUndoIncidence->typeID() == eventID ) | ||
120 | delete ((Event*) mUndoIncidence) ; | ||
121 | else if ( mUndoIncidence->typeID() == todoID ) | ||
122 | delete ( (Todo*) mUndoIncidence ); | ||
123 | else if ( mUndoIncidence->typeID() == journalID ) | ||
124 | delete ( (Journal*) mUndoIncidence ); | ||
125 | else | ||
126 | delete mUndoIncidence; | ||
127 | } | ||
128 | mUndoIncidence = newUndo; | ||
129 | if ( mUndoIncidence ) { | ||
130 | mUndoIncidence->clearRelations(); | ||
131 | } | ||
132 | |||
133 | } | ||
134 | |||
116 | void Calendar::setDontDeleteIncidencesOnClose () | 135 | void Calendar::setDontDeleteIncidencesOnClose () |
117 | { | 136 | { |
118 | mDeleteIncidencesOnClose = false; | 137 | mDeleteIncidencesOnClose = false; |
119 | } | 138 | } |
120 | void Calendar::setDefaultCalendar( int d ) | 139 | void Calendar::setDefaultCalendar( int d ) |
121 | { | 140 | { |
122 | mDefaultCalendar = d; | 141 | mDefaultCalendar = d; |
123 | } | 142 | } |
@@ -442,27 +461,42 @@ void Calendar::removeRelations( Incidence *incidence ) | |||
442 | i->setRelatedToUid( uid ); | 461 | i->setRelatedToUid( uid ); |
443 | } | 462 | } |
444 | 463 | ||
445 | // If this incidence is related to something else, tell that about it | 464 | // If this incidence is related to something else, tell that about it |
446 | if( incidence->relatedTo() ) | 465 | if( incidence->relatedTo() ) |
447 | incidence->relatedTo()->removeRelation( incidence ); | 466 | incidence->relatedTo()->removeRelation( incidence ); |
448 | 467 | ||
449 | // Remove this one from the orphans list | 468 | // Remove this one from the orphans list |
450 | if( mOrphanUids.remove( uid ) ) | 469 | if( mOrphanUids.remove( uid ) ) { |
470 | QString r2uid = incidence->relatedToUid(); | ||
471 | QPtrList<Incidence> tempList; | ||
472 | while( Incidence* i = mOrphans[ r2uid ] ) { | ||
473 | mOrphans.remove( r2uid ); | ||
474 | if ( i != incidence ) tempList.append( i ); | ||
475 | } | ||
476 | Incidence* inc = tempList.first(); | ||
477 | while ( inc ) { | ||
478 | mOrphans.insert( r2uid, inc ); | ||
479 | inc = tempList.next(); | ||
480 | } | ||
481 | } | ||
482 | // LR: and another big bad bug found | ||
483 | #if 0 | ||
451 | // This incidence is located in the orphans list - it should be removed | 484 | // This incidence is located in the orphans list - it should be removed |
452 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 485 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
453 | // Removing wasn't that easy | 486 | // Removing wasn't that easy |
454 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 487 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
455 | if( it.current()->uid() == uid ) { | 488 | if( it.current()->uid() == uid ) { |
456 | mOrphans.remove( it.currentKey() ); | 489 | mOrphans.remove( it.currentKey() ); |
457 | break; | 490 | break; |
458 | } | 491 | } |
459 | } | 492 | } |
460 | } | 493 | } |
494 | #endif | ||
461 | } | 495 | } |
462 | 496 | ||
463 | void Calendar::registerObserver( Observer *observer ) | 497 | void Calendar::registerObserver( Observer *observer ) |
464 | { | 498 | { |
465 | mObserver = observer; | 499 | mObserver = observer; |
466 | mNewObserver = true; | 500 | mNewObserver = true; |
467 | } | 501 | } |
468 | 502 | ||