From d92f58ffa1937af8a4240b9d235da15f5f352769 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sun, 17 Oct 2004 16:06:42 +0000 Subject: KDE sync fixes --- diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp index 03571b9..755e792 100644 --- a/kde2file/caldump/main.cpp +++ b/kde2file/caldump/main.cpp @@ -165,38 +165,45 @@ int main( int argc, char *argv[] ) KCal::Incidence::List newInc = localCalendar->rawIncidences(); Incidence::List::ConstIterator it; for( it = newInc.begin(); it != newInc.end(); ++it ) { - Incidence* cl = (*it)->clone(); - Incidence *incOld = calendarResource->incidence( cl->uid() ); - ResourceCalendar * res = 0; - if ( incOld ) - res = calendarResource->resource( incOld ); - if ( res ) { - ++num; - if ( incOld->type() == "Journal" ) - calendarResource->deleteJournal( (Journal *) incOld ); - else if ( incOld->type() == "Todo" ) - calendarResource->deleteTodo( (Todo *) incOld ); - else if ( incOld->type() == "Event" ) - calendarResource->deleteEvent( (Event *) incOld ); - - if ( cl->type() == "Journal" ) - calendarResource->addJournal( (Journal *) cl, res ); - else if ( cl->type() == "Todo" ) - calendarResource->addTodo( (Todo *) cl, res ); - else if ( cl->type() == "Event" ) - calendarResource->addEvent( (Event *) cl, res ); - - } else { - if ( incOld ) { - qDebug("ERROR: no resource found for old incidence "); + if ( (*it)->pilotId() > 0 ) { //changed + Incidence* cl = (*it)->clone(); + Incidence *incOld = calendarResource->incidence( cl->uid() ); + ResourceCalendar * res = 0; + if ( incOld ) + res = calendarResource->resource( incOld ); + if ( res ) { + cl->setPilotId( incOld->pilotId() ); + ++num; if ( incOld->type() == "Journal" ) calendarResource->deleteJournal( (Journal *) incOld ); else if ( incOld->type() == "Todo" ) calendarResource->deleteTodo( (Todo *) incOld ); else if ( incOld->type() == "Event" ) calendarResource->deleteEvent( (Event *) incOld ); + + if ( cl->type() == "Journal" ) + calendarResource->addJournal( (Journal *) cl, res ); + else if ( cl->type() == "Todo" ) + calendarResource->addTodo( (Todo *) cl, res ); + else if ( cl->type() == "Event" ) + calendarResource->addEvent( (Event *) cl, res ); + + } else { + if ( incOld ) { + qDebug("ERROR: no resource found for old incidence "); + if ( incOld->type() == "Journal" ) + calendarResource->deleteJournal( (Journal *) incOld ); + else if ( incOld->type() == "Todo" ) + calendarResource->deleteTodo( (Todo *) incOld ); + else if ( incOld->type() == "Event" ) + calendarResource->deleteEvent( (Event *) incOld ); + } + calendarResource->addIncidence( cl ); + ++add; } + } else { // added + Incidence* cl = (*it)->clone(); calendarResource->addIncidence( cl ); ++add; } diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1f8ad5b..f727cd4 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -932,6 +932,11 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int QPtrList eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; local->resetTempSyncStat(); +#ifdef DESKTOP_VERSION + //Needed for KDE - OL sync + local->resetPilotStat(); + remote->resetPilotStat(); +#endif mLastCalendarSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastCalendarSync;; eventLSync = getLastSyncEvent(); @@ -1026,6 +1031,9 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) inR->setIDStr( idS ); remote->addIncidence( inR ); +#ifdef DESKTOP_VERSION + inR->setPilotId( 1 ); +#endif ++changedRemote; } else { if ( inR->revision() < maxrev ) diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index a3977d7..eeb5f48 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp @@ -248,6 +248,22 @@ QPtrList Calendar::incidences() return incidences; } + +void Calendar::resetPilotStat() +{ + QPtrList incidences; + + Incidence *i; + + QPtrList e = rawEvents(); + for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 ); + + QPtrList t = rawTodos(); + for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 ); + + QPtrList j = journals(); + for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 ); +} void Calendar::resetTempSyncStat() { QPtrList incidences; diff --git a/libkcal/calendar.h b/libkcal/calendar.h index c45d81f..d5294eb 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -67,6 +67,7 @@ public: virtual ~Calendar(); void deleteIncidence(Incidence *in); void resetTempSyncStat(); + void resetPilotStat(); /** Clears out the current calendar, freeing all used memory etc. */ -- cgit v0.9.0.2