-rw-r--r-- | libkcal/calendarlocal.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 45e3128..2a57724 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -181,41 +181,51 @@ void CalendarLocal::setSyncEventsEnabled() if ( ev->uid().left(15) == QString("last-syncEvent-") ) ev->setCalEnabled( true ); ev = mEventList.next(); } } void CalendarLocal::setSyncEventsReadOnly() { Event * ev; ev = mEventList.first(); while ( ev ) { if ( ev->uid().left(15) == QString("last-syncEvent-") ) { ev->setReadOnly( true ); - ev->setCalID( 1 ); } ev = mEventList.next(); } } + void CalendarLocal::addCalendar( Calendar* cal ) { cal->setDontDeleteIncidencesOnClose(); + setSyncEventsEnabled(); { 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 ); + } ev->unRegisterObserver( cal ); ev->registerObserver( this ); mEventList.append( ev ); ev = EventList.next(); } + for ( ev = el.first(); ev; ev = el.next() ) { + deleteIncidence ( ev ); + } } { QPtrList<Todo> TodoList = cal->rawTodos(); Todo * ev = TodoList.first(); while ( ev ) { QString rel = ev->relatedToUid(); if ( !rel.isEmpty() ){ ev->setRelatedTo ( 0 ); ev->setRelatedToUid( rel ); } ev = TodoList.next(); @@ -994,24 +1004,37 @@ void CalendarLocal::setCalendarRemove( int id ) Journal * ev = JournalList.first(); while ( ev ) { if ( ev->calID() == id ) deleteJournal( ev ); ev = JournalList.next(); } } clearUndo(0); } +void CalendarLocal::setAllCalendarEnabled( bool enable ) +{ + for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) + it->setCalEnabled( enable ); + + for ( Event *it = mEventList.first(); it; it = mEventList.next() ) + it->setCalEnabled( enable ); + + for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) + it->setCalEnabled( enable ); + + +} void CalendarLocal::setCalendarEnabled( int id, bool enable ) { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calID() == id ) it->setCalEnabled( enable ); for ( Event *it = mEventList.first(); it; it = mEventList.next() ) if ( it->calID() == id ) it->setCalEnabled( enable ); for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) if ( it->calID() == id ) it->setCalEnabled( enable ); } |