-rw-r--r-- | libkcal/calendar.cpp | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index b7990d4..b1806ee 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -107,15 +107,34 @@ void Calendar::init() // KOPrefs::instance()->writeConfig(); } Calendar::~Calendar() { delete mDefaultFilter; - if ( mUndoIncidence ) + clearUndo( 0 ); +} +void Calendar::clearUndo( Incidence * newUndo ) +{ + + if ( mUndoIncidence ) { + if ( mUndoIncidence->typeID() == eventID ) + delete ((Event*) mUndoIncidence) ; + else if ( mUndoIncidence->typeID() == todoID ) + delete ( (Todo*) mUndoIncidence ); + else if ( mUndoIncidence->typeID() == journalID ) + delete ( (Journal*) mUndoIncidence ); + else delete mUndoIncidence; } + mUndoIncidence = newUndo; + if ( mUndoIncidence ) { + mUndoIncidence->clearRelations(); + } + +} + void Calendar::setDontDeleteIncidencesOnClose () { mDeleteIncidencesOnClose = false; } void Calendar::setDefaultCalendar( int d ) { @@ -444,23 +463,38 @@ void Calendar::removeRelations( Incidence *incidence ) // If this incidence is related to something else, tell that about it if( incidence->relatedTo() ) incidence->relatedTo()->removeRelation( incidence ); // Remove this one from the orphans list - if( mOrphanUids.remove( uid ) ) + if( mOrphanUids.remove( uid ) ) { + QString r2uid = incidence->relatedToUid(); + QPtrList<Incidence> tempList; + while( Incidence* i = mOrphans[ r2uid ] ) { + mOrphans.remove( r2uid ); + if ( i != incidence ) tempList.append( i ); + } + Incidence* inc = tempList.first(); + while ( inc ) { + mOrphans.insert( r2uid, inc ); + inc = tempList.next(); + } + } + // LR: and another big bad bug found +#if 0 // This incidence is located in the orphans list - it should be removed if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { // Removing wasn't that easy for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { if( it.current()->uid() == uid ) { mOrphans.remove( it.currentKey() ); break; } } } +#endif } void Calendar::registerObserver( Observer *observer ) { mObserver = observer; mNewObserver = true; |