-rw-r--r-- | libkcal/alarm.cpp | 2 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 54 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 56 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 1 |
5 files changed, 87 insertions, 27 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 0afa0a7..79e0464 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp @@ -372,4 +372,6 @@ QString Alarm::offsetText() if ( message.isEmpty() ) message = i18n("%1min").arg( 0 ); + if ( !mParent->alarmEnabled() ) + return "!"+message + i18n("(disabled)"); return message; } diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 5092d1a..a662eeb 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -431,31 +431,31 @@ void Calendar::removeRelations( Incidence *incidence ) { // qDebug("Calendar::removeRelations "); - QString uid = incidence->uid(); - - QPtrList<Incidence> relations = incidence->relations(); - for( Incidence* i = relations.first(); i; i = relations.next() ) - if( !mOrphanUids.find( i->uid() ) ) { - mOrphans.insert( uid, i ); - mOrphanUids.insert( i->uid(), i ); - i->setRelatedTo( 0 ); - i->setRelatedToUid( uid ); - } - - // If this incidence is related to something else, tell that about it - if( incidence->relatedTo() ) - incidence->relatedTo()->removeRelation( incidence ); - - // Remove this one from the orphans list - if( mOrphanUids.remove( uid ) ) - // This incidence is located in the orphans list - it should be removed - if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { - // Removing wasn't that easy - for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { - if( it.current()->uid() == uid ) { - mOrphans.remove( it.currentKey() ); - break; - } - } - } + QString uid = incidence->uid(); + + QPtrList<Incidence> relations = incidence->relations(); + for( Incidence* i = relations.first(); i; i = relations.next() ) + if( !mOrphanUids.find( i->uid() ) ) { + mOrphans.insert( uid, i ); + mOrphanUids.insert( i->uid(), i ); + i->setRelatedTo( 0 ); + i->setRelatedToUid( uid ); + } + + // If this incidence is related to something else, tell that about it + if( incidence->relatedTo() ) + incidence->relatedTo()->removeRelation( incidence ); + + // Remove this one from the orphans list + if( mOrphanUids.remove( uid ) ) + // This incidence is located in the orphans list - it should be removed + if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { + // Removing wasn't that easy + for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { + if( it.current()->uid() == uid ) { + mOrphans.remove( it.currentKey() ); + break; + } + } + } } diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 73f82bb..2243e28 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -313,4 +313,5 @@ public: virtual void setReadOnly( int id, bool enable ) = 0; virtual void setDefaultCalendarEnabledOnly() = 0; + virtual void setCalendarRemove( int id ) = 0; signals: void calendarChanged(); diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e48122a..749d9f6 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -86,4 +86,6 @@ void CalendarLocal::addCalendar( Calendar* cal ) Event * ev = EventList.first(); while ( ev ) { + ev->unRegisterObserver( cal ); + ev->registerObserver( this ); mEventList.append( ev ); ev = EventList.next(); @@ -91,8 +93,22 @@ void CalendarLocal::addCalendar( Calendar* cal ) } { + 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(); } @@ -102,8 +118,11 @@ void CalendarLocal::addCalendar( Calendar* cal ) 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 ) @@ -782,4 +801,40 @@ QPtrList<Journal> CalendarLocal::journals() 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 ) @@ -819,4 +874,5 @@ void CalendarLocal::setAlarmEnabled( int id, bool enable ) for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) if ( it->calID() == id ) it->setAlarmEnabled( enable ); + reInitAlarmSettings(); } diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 65f6aa7..5bbe55f 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -186,4 +186,5 @@ public slots: void setReadOnly( int id, bool enable ); void setDefaultCalendarEnabledOnly(); + void setCalendarRemove( int id ); protected: |