-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 25 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 2 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 1 |
5 files changed, 32 insertions, 5 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 14a1a45..95477cd 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -79,2 +79,3 @@ public: virtual bool mergeCalendarFile( QString name ) = 0; + virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; virtual void setSyncEventsReadOnly() = 0; 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,8 +128,21 @@ 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 ) { + if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { int calID = inL->calID(); @@ -136,2 +152,3 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) addIncidence( inL ); + } } else { @@ -145,2 +162,4 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) } + + bool CalendarLocal::addCalendarFile( QString name, int id ) diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 23b0542..a7a85c8 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -49,3 +49,3 @@ class CalendarLocal : public Calendar bool mergeCalendar( Calendar* cal ); - Incidence* incidenceForUid( const QString& uid ); + Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); void setSyncEventsReadOnly(); diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index dcead02..1a19f3e 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -36,2 +36,3 @@ IncidenceBase::IncidenceBase() : { + blockLastModified = false; setUid(CalFormat::createUniqueId()); @@ -55,2 +56,3 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) : + blockLastModified = false; mReadOnly = i.mReadOnly; @@ -151,4 +153,7 @@ void IncidenceBase::setCalID( int id ) { - if ( mCalID > 0 ) + if ( mCalID > 0 ) { + blockLastModified = true; updated(); + blockLastModified = false; + } mCalID = id; @@ -191,2 +196,3 @@ void IncidenceBase::setLastModified(const QDateTime &lm) { + if ( blockLastModified ) return; // DON'T! updated() because we call this from diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index bccf287..bed73db 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h @@ -152,2 +152,3 @@ class IncidenceBase : public CustomProperties protected: + bool blockLastModified; bool mIsTagged; |