-rw-r--r-- | libkcal/calendarlocal.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3e42ec0..e37a7ad 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -81,3 +81,3 @@ bool CalendarLocal::mergeCalendarFile( QString name ) -Incidence* CalendarLocal::incidenceForUid( const QString& uid ) +Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) { @@ -87,2 +87,3 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) if ( todo->uid() == uid ) { + if ( doNotCheckDuplicates ) return todo; if ( retVal ) { @@ -100,2 +101,3 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) if ( event->uid() == uid ) { + if ( doNotCheckDuplicates ) return event; if ( retVal ) { @@ -112,2 +114,3 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) if ( it->uid() == uid ) { + if ( doNotCheckDuplicates ) return it; if ( retVal ) { @@ -125,13 +128,27 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) { + // 1 look for raw inc in local + // if inc not in remote, delete in local + // 2 look for raw inc in remote + // if inc in local, replace it + // if not in local, add it to default calendar + QPtrList<Incidence> localInc = rawIncidences(); + Incidence* inL = localInc.first(); + while ( inL ) { + if ( ! inL->isReadOnly () ) + if ( !remote->incidenceForUid( inL->uid(), true )) + deleteIncidence( inL ); + inL = localInc.next(); + } QPtrList<Incidence> er = remote->rawIncidences(); Incidence* inR = er.first(); - Incidence* inL; while ( inR ) { - inL = incidenceForUid( inR->uid() ); + inL = incidenceForUid( inR->uid(),false ); if ( inL ) { - int calID = inL->calID(); - deleteIncidence( inL ); - inL = inR->clone(); - inL->setCalID( calID ); - addIncidence( inL ); + if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { + int calID = inL->calID(); + deleteIncidence( inL ); + inL = inR->clone(); + inL->setCalID( calID ); + addIncidence( inL ); + } } else { @@ -145,2 +162,4 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) } + + bool CalendarLocal::addCalendarFile( QString name, int id ) |