author | zautrix <zautrix> | 2005-11-28 03:27:16 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 03:27:16 (UTC) |
commit | b7522a13b64225bb91bdab4a21b44282f8c3e3b4 (patch) (unidiff) | |
tree | 3aa005036dd83f3d0e5f57dd398dc260666daea1 | |
parent | 084180efc1bccba341bf3f2f718fd10cdfdaf18e (diff) | |
download | kdepimpi-b7522a13b64225bb91bdab4a21b44282f8c3e3b4.zip kdepimpi-b7522a13b64225bb91bdab4a21b44282f8c3e3b4.tar.gz kdepimpi-b7522a13b64225bb91bdab4a21b44282f8c3e3b4.tar.bz2 |
sync
-rw-r--r-- | korganizer/calendarview.cpp | 44 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 27 |
2 files changed, 41 insertions, 30 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 1800cf2..8385bcc 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1731,8 +1731,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1731 | else | 1731 | else |
1732 | hasCalId = 0; | 1732 | hasCalId = 0; |
1733 | if ( inL ) { // maybe conflict - same uid in both calendars | 1733 | if ( inL ) { // maybe conflict - same uid in both calendars |
1734 | if ( hasCalId ) | 1734 | |
1735 | qDebug("KO: Cal id %d conflict detected: %s ", hasCalId, inL->summary().latin1()); | ||
1736 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1735 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1737 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1736 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1738 | if ( take == 3 ) | 1737 | if ( take == 3 ) |
@@ -1744,22 +1743,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1744 | idS = inR->IDStr(); | 1743 | idS = inR->IDStr(); |
1745 | int calID = inR->calID(); | 1744 | int calID = inR->calID(); |
1746 | remote->deleteIncidence( inR ); | 1745 | remote->deleteIncidence( inR ); |
1747 | inR = inL->clone(); | 1746 | if ( !hasCalId ) { |
1748 | inR->setCalID_block( calID ); | 1747 | inR = inL->clone(); |
1749 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1748 | inR->setCalID_block( calID ); |
1750 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1749 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1751 | inR->setIDStr( idS ); | 1750 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1752 | remote->addIncidence( inR ); | 1751 | inR->setIDStr( idS ); |
1753 | if ( mSyncManager->syncWithDesktop() ) | 1752 | remote->addIncidence( inR ); |
1754 | inR->setPilotId( 2 ); | 1753 | if ( mSyncManager->syncWithDesktop() ) |
1755 | ++changedRemote; | 1754 | inR->setPilotId( 2 ); |
1755 | ++changedRemote; | ||
1756 | } else | ||
1757 | ++deletedEventR; | ||
1756 | } else {// take remote ********************** | 1758 | } else {// take remote ********************** |
1757 | if ( !inL->isReadOnly() ) { | 1759 | if ( !inL->isReadOnly() ) { |
1758 | idS = inL->IDStr(); | 1760 | idS = inL->IDStr(); |
1759 | int pid = inL->pilotId(); | 1761 | int pid = inL->pilotId(); |
1760 | int calID = inL->calID(); | 1762 | int calID = inL->calID(); |
1761 | if ( hasCalId ) | 1763 | if ( hasCalId ) |
1762 | calID = hasCalId; | 1764 | calID = 0;// add to default calendar |
1763 | local->deleteIncidence( inL ); | 1765 | local->deleteIncidence( inL ); |
1764 | inL = inR->clone(); | 1766 | inL = inR->clone(); |
1765 | inL->setCalID_block( calID ); | 1767 | inL->setCalID_block( calID ); |
@@ -1776,10 +1778,14 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1776 | } | 1778 | } |
1777 | } else { | 1779 | } else { |
1778 | // take == 0; events equal | 1780 | // take == 0; events equal |
1779 | if ( hasCalId ) | 1781 | if ( hasCalId ) { |
1780 | qDebug("EV EQUALLLL **************************** "); | 1782 | qDebug("KO: Changing Cal id %d to %d for : %s ", hasCalId, local->defaultCalendar(),inL->summary().latin1()); |
1783 | inL->setCalID( local->defaultCalendar() ); | ||
1784 | } | ||
1781 | 1785 | ||
1782 | } | 1786 | } |
1787 | |||
1788 | |||
1783 | } else { // no conflict ********** add or delete remote | 1789 | } else { // no conflict ********** add or delete remote |
1784 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1790 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1785 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1791 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
@@ -2482,16 +2488,12 @@ void CalendarView::mergeFileResource( QString fn ,QString resource ) | |||
2482 | } | 2488 | } |
2483 | clearAllViews(); | 2489 | clearAllViews(); |
2484 | mCalendar->setCalendarRemove( exclusiveResource ); | 2490 | mCalendar->setCalendarRemove( exclusiveResource ); |
2485 | int def = mCalendar->defaultCalendar(); | ||
2486 | mCalendar->setDefaultCalendar(exclusiveResource); | 2491 | mCalendar->setDefaultCalendar(exclusiveResource); |
2492 | mCalendar->setAllCalendarEnabled( true ); | ||
2487 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { | 2493 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { |
2488 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); | 2494 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); |
2489 | } | 2495 | } |
2490 | mCalendar->setDefaultCalendar( def ); | 2496 | restoreCalendarSettings(); |
2491 | mCalendar->reInitAlarmSettings(); | ||
2492 | setSyncEventsReadOnly(); | ||
2493 | updateUnmanagedViews(); | ||
2494 | updateView(); | ||
2495 | } | 2497 | } |
2496 | void CalendarView::showOpenError() | 2498 | void CalendarView::showOpenError() |
2497 | { | 2499 | { |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 980663f..8a5a76f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -259,25 +259,23 @@ void CalendarLocal::addCalendar( Calendar* cal ) | |||
259 | { | 259 | { |
260 | cal->setDontDeleteIncidencesOnClose(); | 260 | cal->setDontDeleteIncidencesOnClose(); |
261 | setSyncEventsEnabled(); | 261 | setSyncEventsEnabled(); |
262 | QPtrList<Incidence> incList; | ||
262 | { | 263 | { |
263 | QPtrList<Event> EventList = cal->rawEvents(); | 264 | QPtrList<Event> EventList = cal->rawEvents(); |
264 | QPtrList<Event> el; | ||
265 | Event * ev = EventList.first(); | 265 | Event * ev = EventList.first(); |
266 | while ( ev ) { | 266 | while ( ev ) { |
267 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { | 267 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { |
268 | Event * se = event( ev->uid() ); | ||
269 | if ( se ) | ||
270 | el.append( se ); | ||
271 | ev->setCalID_block( 1 ); | 268 | ev->setCalID_block( 1 ); |
272 | } | 269 | } |
270 | Event * se = event( ev->uid() ); | ||
271 | if ( se ) | ||
272 | incList.append( se ); | ||
273 | ev->unRegisterObserver( cal ); | 273 | ev->unRegisterObserver( cal ); |
274 | ev->registerObserver( this ); | 274 | ev->registerObserver( this ); |
275 | mEventList.append( ev ); | 275 | mEventList.append( ev ); |
276 | ev = EventList.next(); | 276 | ev = EventList.next(); |
277 | } | 277 | } |
278 | for ( ev = el.first(); ev; ev = el.next() ) { | 278 | |
279 | deleteIncidence ( ev ); | ||
280 | } | ||
281 | } | 279 | } |
282 | { | 280 | { |
283 | 281 | ||
@@ -289,7 +287,10 @@ void CalendarLocal::addCalendar( Calendar* cal ) | |||
289 | } | 287 | } |
290 | //TodoList = cal->rawTodos(); | 288 | //TodoList = cal->rawTodos(); |
291 | ev = TodoList.first(); | 289 | ev = TodoList.first(); |
292 | while ( ev ) { | 290 | while ( ev ) { |
291 | Todo * se = todo( ev->uid() ); | ||
292 | if ( se ) | ||
293 | incList.append( se ); | ||
293 | ev->unRegisterObserver( cal ); | 294 | ev->unRegisterObserver( cal ); |
294 | ev->registerObserver( this ); | 295 | ev->registerObserver( this ); |
295 | mTodoList.append( ev ); | 296 | mTodoList.append( ev ); |
@@ -301,12 +302,20 @@ void CalendarLocal::addCalendar( Calendar* cal ) | |||
301 | QPtrList<Journal> JournalList = cal->journals(); | 302 | QPtrList<Journal> JournalList = cal->journals(); |
302 | Journal * ev = JournalList.first(); | 303 | Journal * ev = JournalList.first(); |
303 | while ( ev ) { | 304 | while ( ev ) { |
305 | Journal * se = journal( ev->uid() ); | ||
306 | if ( se ) | ||
307 | incList.append( se ); | ||
304 | ev->unRegisterObserver( cal ); | 308 | ev->unRegisterObserver( cal ); |
305 | ev->registerObserver( this ); | 309 | ev->registerObserver( this ); |
306 | mJournalList.append( ev ); | 310 | mJournalList.append( ev ); |
307 | ev = JournalList.next(); | 311 | ev = JournalList.next(); |
308 | } | 312 | } |
309 | } | 313 | } |
314 | { | ||
315 | for (Incidence * ev = incList.first(); ev; ev = incList.next() ) { | ||
316 | deleteIncidence ( ev ); | ||
317 | } | ||
318 | } | ||
310 | setModified( true ); | 319 | setModified( true ); |
311 | } | 320 | } |
312 | bool CalendarLocal::load( const QString &fileName ) | 321 | bool CalendarLocal::load( const QString &fileName ) |