author | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-28 01:23:02 (UTC) |
commit | e08811c2246f63b2b63f9db6b65701344460f3d7 (patch) (unidiff) | |
tree | d450f486a9472d80eb86f605237b828a0e7ffae6 | |
parent | 854d4a0c686962cd73ac7418b5fbf4b2d73adab7 (diff) | |
download | kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.zip kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.gz kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.bz2 |
ync
-rw-r--r-- | korganizer/calendarview.cpp | 17 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 9 | ||||
-rw-r--r-- | libkcal/calendar.h | 3 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 81 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 3 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 6 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
7 files changed, 99 insertions, 21 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d024c1..1800cf2 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1605,4 +1605,5 @@ void CalendarView::checkExternalId( Incidence * inc ) | |||
1605 | 1605 | ||
1606 | } | 1606 | } |
1607 | // SSSSSSSSSSSSSSSSSSSSSS | ||
1607 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1608 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1608 | { | 1609 | { |
@@ -1724,6 +1725,13 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1724 | qApp->processEvents(); | 1725 | qApp->processEvents(); |
1725 | if ( !skipIncidence ) { | 1726 | if ( !skipIncidence ) { |
1726 | inL = local->incidenceForUid( uid , false , true ); | 1727 | int hasCalId = 0; |
1728 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | ||
1729 | if ( hasCalId && !inL ) | ||
1730 | inL = local->incidenceForUid( uid , false , true, &hasCalId ); | ||
1731 | else | ||
1732 | hasCalId = 0; | ||
1727 | if ( inL ) { // maybe conflict - same uid in both calendars | 1733 | if ( inL ) { // maybe conflict - same uid in both calendars |
1734 | if ( hasCalId ) | ||
1735 | qDebug("KO: Cal id %d conflict detected: %s ", hasCalId, inL->summary().latin1()); | ||
1728 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1736 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1729 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1737 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
@@ -1751,4 +1759,6 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1751 | int pid = inL->pilotId(); | 1759 | int pid = inL->pilotId(); |
1752 | int calID = inL->calID(); | 1760 | int calID = inL->calID(); |
1761 | if ( hasCalId ) | ||
1762 | calID = hasCalId; | ||
1753 | local->deleteIncidence( inL ); | 1763 | local->deleteIncidence( inL ); |
1754 | inL = inR->clone(); | 1764 | inL = inR->clone(); |
@@ -1765,4 +1775,9 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1765 | } | 1775 | } |
1766 | } | 1776 | } |
1777 | } else { | ||
1778 | // take == 0; events equal | ||
1779 | if ( hasCalId ) | ||
1780 | qDebug("EV EQUALLLL **************************** "); | ||
1781 | |||
1767 | } | 1782 | } |
1768 | } else { // no conflict ********** add or delete remote | 1783 | } else { // no conflict ********** add or delete remote |
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 8535191..1350f6d 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -8,5 +8,4 @@ | |||
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | |||
11 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
@@ -421,9 +420,10 @@ void Calendar::setupRelations( Incidence *incidence ) | |||
421 | { | 420 | { |
422 | QString uid = incidence->uid(); | 421 | QString uid = incidence->uid(); |
423 | //qDebug("Calendar::setupRelations "); | 422 | //qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); |
424 | // First, go over the list of orphans and see if this is their parent | 423 | // First, go over the list of orphans and see if this is their parent |
425 | while( Incidence* i = mOrphans[ uid ] ) { | 424 | while( Incidence* i = mOrphans[ uid ] ) { |
426 | mOrphans.remove( uid ); | 425 | mOrphans.remove( uid ); |
427 | i->setRelatedTo( incidence ); | 426 | i->setRelatedTo( incidence ); |
427 | //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); | ||
428 | incidence->addRelation( i ); | 428 | incidence->addRelation( i ); |
429 | mOrphanUids.remove( i->uid() ); | 429 | mOrphanUids.remove( i->uid() ); |
@@ -434,10 +434,13 @@ void Calendar::setupRelations( Incidence *incidence ) | |||
434 | // This incidence has a uid it is related to, but is not registered to it yet | 434 | // This incidence has a uid it is related to, but is not registered to it yet |
435 | // Try to find it | 435 | // Try to find it |
436 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 436 | //qDebug("Test parent for %s", incidence->summary().latin1()); |
437 | Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); | ||
437 | if( parent ) { | 438 | if( parent ) { |
438 | // Found it | 439 | // Found it |
440 | // qDebug("parent found for for %s", incidence->summary().latin1()); | ||
439 | incidence->setRelatedTo( parent ); | 441 | incidence->setRelatedTo( parent ); |
440 | parent->addRelation( incidence ); | 442 | parent->addRelation( incidence ); |
441 | } else { | 443 | } else { |
444 | // qDebug("NO parent found for for %s", incidence->summary().latin1()); | ||
442 | // Not found, put this in the mOrphans list | 445 | // Not found, put this in the mOrphans list |
443 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 446 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index f301768..fbc40ad 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -78,5 +78,6 @@ public: | |||
78 | virtual bool addCalendarFile( QString name, int id ) = 0; | 78 | virtual bool addCalendarFile( QString name, int id ) = 0; |
79 | virtual bool mergeCalendarFile( QString name ) = 0; | 79 | virtual bool mergeCalendarFile( QString name ) = 0; |
80 | virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ) = 0; | 80 | virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ,int * isDup = 0 ) = 0; |
81 | virtual Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0) = 0; | ||
81 | virtual void setSyncEventsReadOnly() = 0; | 82 | virtual void setSyncEventsReadOnly() = 0; |
82 | virtual void setSyncEventsEnabled() = 0; | 83 | virtual void setSyncEventsEnabled() = 0; |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index ad8ace3..980663f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -80,17 +80,33 @@ bool CalendarLocal::mergeCalendarFile( QString name ) | |||
80 | return false; | 80 | return false; |
81 | } | 81 | } |
82 | 82 | ||
83 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly ) | 83 | Todo* CalendarLocal::todoForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly,int * isDup ) |
84 | { | 84 | { |
85 | |||
86 | int calID = 0; | ||
87 | if ( isDup && *isDup > 0 ) | ||
88 | calID = *isDup; | ||
85 | Todo *todo;; | 89 | Todo *todo;; |
86 | Incidence *retVal = 0; | 90 | Todo *retVal = 0; |
87 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 91 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
88 | if ( todo->uid() == uid ) { | 92 | if ( todo->uid() == uid ) { |
89 | if ( enabledOnly ) | 93 | if( calID ) { |
90 | if ( !todo->calEnabled() ) | 94 | if ( todo->calID() != calID ) |
91 | continue; | 95 | continue; |
96 | } | ||
97 | else { | ||
98 | if ( enabledOnly ) { | ||
99 | if ( !todo->calEnabled() ) { | ||
100 | if ( isDup ) | ||
101 | *isDup = todo->calID(); | ||
102 | continue; | ||
103 | } | ||
104 | } | ||
105 | } | ||
92 | if ( doNotCheckDuplicates ) return todo; | 106 | if ( doNotCheckDuplicates ) return todo; |
93 | if ( retVal ) { | 107 | if ( retVal ) { |
94 | if ( retVal->calID() > todo->calID() ) { | 108 | if ( retVal->calID() > todo->calID() ) { |
109 | if ( isDup ) | ||
110 | *isDup = retVal->calID(); | ||
95 | retVal = todo; | 111 | retVal = todo; |
96 | } | 112 | } |
@@ -100,14 +116,37 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD | |||
100 | } | 116 | } |
101 | } | 117 | } |
118 | return retVal; | ||
119 | } | ||
120 | //if ( isDup) and * isDup == 0: store duplicate found cal id in isDup | ||
121 | //if ( isDup) and * isDup > 0: search only in calendar with ID *isDup, ignore enabledOnly | ||
122 | |||
123 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly, int * isDup ) | ||
124 | { | ||
125 | int calID = 0; | ||
126 | if ( isDup && *isDup > 0 ) | ||
127 | calID = *isDup; | ||
128 | Incidence *retVal = todoForUid( uid , doNotCheckDuplicates,enabledOnly, isDup ); | ||
102 | if ( retVal ) return retVal; | 129 | if ( retVal ) return retVal; |
103 | Event *event; | 130 | Event *event; |
104 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 131 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
105 | if ( event->uid() == uid ) { | 132 | if ( event->uid() == uid ) { |
106 | if ( enabledOnly ) | 133 | if( calID ) { |
107 | if ( !event->calEnabled() ) | 134 | if ( event->calID() != calID ) |
108 | continue; | 135 | continue; |
136 | } | ||
137 | else { | ||
138 | if ( enabledOnly ) { | ||
139 | if ( !event->calEnabled() ) { | ||
140 | if ( isDup ) | ||
141 | *isDup =event->calID() ; | ||
142 | continue; | ||
143 | } | ||
144 | } | ||
145 | } | ||
109 | if ( doNotCheckDuplicates ) return event; | 146 | if ( doNotCheckDuplicates ) return event; |
110 | if ( retVal ) { | 147 | if ( retVal ) { |
111 | if ( retVal->calID() > event->calID() ) { | 148 | if ( retVal->calID() > event->calID() ) { |
149 | if ( isDup ) | ||
150 | *isDup = retVal->calID(); | ||
112 | retVal = event; | 151 | retVal = event; |
113 | } | 152 | } |
@@ -120,10 +159,22 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD | |||
120 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 159 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
121 | if ( it->uid() == uid ) { | 160 | if ( it->uid() == uid ) { |
122 | if ( enabledOnly ) | 161 | if( calID ) { |
123 | if ( !it->calEnabled() ) | 162 | if ( event->calID() != calID ) |
124 | continue; | 163 | continue; |
164 | } | ||
165 | else { | ||
166 | if ( enabledOnly ) { | ||
167 | if ( !it->calEnabled() ) { | ||
168 | if ( isDup ) | ||
169 | *isDup = it->calID(); | ||
170 | continue; | ||
171 | } | ||
172 | } | ||
173 | } | ||
125 | if ( doNotCheckDuplicates ) return it; | 174 | if ( doNotCheckDuplicates ) return it; |
126 | if ( retVal ) { | 175 | if ( retVal ) { |
127 | if ( retVal->calID() > it->calID() ) { | 176 | if ( retVal->calID() > it->calID() ) { |
177 | if ( isDup ) | ||
178 | *isDup = retVal->calID(); | ||
128 | retVal = it; | 179 | retVal = it; |
129 | } | 180 | } |
@@ -234,9 +285,5 @@ void CalendarLocal::addCalendar( Calendar* cal ) | |||
234 | Todo * ev = TodoList.first(); | 285 | Todo * ev = TodoList.first(); |
235 | while ( ev ) { | 286 | while ( ev ) { |
236 | QString rel = ev->relatedToUid(); | 287 | ev->resetRelatedTo(); |
237 | if ( !rel.isEmpty() ){ | ||
238 | ev->setRelatedTo ( 0 ); | ||
239 | ev->setRelatedToUid( rel ); | ||
240 | } | ||
241 | ev = TodoList.next(); | 288 | ev = TodoList.next(); |
242 | } | 289 | } |
@@ -413,4 +460,5 @@ bool CalendarLocal::addTodo( Todo *todo ) | |||
413 | void CalendarLocal::deleteTodo( Todo *todo ) | 460 | void CalendarLocal::deleteTodo( Todo *todo ) |
414 | { | 461 | { |
462 | QString uid = todo->uid(); | ||
415 | // Handle orphaned children | 463 | // Handle orphaned children |
416 | removeRelations( todo ); | 464 | removeRelations( todo ); |
@@ -420,4 +468,7 @@ void CalendarLocal::deleteTodo( Todo *todo ) | |||
420 | setModified( true ); | 468 | setModified( true ); |
421 | } | 469 | } |
470 | Todo* dup = todoForUid( uid ); | ||
471 | if ( dup ) | ||
472 | setupRelations( dup ); | ||
422 | } | 473 | } |
423 | 474 | ||
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index b611704..1ceabce 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -48,5 +48,6 @@ class CalendarLocal : public Calendar | |||
48 | bool mergeCalendarFile( QString name ); | 48 | bool mergeCalendarFile( QString name ); |
49 | bool mergeCalendar( Calendar* cal ); | 49 | bool mergeCalendar( Calendar* cal ); |
50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false ); | 50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false,int * isDup = 0 ); |
51 | Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0 ); | ||
51 | void setSyncEventsReadOnly(); | 52 | void setSyncEventsReadOnly(); |
52 | void setSyncEventsEnabled(); | 53 | void setSyncEventsEnabled(); |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index fe9f854..7dd9bd2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -521,4 +521,10 @@ QString Incidence::relatedToUid() const | |||
521 | return mRelatedToUid; | 521 | return mRelatedToUid; |
522 | } | 522 | } |
523 | void Incidence::resetRelatedTo() | ||
524 | { | ||
525 | QString store = mRelatedToUid; | ||
526 | setRelatedTo( 0 ); | ||
527 | mRelatedToUid = store; | ||
528 | } | ||
523 | 529 | ||
524 | void Incidence::setRelatedTo(Incidence *relatedTo) | 530 | void Incidence::setRelatedTo(Incidence *relatedTo) |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index dc49640..f89942f 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -174,4 +174,5 @@ class Incidence : public IncidenceBase | |||
174 | /** point at some other event to which the event relates */ | 174 | /** point at some other event to which the event relates */ |
175 | void setRelatedTo(Incidence *relatedTo); | 175 | void setRelatedTo(Incidence *relatedTo); |
176 | void resetRelatedTo(); | ||
176 | /** what event does this one relate to? */ | 177 | /** what event does this one relate to? */ |
177 | Incidence *relatedTo() const; | 178 | Incidence *relatedTo() const; |