-rw-r--r-- | libkcal/calendarlocal.cpp | 31 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 | ||||
-rw-r--r-- | libkcal/journal.cpp | 4 |
3 files changed, 24 insertions, 12 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 5baa7dc..e8c969f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -269,5 +269,18 @@ void CalendarLocal::close() setModified( false ); } - + void CalendarLocal::clearUndo() +{ + 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 = 0; +} bool CalendarLocal::addAnniversaryNoDup( Event *event ) { @@ -328,6 +341,6 @@ bool CalendarLocal::addEvent( Event *event ) void CalendarLocal::deleteEvent( Event *event ) { - if ( mUndoIncidence ) delete mUndoIncidence; - mUndoIncidence = event->clone(); + clearUndo(); + mUndoIncidence = event; if ( mEventList.removeRef( event ) ) { setModified( true ); @@ -383,7 +396,7 @@ void CalendarLocal::deleteTodo( Todo *todo ) { // Handle orphaned children - if ( mUndoIncidence ) delete mUndoIncidence; + clearUndo(); removeRelations( todo ); - mUndoIncidence = todo->clone(); + mUndoIncidence = todo; if ( mTodoList.removeRef( todo ) ) { @@ -887,7 +900,6 @@ bool CalendarLocal::addJournal(Journal *journal) void CalendarLocal::deleteJournal( Journal *journal ) { - if ( mUndoIncidence ) delete mUndoIncidence; - mUndoIncidence = journal->clone(); - mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); + clearUndo(); + mUndoIncidence = journal; if ( mJournalList.removeRef(journal) ) { setModified( true ); @@ -968,6 +980,5 @@ void CalendarLocal::setCalendarRemove( int id ) } - if ( mUndoIncidence ) delete mUndoIncidence; - mUndoIncidence = 0; + clearUndo(); } diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a7a85c8..ae7e30c 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -70,4 +70,5 @@ class CalendarLocal : public Calendar */ void close(); + void clearUndo(); void save() {} diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp index c4e4474..328db46 100644 --- a/libkcal/journal.cpp +++ b/libkcal/journal.cpp @@ -25,10 +25,10 @@ using namespace KCal; Journal::Journal() { - qDebug("New JJJ "); + } Journal::~Journal() { - qDebug("delete JJJ "); + } |