-rw-r--r-- | libkcal/calendarlocal.cpp | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e8c969f..1a1c6be 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -263,30 +263,17 @@ void CalendarLocal::close() | |||
263 | mJournalList.clear(); | 263 | mJournalList.clear(); |
264 | 264 | ||
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 | void CalendarLocal::clearUndo() | 271 | |
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 | } | ||
285 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 272 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
286 | { | 273 | { |
287 | QString cat; | 274 | QString cat; |
288 | bool isBirthday = true; | 275 | bool isBirthday = true; |
289 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 276 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
290 | isBirthday = false; | 277 | isBirthday = false; |
291 | cat = i18n( "Anniversary" ); | 278 | cat = i18n( "Anniversary" ); |
292 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { | 279 | } else if( event->categoriesStr() == i18n( "Birthday" ) ) { |
@@ -335,18 +322,17 @@ bool CalendarLocal::addEvent( Event *event ) | |||
335 | event->setCalID( mDefaultCalendar ); | 322 | event->setCalID( mDefaultCalendar ); |
336 | event->setCalEnabled( true ); | 323 | event->setCalEnabled( true ); |
337 | 324 | ||
338 | return true; | 325 | return true; |
339 | } | 326 | } |
340 | 327 | ||
341 | void CalendarLocal::deleteEvent( Event *event ) | 328 | void CalendarLocal::deleteEvent( Event *event ) |
342 | { | 329 | { |
343 | clearUndo(); | 330 | clearUndo(event); |
344 | mUndoIncidence = event; | ||
345 | if ( mEventList.removeRef( event ) ) { | 331 | if ( mEventList.removeRef( event ) ) { |
346 | setModified( true ); | 332 | setModified( true ); |
347 | } | 333 | } |
348 | } | 334 | } |
349 | 335 | ||
350 | 336 | ||
351 | Event *CalendarLocal::event( const QString &uid ) | 337 | Event *CalendarLocal::event( const QString &uid ) |
352 | { | 338 | { |
@@ -390,19 +376,18 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
390 | todo->setCalID( mDefaultCalendar ); | 376 | todo->setCalID( mDefaultCalendar ); |
391 | todo->setCalEnabled( true ); | 377 | todo->setCalEnabled( true ); |
392 | return true; | 378 | return true; |
393 | } | 379 | } |
394 | 380 | ||
395 | void CalendarLocal::deleteTodo( Todo *todo ) | 381 | void CalendarLocal::deleteTodo( Todo *todo ) |
396 | { | 382 | { |
397 | // Handle orphaned children | 383 | // Handle orphaned children |
398 | clearUndo(); | ||
399 | removeRelations( todo ); | 384 | removeRelations( todo ); |
400 | mUndoIncidence = todo; | 385 | clearUndo(todo); |
401 | 386 | ||
402 | if ( mTodoList.removeRef( todo ) ) { | 387 | if ( mTodoList.removeRef( todo ) ) { |
403 | setModified( true ); | 388 | setModified( true ); |
404 | } | 389 | } |
405 | } | 390 | } |
406 | 391 | ||
407 | QPtrList<Todo> CalendarLocal::rawTodos() | 392 | QPtrList<Todo> CalendarLocal::rawTodos() |
408 | { | 393 | { |
@@ -894,18 +879,17 @@ bool CalendarLocal::addJournal(Journal *journal) | |||
894 | if ( journal->calID() == 0 ) | 879 | if ( journal->calID() == 0 ) |
895 | journal->setCalID( mDefaultCalendar ); | 880 | journal->setCalID( mDefaultCalendar ); |
896 | journal->setCalEnabled( true ); | 881 | journal->setCalEnabled( true ); |
897 | return true; | 882 | return true; |
898 | } | 883 | } |
899 | 884 | ||
900 | void CalendarLocal::deleteJournal( Journal *journal ) | 885 | void CalendarLocal::deleteJournal( Journal *journal ) |
901 | { | 886 | { |
902 | clearUndo(); | 887 | clearUndo(journal); |
903 | mUndoIncidence = journal; | ||
904 | if ( mJournalList.removeRef(journal) ) { | 888 | if ( mJournalList.removeRef(journal) ) { |
905 | setModified( true ); | 889 | setModified( true ); |
906 | } | 890 | } |
907 | } | 891 | } |
908 | 892 | ||
909 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) | 893 | QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) |
910 | { | 894 | { |
911 | QPtrList<Journal> el; | 895 | QPtrList<Journal> el; |
@@ -974,17 +958,17 @@ void CalendarLocal::setCalendarRemove( int id ) | |||
974 | Journal * ev = JournalList.first(); | 958 | Journal * ev = JournalList.first(); |
975 | while ( ev ) { | 959 | while ( ev ) { |
976 | if ( ev->calID() == id ) | 960 | if ( ev->calID() == id ) |
977 | deleteJournal( ev ); | 961 | deleteJournal( ev ); |
978 | ev = JournalList.next(); | 962 | ev = JournalList.next(); |
979 | } | 963 | } |
980 | } | 964 | } |
981 | 965 | ||
982 | clearUndo(); | 966 | clearUndo(0); |
983 | 967 | ||
984 | } | 968 | } |
985 | 969 | ||
986 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) | 970 | void CalendarLocal::setCalendarEnabled( int id, bool enable ) |
987 | { | 971 | { |
988 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 972 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
989 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 973 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
990 | 974 | ||