summaryrefslogtreecommitdiffabout
path: root/libkcal/calendarlocal.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/calendarlocal.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendarlocal.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index e48122a..749d9f6 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -76,44 +76,63 @@ bool CalendarLocal::addCalendarFile( QString name, int id )
addCalendar( &calendar );
return true;
}
return false;
}
void CalendarLocal::addCalendar( Calendar* cal )
{
cal->setDontDeleteIncidencesOnClose();
{
QPtrList<Event> EventList = cal->rawEvents();
Event * ev = EventList.first();
while ( ev ) {
+ ev->unRegisterObserver( cal );
+ ev->registerObserver( this );
mEventList.append( ev );
ev = EventList.next();
}
}
{
+
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();
+ }
+ //TodoList = cal->rawTodos();
+ ev = TodoList.first();
+ while ( ev ) {
+ ev->unRegisterObserver( cal );
+ ev->registerObserver( this );
mTodoList.append( ev );
+ setupRelations( ev );
ev = TodoList.next();
}
}
{
QPtrList<Journal> JournalList = cal->journals();
Journal * ev = JournalList.first();
while ( ev ) {
+ ev->unRegisterObserver( cal );
+ ev->registerObserver( this );
mJournalList.append( ev );
ev = JournalList.next();
}
}
+ setModified( true );
}
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();
}
@@ -772,24 +791,60 @@ Journal *CalendarLocal::journal( const QString &uid )
return it;
return 0;
}
QPtrList<Journal> CalendarLocal::journals()
{
QPtrList<Journal> el;
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
if ( it->calEnabled() ) el.append( it );
return el;
}
+void CalendarLocal::setCalendarRemove( int id )
+{
+
+ {
+ QPtrList<Event> EventList = mEventList;
+ Event * ev = EventList.first();
+ while ( ev ) {
+ if ( ev->calID() == id )
+ deleteEvent( ev );
+ ev = EventList.next();
+ }
+ }
+ {
+
+ QPtrList<Todo> TodoList = mTodoList;
+ Todo * ev = TodoList.first();
+ while ( ev ) {
+ if ( ev->calID() == id )
+ deleteTodo( ev );
+ ev = TodoList.next();
+ }
+ }
+ {
+ QPtrList<Journal> JournalList = mJournalList;
+ Journal * ev = JournalList.first();
+ while ( ev ) {
+ if ( ev->calID() == id )
+ deleteJournal( ev );
+ ev = JournalList.next();
+ }
+ }
+
+ if ( mUndoIncidence ) delete mUndoIncidence;
+ mUndoIncidence = 0;
+
+}
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 );
@@ -809,24 +864,25 @@ void CalendarLocal::setReadOnly( int id, bool 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 );
+ reInitAlarmSettings();
}
void CalendarLocal::setDefaultCalendarEnabledOnly()
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
it->setCalEnabled( it->calID() == mDefaultCalendar );
for ( Event *it = mEventList.first(); it; it = mEventList.next() )
it->setCalEnabled( it->calID() == mDefaultCalendar);
for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
it->setCalEnabled( it->calID() == mDefaultCalendar);