From 56de219c5ce910a470a01a0e5003d1a113837ef4 Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 13 Jun 2005 13:57:22 +0000 Subject: fixxx --- (limited to 'libkcal') diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 0afa0a7..79e0464 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp @@ -371,6 +371,8 @@ 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 @@ -430,33 +430,33 @@ void Calendar::setupRelations( Incidence *incidence ) void Calendar::removeRelations( Incidence *incidence ) { // qDebug("Calendar::removeRelations "); - QString uid = incidence->uid(); - - QPtrList 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 it( mOrphans ); it.current(); ++it ) { - if( it.current()->uid() == uid ) { - mOrphans.remove( it.currentKey() ); - break; - } - } - } + QString uid = incidence->uid(); + + QPtrList 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 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 @@ -312,6 +312,7 @@ public: 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(); diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e48122a..749d9f6 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -85,15 +85,31 @@ void CalendarLocal::addCalendar( Calendar* cal ) QPtrList EventList = cal->rawEvents(); Event * ev = EventList.first(); while ( ev ) { + ev->unRegisterObserver( cal ); + ev->registerObserver( this ); mEventList.append( ev ); ev = EventList.next(); } } { + QPtrList 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(); } } @@ -101,10 +117,13 @@ void CalendarLocal::addCalendar( Calendar* cal ) QPtrList 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 ) { @@ -781,6 +800,42 @@ QPtrList CalendarLocal::journals() if ( it->calEnabled() ) el.append( it ); return el; } +void CalendarLocal::setCalendarRemove( int id ) +{ + + { + QPtrList EventList = mEventList; + Event * ev = EventList.first(); + while ( ev ) { + if ( ev->calID() == id ) + deleteEvent( ev ); + ev = EventList.next(); + } + } + { + + QPtrList TodoList = mTodoList; + Todo * ev = TodoList.first(); + while ( ev ) { + if ( ev->calID() == id ) + deleteTodo( ev ); + ev = TodoList.next(); + } + } + { + QPtrList 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 ) { @@ -818,6 +873,7 @@ void CalendarLocal::setAlarmEnabled( int id, bool 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 @@ -185,6 +185,7 @@ public slots: void setAlarmEnabled( int id, bool enable ); void setReadOnly( int id, bool enable ); void setDefaultCalendarEnabledOnly(); + void setCalendarRemove( int id ); protected: -- cgit v0.9.0.2