From b51db424f4b1e558ab8c7c723859bb564c99d83b Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 09 Jul 2005 10:40:57 +0000 Subject: fixxx --- diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ccacc52..a350c3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1224,14 +1224,14 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b return 2; break; case SYNC_PREF_ASK: - //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); + qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); if ( lastSync > remoteMod && lastSync > localMod) return 0; if ( lastSync > remoteMod ) return 1; if ( lastSync > localMod ) return 2; - //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); + qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); localIsNew = localMod >= remoteMod; if ( localIsNew ) getEventViewerDialog()->setColorMode( 1 ); @@ -1359,6 +1359,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int eventLSync = getLastSyncEvent(); eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); if ( eventR ) { + qDebug("last-syncEvent on remote found "); eventRSync = (Event*) eventR->clone(); remote->deleteEvent(eventR ); @@ -1381,7 +1382,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( ! fullDateRange ) { if ( eventLSync->dtStart() != eventRSync->dtStart() ) { - // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); + qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); fullDateRange = true; } diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 14a1a45..95477cd 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -77,6 +77,7 @@ public: 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 ) = 0; virtual void setSyncEventsReadOnly() = 0; virtual void stopAllTodos() = 0; diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3e42ec0..e37a7ad 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -79,12 +79,13 @@ bool CalendarLocal::mergeCalendarFile( QString name ) return false; } -Incidence* CalendarLocal::incidenceForUid( const QString& uid ) +Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) { Todo *todo;; Incidence *retVal = 0; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->uid() == uid ) { + if ( doNotCheckDuplicates ) return todo; if ( retVal ) { if ( retVal->calID() > todo->calID() ) { retVal = todo; @@ -98,6 +99,7 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) Event *event; for ( event = mEventList.first(); event; event = mEventList.next() ) { if ( event->uid() == uid ) { + if ( doNotCheckDuplicates ) return event; if ( retVal ) { if ( retVal->calID() > event->calID() ) { retVal = event; @@ -110,6 +112,7 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) if ( retVal ) return retVal; for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) if ( it->uid() == uid ) { + if ( doNotCheckDuplicates ) return it; if ( retVal ) { if ( retVal->calID() > it->calID() ) { retVal = it; @@ -123,17 +126,31 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) 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 localInc = rawIncidences(); + Incidence* inL = localInc.first(); + while ( inL ) { + if ( ! inL->isReadOnly () ) + if ( !remote->incidenceForUid( inL->uid(), true )) + deleteIncidence( inL ); + inL = localInc.next(); + } QPtrList 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 { inL = inR->clone(); inL->setCalID( 0 );// add to default cal @@ -143,6 +160,8 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) } return true; } + + bool CalendarLocal::addCalendarFile( QString name, int id ) { CalendarLocal calendar( timeZoneId() ); diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 23b0542..a7a85c8 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -47,7 +47,7 @@ class CalendarLocal : public Calendar bool addCalendarFile( QString name, int id ); bool mergeCalendarFile( QString name ); bool mergeCalendar( Calendar* cal ); - Incidence* incidenceForUid( const QString& uid ); + Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); void setSyncEventsReadOnly(); void stopAllTodos(); /** diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index dcead02..1a19f3e 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp @@ -34,6 +34,7 @@ IncidenceBase::IncidenceBase() : mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), mPilotId(0), mSyncStatus(SYNCMOD) { + blockLastModified = false; setUid(CalFormat::createUniqueId()); mOrganizer = ""; mFloats = false; @@ -53,6 +54,7 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) : CustomProperties( i ) { + blockLastModified = false; mReadOnly = i.mReadOnly; mDtStart = i.mDtStart; mDuration = i.mDuration; @@ -149,8 +151,11 @@ void IncidenceBase::setTagged( bool b) } void IncidenceBase::setCalID( int id ) { - if ( mCalID > 0 ) + if ( mCalID > 0 ) { + blockLastModified = true; updated(); + blockLastModified = false; + } mCalID = id; } int IncidenceBase::calID() const @@ -189,6 +194,7 @@ QString IncidenceBase::uid() const void IncidenceBase::setLastModified(const QDateTime &lm) { + if ( blockLastModified ) return; // DON'T! updated() because we call this from // Calendar::updateEvent(). mLastModified = getEvenTime(lm); diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index bccf287..bed73db 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h @@ -150,6 +150,7 @@ class IncidenceBase : public CustomProperties bool isTagged() const; void setTagged( bool ); protected: + bool blockLastModified; bool mIsTagged; QDateTime mDtStart; bool mReadOnly; -- cgit v0.9.0.2