-rw-r--r-- | libkcal/calendarlocal.cpp | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index c5500bf..e48122a 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -67,5 +67,43 @@ CalendarLocal::~CalendarLocal() { - close(); + if ( mDeleteIncidencesOnClose ) + close(); +} +bool CalendarLocal::addCalendarFile( QString name, int id ) +{ + CalendarLocal calendar( timeZoneId() ); + calendar.setDefaultCalendar( id ); + if ( calendar.load( name ) ) { + addCalendar( &calendar ); + return true; + } + return false; +} +void CalendarLocal::addCalendar( Calendar* cal ) +{ + cal->setDontDeleteIncidencesOnClose(); + { + QPtrList<Event> EventList = cal->rawEvents(); + Event * ev = EventList.first(); + while ( ev ) { + mEventList.append( ev ); + ev = EventList.next(); + } + } + { + QPtrList<Todo> TodoList = cal->rawTodos(); + Todo * ev = TodoList.first(); + while ( ev ) { + mTodoList.append( ev ); + ev = TodoList.next(); + } + } + { + QPtrList<Journal> JournalList = cal->journals(); + Journal * ev = JournalList.first(); + while ( ev ) { + mJournalList.append( ev ); + ev = JournalList.next(); + } + } } - bool CalendarLocal::load( const QString &fileName ) @@ -758,2 +796,16 @@ void CalendarLocal::setCalendarEnabled( int id, bool enable ) } + +void CalendarLocal::setReadOnly( int id, bool enable ) +{ + for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) + if ( it->calID() == id ) it->setReadOnly( enable ); + + for ( Event *it = mEventList.first(); it; it = mEventList.next() ) + if ( it->calID() == id ) it->setReadOnly( enable ); + + for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) + if ( it->calID() == id ) it->setReadOnly( enable ); + +} + void CalendarLocal::setAlarmEnabled( int id, bool enable ) |