-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 @@ -112,5 +112,24 @@ 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 () @@ -449,3 +468,17 @@ void Calendar::removeRelations( Incidence *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 @@ -460,2 +493,3 @@ void Calendar::removeRelations( Incidence *incidence ) } +#endif } |