-rw-r--r-- | libkcal/calendarlocal.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 980663f..8a5a76f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -259,25 +259,23 @@ void CalendarLocal::addCalendar( Calendar* cal ) { cal->setDontDeleteIncidencesOnClose(); setSyncEventsEnabled(); + QPtrList<Incidence> incList; { QPtrList<Event> EventList = cal->rawEvents(); - QPtrList<Event> el; Event * ev = EventList.first(); while ( ev ) { - if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { - Event * se = event( ev->uid() ); - if ( se ) - el.append( se ); + if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { ev->setCalID_block( 1 ); } + Event * se = event( ev->uid() ); + if ( se ) + incList.append( se ); ev->unRegisterObserver( cal ); ev->registerObserver( this ); mEventList.append( ev ); ev = EventList.next(); } - for ( ev = el.first(); ev; ev = el.next() ) { - deleteIncidence ( ev ); - } + } { @@ -289,7 +287,10 @@ void CalendarLocal::addCalendar( Calendar* cal ) } //TodoList = cal->rawTodos(); ev = TodoList.first(); - while ( ev ) { + while ( ev ) { + Todo * se = todo( ev->uid() ); + if ( se ) + incList.append( se ); ev->unRegisterObserver( cal ); ev->registerObserver( this ); mTodoList.append( ev ); @@ -301,12 +302,20 @@ void CalendarLocal::addCalendar( Calendar* cal ) QPtrList<Journal> JournalList = cal->journals(); Journal * ev = JournalList.first(); while ( ev ) { + Journal * se = journal( ev->uid() ); + if ( se ) + incList.append( se ); ev->unRegisterObserver( cal ); ev->registerObserver( this ); mJournalList.append( ev ); ev = JournalList.next(); } } + { + for (Incidence * ev = incList.first(); ev; ev = incList.next() ) { + deleteIncidence ( ev ); + } + } setModified( true ); } bool CalendarLocal::load( const QString &fileName ) |