-rw-r--r-- | libkcal/calendarlocal.cpp | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index c5500bf..e48122a 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -52,35 +52,73 @@ CalendarLocal::CalendarLocal() } CalendarLocal::CalendarLocal(const QString &timeZoneId) : Calendar(timeZoneId) { init(); } void CalendarLocal::init() { mNextAlarmIncidence = 0; } CalendarLocal::~CalendarLocal() { + 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 ) { FileStorage storage( this, fileName ); return storage.load(); } bool CalendarLocal::save( const QString &fileName, CalFormat *format ) { FileStorage storage( this, fileName, format ); return storage.save(); } void CalendarLocal::close() { Todo * i; @@ -743,32 +781,46 @@ QPtrList<Journal> CalendarLocal::journals() if ( it->calEnabled() ) el.append( it ); return el; } 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 ); } + +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 ) { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); for ( Event *it = mEventList.first(); it; it = mEventList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); } void CalendarLocal::setDefaultCalendarEnabledOnly() { for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) it->setCalEnabled( it->calID() == mDefaultCalendar ); |