author | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
commit | e08811c2246f63b2b63f9db6b65701344460f3d7 (patch) (side-by-side diff) | |
tree | d450f486a9472d80eb86f605237b828a0e7ffae6 | |
parent | 854d4a0c686962cd73ac7418b5fbf4b2d73adab7 (diff) | |
download | kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.zip kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.gz kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.bz2 |
ync
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 9 | ||||
-rw-r--r-- | libkcal/calendar.h | 3 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 81 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 3 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 6 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
7 files changed, 99 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d024c1..1800cf2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1603,8 +1603,9 @@ void CalendarView::checkExternalId( Incidence * inc ) QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; checkExternSyncEvent( lastSync, inc ); } +// SSSSSSSSSSSSSSSSSSSSSS bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) { bool syncOK = true; @@ -1722,10 +1723,17 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int skipIncidence = true; QString idS; qApp->processEvents(); if ( !skipIncidence ) { - inL = local->incidenceForUid( uid , false , true ); + int hasCalId = 0; + inL = local->incidenceForUid( uid , false , true, &hasCalId ); + if ( hasCalId && !inL ) + inL = local->incidenceForUid( uid , false , true, &hasCalId ); + else + hasCalId = 0; if ( inL ) { // maybe conflict - same uid in both calendars + if ( hasCalId ) + qDebug("KO: Cal id %d conflict detected: %s ", hasCalId, inL->summary().latin1()); if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { //qDebug("take %d %s ", take, inL->summary().latin1()); if ( take == 3 ) return false; @@ -1749,8 +1757,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( !inL->isReadOnly() ) { idS = inL->IDStr(); int pid = inL->pilotId(); int calID = inL->calID(); + if ( hasCalId ) + calID = hasCalId; local->deleteIncidence( inL ); inL = inR->clone(); inL->setCalID_block( calID ); if ( mSyncManager->syncWithDesktop() ) @@ -1763,8 +1773,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int local->addIncidence( inL ); ++changedLocal; } } + } else { + // take == 0; events equal + if ( hasCalId ) + qDebug("EV EQUALLLL **************************** "); + } } else { // no conflict ********** add or delete remote if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 8535191..1350f6d 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -6,9 +6,8 @@ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. @@ -419,27 +418,31 @@ QPtrList<Todo> Calendar::todos() // This method is only about linking related todos void Calendar::setupRelations( Incidence *incidence ) { QString uid = incidence->uid(); - //qDebug("Calendar::setupRelations "); + //qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); // First, go over the list of orphans and see if this is their parent while( Incidence* i = mOrphans[ uid ] ) { mOrphans.remove( uid ); i->setRelatedTo( incidence ); + //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); incidence->addRelation( i ); mOrphanUids.remove( i->uid() ); } // Now see about this incidences parent if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { // This incidence has a uid it is related to, but is not registered to it yet // Try to find it - Incidence* parent = this->incidence( incidence->relatedToUid() ); + //qDebug("Test parent for %s", incidence->summary().latin1()); + Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); if( parent ) { // Found it + // qDebug("parent found for for %s", incidence->summary().latin1()); incidence->setRelatedTo( parent ); parent->addRelation( incidence ); } else { + // qDebug("NO parent found for for %s", incidence->summary().latin1()); // Not found, put this in the mOrphans list mOrphans.insert( incidence->relatedToUid(), incidence ); mOrphanUids.insert( incidence->uid(), incidence ); } diff --git a/libkcal/calendar.h b/libkcal/calendar.h index f301768..fbc40ad 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -76,9 +76,10 @@ public: virtual void close() = 0; virtual void addCalendar( Calendar* ) = 0; virtual bool addCalendarFile( QString name, int id ) = 0; virtual bool mergeCalendarFile( QString name ) = 0; - virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ) = 0; + virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ,int * isDup = 0 ) = 0; + virtual Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0) = 0; virtual void setSyncEventsReadOnly() = 0; virtual void setSyncEventsEnabled() = 0; virtual void stopAllTodos() = 0; virtual void clearUndo( Incidence * newUndo ); diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index ad8ace3..980663f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -78,38 +78,77 @@ bool CalendarLocal::mergeCalendarFile( QString name ) return true; } 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 { retVal = todo; } } } + 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 { retVal = event; @@ -118,14 +157,26 @@ 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 { retVal = it; @@ -232,13 +283,9 @@ 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->resetRelatedTo(); ev = TodoList.next(); } //TodoList = cal->rawTodos(); ev = TodoList.first(); @@ -411,15 +458,19 @@ bool CalendarLocal::addTodo( Todo *todo ) } void CalendarLocal::deleteTodo( Todo *todo ) { + QString uid = todo->uid(); // Handle orphaned children removeRelations( todo ); clearUndo(todo); if ( mTodoList.removeRef( todo ) ) { setModified( true ); } + Todo* dup = todoForUid( uid ); + if ( dup ) + setupRelations( dup ); } QPtrList<Todo> CalendarLocal::rawTodos() { diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index b611704..1ceabce 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -46,9 +46,10 @@ class CalendarLocal : public Calendar void addCalendar( Calendar* ); bool addCalendarFile( QString name, int id ); bool mergeCalendarFile( QString name ); bool mergeCalendar( Calendar* cal ); - Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false ); + Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false,int * isDup = 0 ); + Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0 ); void setSyncEventsReadOnly(); void setSyncEventsEnabled(); void stopAllTodos(); /** diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index fe9f854..7dd9bd2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp @@ -519,8 +519,14 @@ void Incidence::clearRelations() QString Incidence::relatedToUid() const { return mRelatedToUid; } +void Incidence::resetRelatedTo() +{ + QString store = mRelatedToUid; + setRelatedTo( 0 ); + mRelatedToUid = store; +} void Incidence::setRelatedTo(Incidence *relatedTo) { //qDebug("Incidence::setRelatedTo %d ", relatedTo); diff --git a/libkcal/incidence.h b/libkcal/incidence.h index dc49640..f89942f 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h @@ -172,8 +172,9 @@ class Incidence : public IncidenceBase * exists. */ QString relatedToUid() const; /** point at some other event to which the event relates */ void setRelatedTo(Incidence *relatedTo); + void resetRelatedTo(); /** what event does this one relate to? */ Incidence *relatedTo() const; /** All events that are related to this event */ QPtrList<Incidence> relations() const; |