-rw-r--r-- | korganizer/calendarview.cpp | 7 | ||||
-rw-r--r-- | libkcal/calendar.h | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 35 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 2 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 1 |
6 files changed, 41 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index ccacc52..a350c3b 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1225,5 +1225,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
1225 | break; | 1225 | break; |
1226 | case SYNC_PREF_ASK: | 1226 | case SYNC_PREF_ASK: |
1227 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1227 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1228 | if ( lastSync > remoteMod && lastSync > localMod) | 1228 | if ( lastSync > remoteMod && lastSync > localMod) |
1229 | return 0; | 1229 | return 0; |
@@ -1232,5 +1232,5 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b | |||
1232 | if ( lastSync > localMod ) | 1232 | if ( lastSync > localMod ) |
1233 | return 2; | 1233 | return 2; |
1234 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1234 | qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1235 | localIsNew = localMod >= remoteMod; | 1235 | localIsNew = localMod >= remoteMod; |
1236 | if ( localIsNew ) | 1236 | if ( localIsNew ) |
@@ -1360,4 +1360,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1360 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1361 | if ( eventR ) { | 1361 | if ( eventR ) { |
1362 | qDebug("last-syncEvent on remote found "); | ||
1362 | eventRSync = (Event*) eventR->clone(); | 1363 | eventRSync = (Event*) eventR->clone(); |
1363 | remote->deleteEvent(eventR ); | 1364 | remote->deleteEvent(eventR ); |
@@ -1382,5 +1383,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1382 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1383 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1383 | 1384 | ||
1384 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1385 | qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1385 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1386 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1386 | fullDateRange = true; | 1387 | fullDateRange = true; |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 14a1a45..95477cd 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -78,4 +78,5 @@ 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 ) = 0; | ||
80 | virtual void setSyncEventsReadOnly() = 0; | 81 | virtual void setSyncEventsReadOnly() = 0; |
81 | virtual void stopAllTodos() = 0; | 82 | 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 | |||
@@ -80,5 +80,5 @@ bool CalendarLocal::mergeCalendarFile( QString name ) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | 82 | Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) |
83 | { | 83 | { |
84 | Todo *todo;; | 84 | Todo *todo;; |
@@ -86,4 +86,5 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | |||
86 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 86 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
87 | if ( todo->uid() == uid ) { | 87 | if ( todo->uid() == uid ) { |
88 | if ( doNotCheckDuplicates ) return todo; | ||
88 | if ( retVal ) { | 89 | if ( retVal ) { |
89 | if ( retVal->calID() > todo->calID() ) { | 90 | if ( retVal->calID() > todo->calID() ) { |
@@ -99,4 +100,5 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | |||
99 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 100 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
100 | if ( event->uid() == uid ) { | 101 | if ( event->uid() == uid ) { |
102 | if ( doNotCheckDuplicates ) return event; | ||
101 | if ( retVal ) { | 103 | if ( retVal ) { |
102 | if ( retVal->calID() > event->calID() ) { | 104 | if ( retVal->calID() > event->calID() ) { |
@@ -111,4 +113,5 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | |||
111 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) | 113 | for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) |
112 | if ( it->uid() == uid ) { | 114 | if ( it->uid() == uid ) { |
115 | if ( doNotCheckDuplicates ) return it; | ||
113 | if ( retVal ) { | 116 | if ( retVal ) { |
114 | if ( retVal->calID() > it->calID() ) { | 117 | if ( retVal->calID() > it->calID() ) { |
@@ -124,15 +127,29 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid ) | |||
124 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | 127 | bool CalendarLocal::mergeCalendar( Calendar* remote ) |
125 | { | 128 | { |
129 | // 1 look for raw inc in local | ||
130 | // if inc not in remote, delete in local | ||
131 | // 2 look for raw inc in remote | ||
132 | // if inc in local, replace it | ||
133 | // if not in local, add it to default calendar | ||
134 | QPtrList<Incidence> localInc = rawIncidences(); | ||
135 | Incidence* inL = localInc.first(); | ||
136 | while ( inL ) { | ||
137 | if ( ! inL->isReadOnly () ) | ||
138 | if ( !remote->incidenceForUid( inL->uid(), true )) | ||
139 | deleteIncidence( inL ); | ||
140 | inL = localInc.next(); | ||
141 | } | ||
126 | QPtrList<Incidence> er = remote->rawIncidences(); | 142 | QPtrList<Incidence> er = remote->rawIncidences(); |
127 | Incidence* inR = er.first(); | 143 | Incidence* inR = er.first(); |
128 | Incidence* inL; | ||
129 | while ( inR ) { | 144 | while ( inR ) { |
130 | inL = incidenceForUid( inR->uid() ); | 145 | inL = incidenceForUid( inR->uid(),false ); |
131 | if ( inL ) { | 146 | if ( inL ) { |
132 | int calID = inL->calID(); | 147 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { |
133 | deleteIncidence( inL ); | 148 | int calID = inL->calID(); |
134 | inL = inR->clone(); | 149 | deleteIncidence( inL ); |
135 | inL->setCalID( calID ); | 150 | inL = inR->clone(); |
136 | addIncidence( inL ); | 151 | inL->setCalID( calID ); |
152 | addIncidence( inL ); | ||
153 | } | ||
137 | } else { | 154 | } else { |
138 | inL = inR->clone(); | 155 | inL = inR->clone(); |
@@ -144,4 +161,6 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) | |||
144 | return true; | 161 | return true; |
145 | } | 162 | } |
163 | |||
164 | |||
146 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 165 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
147 | { | 166 | { |
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index 23b0542..a7a85c8 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h | |||
@@ -48,5 +48,5 @@ 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 ); | 50 | Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); |
51 | void setSyncEventsReadOnly(); | 51 | void setSyncEventsReadOnly(); |
52 | void stopAllTodos(); | 52 | void stopAllTodos(); |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index dcead02..1a19f3e 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -35,4 +35,5 @@ IncidenceBase::IncidenceBase() : | |||
35 | mPilotId(0), mSyncStatus(SYNCMOD) | 35 | mPilotId(0), mSyncStatus(SYNCMOD) |
36 | { | 36 | { |
37 | blockLastModified = false; | ||
37 | setUid(CalFormat::createUniqueId()); | 38 | setUid(CalFormat::createUniqueId()); |
38 | mOrganizer = ""; | 39 | mOrganizer = ""; |
@@ -54,4 +55,5 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) : | |||
54 | { | 55 | { |
55 | 56 | ||
57 | blockLastModified = false; | ||
56 | mReadOnly = i.mReadOnly; | 58 | mReadOnly = i.mReadOnly; |
57 | mDtStart = i.mDtStart; | 59 | mDtStart = i.mDtStart; |
@@ -150,6 +152,9 @@ void IncidenceBase::setTagged( bool b) | |||
150 | void IncidenceBase::setCalID( int id ) | 152 | void IncidenceBase::setCalID( int id ) |
151 | { | 153 | { |
152 | if ( mCalID > 0 ) | 154 | if ( mCalID > 0 ) { |
155 | blockLastModified = true; | ||
153 | updated(); | 156 | updated(); |
157 | blockLastModified = false; | ||
158 | } | ||
154 | mCalID = id; | 159 | mCalID = id; |
155 | } | 160 | } |
@@ -190,4 +195,5 @@ QString IncidenceBase::uid() const | |||
190 | void IncidenceBase::setLastModified(const QDateTime &lm) | 195 | void IncidenceBase::setLastModified(const QDateTime &lm) |
191 | { | 196 | { |
197 | if ( blockLastModified ) return; | ||
192 | // DON'T! updated() because we call this from | 198 | // DON'T! updated() because we call this from |
193 | // Calendar::updateEvent(). | 199 | // Calendar::updateEvent(). |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index bccf287..bed73db 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -151,4 +151,5 @@ class IncidenceBase : public CustomProperties | |||
151 | void setTagged( bool ); | 151 | void setTagged( bool ); |
152 | protected: | 152 | protected: |
153 | bool blockLastModified; | ||
153 | bool mIsTagged; | 154 | bool mIsTagged; |
154 | QDateTime mDtStart; | 155 | QDateTime mDtStart; |