-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 | |||
@@ -268,7 +268,20 @@ void CalendarLocal::close() | |||
268 | 268 | ||
269 | setModified( false ); | 269 | setModified( false ); |
270 | } | 270 | } |
271 | 271 | void CalendarLocal::clearUndo() | |
272 | { | ||
273 | if ( mUndoIncidence ) { | ||
274 | if ( mUndoIncidence->typeID() == eventID ) | ||
275 | delete ((Event*) mUndoIncidence) ; | ||
276 | else if ( mUndoIncidence->typeID() == todoID ) | ||
277 | delete ( (Todo*) mUndoIncidence ); | ||
278 | else if ( mUndoIncidence->typeID() == journalID ) | ||
279 | delete ( (Journal*) mUndoIncidence ); | ||
280 | else | ||
281 | delete mUndoIncidence; | ||
282 | } | ||
283 | mUndoIncidence = 0; | ||
284 | } | ||
272 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 285 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
273 | { | 286 | { |
274 | QString cat; | 287 | QString cat; |
@@ -327,8 +340,8 @@ bool CalendarLocal::addEvent( Event *event ) | |||
327 | 340 | ||
328 | void CalendarLocal::deleteEvent( Event *event ) | 341 | void CalendarLocal::deleteEvent( Event *event ) |
329 | { | 342 | { |
330 | if ( mUndoIncidence ) delete mUndoIncidence; | 343 | clearUndo(); |
331 | mUndoIncidence = event->clone(); | 344 | mUndoIncidence = event; |
332 | if ( mEventList.removeRef( event ) ) { | 345 | if ( mEventList.removeRef( event ) ) { |
333 | setModified( true ); | 346 | setModified( true ); |
334 | } | 347 | } |
@@ -382,9 +395,9 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
382 | void CalendarLocal::deleteTodo( Todo *todo ) | 395 | void CalendarLocal::deleteTodo( Todo *todo ) |
383 | { | 396 | { |
384 | // Handle orphaned children | 397 | // Handle orphaned children |
385 | if ( mUndoIncidence ) delete mUndoIncidence; | 398 | clearUndo(); |
386 | removeRelations( todo ); | 399 | removeRelations( todo ); |
387 | mUndoIncidence = todo->clone(); | 400 | mUndoIncidence = todo; |
388 | 401 | ||
389 | if ( mTodoList.removeRef( todo ) ) { | 402 | if ( mTodoList.removeRef( todo ) ) { |
390 | setModified( true ); | 403 | setModified( true ); |
@@ -886,9 +899,8 @@ bool CalendarLocal::addJournal(Journal *journal) | |||
886 | 899 | ||
887 | void CalendarLocal::deleteJournal( Journal *journal ) | 900 | void CalendarLocal::deleteJournal( Journal *journal ) |
888 | { | 901 | { |
889 | if ( mUndoIncidence ) delete mUndoIncidence; | 902 | clearUndo(); |
890 | mUndoIncidence = journal->clone(); | 903 | mUndoIncidence = journal; |
891 | mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); | ||
892 | if ( mJournalList.removeRef(journal) ) { | 904 | if ( mJournalList.removeRef(journal) ) { |
893 | setModified( true ); | 905 | setModified( true ); |
894 | } | 906 | } |
@@ -967,8 +979,7 @@ void CalendarLocal::setCalendarRemove( int id ) | |||
967 | } | 979 | } |
968 | } | 980 | } |
969 | 981 | ||
970 | if ( mUndoIncidence ) delete mUndoIncidence; | 982 | clearUndo(); |
971 | mUndoIncidence = 0; | ||
972 | 983 | ||
973 | } | 984 | } |
974 | 985 | ||
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a7a85c8..ae7e30c 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -69,6 +69,7 @@ class CalendarLocal : public Calendar | |||
69 | Clears out the current calendar, freeing all used memory etc. etc. | 69 | Clears out the current calendar, freeing all used memory etc. etc. |
70 | */ | 70 | */ |
71 | void close(); | 71 | void close(); |
72 | void clearUndo(); | ||
72 | 73 | ||
73 | void save() {} | 74 | void save() {} |
74 | 75 | ||
diff --git a/libkcal/journal.cpp b/libkcal/journal.cpp index c4e4474..328db46 100644 --- a/libkcal/journal.cpp +++ b/libkcal/journal.cpp | |||
@@ -24,12 +24,12 @@ using namespace KCal; | |||
24 | 24 | ||
25 | Journal::Journal() | 25 | Journal::Journal() |
26 | { | 26 | { |
27 | qDebug("New JJJ "); | 27 | |
28 | } | 28 | } |
29 | 29 | ||
30 | Journal::~Journal() | 30 | Journal::~Journal() |
31 | { | 31 | { |
32 | qDebug("delete JJJ "); | 32 | |
33 | } | 33 | } |
34 | 34 | ||
35 | Incidence *Journal::clone() | 35 | Incidence *Journal::clone() |