From e08811c2246f63b2b63f9db6b65701344460f3d7 Mon Sep 17 00:00:00 2001 From: zautrix Date: Mon, 28 Nov 2005 01:23:02 +0000 Subject: ync --- (limited to 'libkcal/calendarlocal.cpp') diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index ad8ace3..980663f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -79,19 +79,35 @@ bool CalendarLocal::mergeCalendarFile( QString name ) } return false; } - -Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly ) + +Todo* CalendarLocal::todoForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly,int * isDup ) { + + int calID = 0; + if ( isDup && *isDup > 0 ) + calID = *isDup; Todo *todo;; - Incidence *retVal = 0; + Todo *retVal = 0; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->uid() == uid ) { - if ( enabledOnly ) - if ( !todo->calEnabled() ) + if( calID ) { + if ( todo->calID() != calID ) continue; + } + else { + if ( enabledOnly ) { + if ( !todo->calEnabled() ) { + if ( isDup ) + *isDup = todo->calID(); + continue; + } + } + } if ( doNotCheckDuplicates ) return todo; if ( retVal ) { if ( retVal->calID() > todo->calID() ) { + if ( isDup ) + *isDup = retVal->calID(); retVal = todo; } } else { @@ -99,16 +115,39 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD } } } + return retVal; +} +//if ( isDup) and * isDup == 0: store duplicate found cal id in isDup +//if ( isDup) and * isDup > 0: search only in calendar with ID *isDup, ignore enabledOnly + +Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly, int * isDup ) +{ + int calID = 0; + if ( isDup && *isDup > 0 ) + calID = *isDup; + Incidence *retVal = todoForUid( uid , doNotCheckDuplicates,enabledOnly, isDup ); if ( retVal ) return retVal; Event *event; for ( event = mEventList.first(); event; event = mEventList.next() ) { if ( event->uid() == uid ) { - if ( enabledOnly ) - if ( !event->calEnabled() ) + if( calID ) { + if ( event->calID() != calID ) continue; + } + else { + if ( enabledOnly ) { + if ( !event->calEnabled() ) { + if ( isDup ) + *isDup =event->calID() ; + continue; + } + } + } if ( doNotCheckDuplicates ) return event; if ( retVal ) { if ( retVal->calID() > event->calID() ) { + if ( isDup ) + *isDup = retVal->calID(); retVal = event; } } else { @@ -119,12 +158,24 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD if ( retVal ) return retVal; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->uid() == uid ) { - if ( enabledOnly ) - if ( !it->calEnabled() ) + if( calID ) { + if ( event->calID() != calID ) continue; + } + else { + if ( enabledOnly ) { + if ( !it->calEnabled() ) { + if ( isDup ) + *isDup = it->calID(); + continue; + } + } + } if ( doNotCheckDuplicates ) return it; if ( retVal ) { - if ( retVal->calID() > it->calID() ) { + if ( retVal->calID() > it->calID() ) { + if ( isDup ) + *isDup = retVal->calID(); retVal = it; } } else { @@ -233,11 +284,7 @@ void CalendarLocal::addCalendar( Calendar* cal ) QPtrList TodoList = cal->rawTodos(); Todo * ev = TodoList.first(); while ( ev ) { - QString rel = ev->relatedToUid(); - if ( !rel.isEmpty() ){ - ev->setRelatedTo ( 0 ); - ev->setRelatedToUid( rel ); - } + ev->resetRelatedTo(); ev = TodoList.next(); } //TodoList = cal->rawTodos(); @@ -412,6 +459,7 @@ bool CalendarLocal::addTodo( Todo *todo ) void CalendarLocal::deleteTodo( Todo *todo ) { + QString uid = todo->uid(); // Handle orphaned children removeRelations( todo ); clearUndo(todo); @@ -419,6 +467,9 @@ void CalendarLocal::deleteTodo( Todo *todo ) if ( mTodoList.removeRef( todo ) ) { setModified( true ); } + Todo* dup = todoForUid( uid ); + if ( dup ) + setupRelations( dup ); } QPtrList CalendarLocal::rawTodos() -- cgit v0.9.0.2