-rw-r--r-- | libkcal/calendarlocal.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 5baa7dc..e8c969f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -265,13 +265,26 @@ void CalendarLocal::close() | |||
265 | mEventList.setAutoDelete( false ); | 265 | mEventList.setAutoDelete( false ); |
266 | mTodoList.setAutoDelete( false ); | 266 | mTodoList.setAutoDelete( false ); |
267 | mJournalList.setAutoDelete( false ); | 267 | mJournalList.setAutoDelete( false ); |
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; |
275 | bool isBirthday = true; | 288 | bool isBirthday = true; |
276 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 289 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
277 | isBirthday = false; | 290 | isBirthday = false; |
@@ -324,14 +337,14 @@ bool CalendarLocal::addEvent( Event *event ) | |||
324 | 337 | ||
325 | return true; | 338 | return true; |
326 | } | 339 | } |
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 | } |
335 | } | 348 | } |
336 | 349 | ||
337 | 350 | ||
@@ -379,15 +392,15 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
379 | return true; | 392 | return true; |
380 | } | 393 | } |
381 | 394 | ||
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 ); |
391 | } | 404 | } |
392 | } | 405 | } |
393 | 406 | ||
@@ -883,15 +896,14 @@ bool CalendarLocal::addJournal(Journal *journal) | |||
883 | journal->setCalEnabled( true ); | 896 | journal->setCalEnabled( true ); |
884 | return true; | 897 | return true; |
885 | } | 898 | } |
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 | } |
895 | } | 907 | } |
896 | 908 | ||
897 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | 909 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) |
@@ -964,14 +976,13 @@ void CalendarLocal::setCalendarRemove( int id ) | |||
964 | if ( ev->calID() == id ) | 976 | if ( ev->calID() == id ) |
965 | deleteJournal( ev ); | 977 | deleteJournal( ev ); |
966 | ev = JournalList.next(); | 978 | ev = JournalList.next(); |
967 | } | 979 | } |
968 | } | 980 | } |
969 | 981 | ||
970 | if ( mUndoIncidence ) delete mUndoIncidence; | 982 | clearUndo(); |
971 | mUndoIncidence = 0; | ||
972 | 983 | ||
973 | } | 984 | } |
974 | 985 | ||
975 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 986 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
976 | { | 987 | { |
977 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 988 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |