-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 @@ -370,8 +370,10 @@ QString Alarm::offsetText() message += i18n("%1min").arg( min ); } 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 @@ -429,35 +429,35 @@ void Calendar::setupRelations( Incidence *incidence ) // If a task with subtasks is deleted, move it's subtasks to the orphans list 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; + } + } + } } void Calendar::registerObserver( Observer *observer ) { diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 73f82bb..2243e28 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -311,8 +311,9 @@ public: virtual void setCalendarEnabled( int id, bool enable ) = 0; virtual void setAlarmEnabled( int id, bool enable ) = 0; virtual void setReadOnly( int id, bool enable ) = 0; virtual void setDefaultCalendarEnabledOnly() = 0; + virtual void setCalendarRemove( int id ) = 0; signals: void calendarChanged(); void calendarSaved(); void calendarLoaded(); diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e48122a..749d9f6 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -84,28 +84,47 @@ void CalendarLocal::addCalendar( Calendar* cal ) { 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 ); @@ -780,8 +799,44 @@ QPtrList<Journal> CalendarLocal::journals() 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() ) @@ -817,8 +872,9 @@ void CalendarLocal::setAlarmEnabled( int id, bool enable ) 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() { diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 65f6aa7..5bbe55f 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -184,8 +184,9 @@ public slots: void setCalendarEnabled( int id, bool enable ); void setAlarmEnabled( int id, bool enable ); void setReadOnly( int id, bool enable ); void setDefaultCalendarEnabledOnly(); + void setCalendarRemove( int id ); protected: // Event* mNextAlarmEvent; |