-rw-r--r-- | libkcal/calendarlocal.cpp | 77 |
1 files changed, 64 insertions, 13 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index ad8ace3..980663f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -35,141 +35,192 @@ | |||
35 | #include "exceptions.h" | 35 | #include "exceptions.h" |
36 | #include "incidence.h" | 36 | #include "incidence.h" |
37 | #include "journal.h" | 37 | #include "journal.h" |
38 | #include "filestorage.h" | 38 | #include "filestorage.h" |
39 | #include "calfilter.h" | 39 | #include "calfilter.h" |
40 | 40 | ||
41 | #include "calendarlocal.h" | 41 | #include "calendarlocal.h" |
42 | 42 | ||
43 | // #ifndef DESKTOP_VERSION | 43 | // #ifndef DESKTOP_VERSION |
44 | // #include <qtopia/alarmserver.h> | 44 | // #include <qtopia/alarmserver.h> |
45 | // #endif | 45 | // #endif |
46 | using namespace KCal; | 46 | using namespace KCal; |
47 | 47 | ||
48 | CalendarLocal::CalendarLocal() | 48 | CalendarLocal::CalendarLocal() |
49 | : Calendar() | 49 | : Calendar() |
50 | { | 50 | { |
51 | init(); | 51 | init(); |
52 | } | 52 | } |
53 | 53 | ||
54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) | 54 | CalendarLocal::CalendarLocal(const QString &timeZoneId) |
55 | : Calendar(timeZoneId) | 55 | : Calendar(timeZoneId) |
56 | { | 56 | { |
57 | init(); | 57 | init(); |
58 | } | 58 | } |
59 | 59 | ||
60 | void CalendarLocal::init() | 60 | void CalendarLocal::init() |
61 | { | 61 | { |
62 | mNextAlarmIncidence = 0; | 62 | mNextAlarmIncidence = 0; |
63 | } | 63 | } |
64 | 64 | ||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | registerObserver( 0 ); | 68 | registerObserver( 0 ); |
69 | if ( mDeleteIncidencesOnClose ) | 69 | if ( mDeleteIncidencesOnClose ) |
70 | close(); | 70 | close(); |
71 | } | 71 | } |
72 | bool CalendarLocal::mergeCalendarFile( QString name ) | 72 | bool CalendarLocal::mergeCalendarFile( QString name ) |
73 | { | 73 | { |
74 | CalendarLocal calendar( timeZoneId() ); | 74 | CalendarLocal calendar( timeZoneId() ); |
75 | calendar.setDefaultCalendar( 1 ); | 75 | calendar.setDefaultCalendar( 1 ); |
76 | if ( calendar.load( name ) ) { | 76 | if ( calendar.load( name ) ) { |
77 | mergeCalendar( &calendar ); | 77 | mergeCalendar( &calendar ); |
78 | return true; | 78 | return true; |
79 | } | 79 | } |
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 ) |
95 | continue; | ||
96 | } | ||
97 | else { | ||
98 | if ( enabledOnly ) { | ||
99 | if ( !todo->calEnabled() ) { | ||
100 | if ( isDup ) | ||
101 | *isDup = todo->calID(); | ||
91 | continue; | 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 | } |
97 | } else { | 113 | } else { |
98 | retVal = todo; | 114 | retVal = todo; |
99 | } | 115 | } |
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 | } |
114 | } else { | 153 | } else { |
115 | retVal = event; | 154 | retVal = event; |
116 | } | 155 | } |
117 | } | 156 | } |
118 | } | 157 | } |
119 | if ( retVal ) return retVal; | 158 | if ( retVal ) return retVal; |
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 | } |
130 | } else { | 181 | } else { |
131 | retVal = it; | 182 | retVal = it; |
132 | } | 183 | } |
133 | } | 184 | } |
134 | return retVal; | 185 | return retVal; |
135 | } | 186 | } |
136 | 187 | ||
137 | bool CalendarLocal::mergeCalendar( Calendar* remote ) | 188 | bool CalendarLocal::mergeCalendar( Calendar* remote ) |
138 | { | 189 | { |
139 | // 1 look for raw inc in local | 190 | // 1 look for raw inc in local |
140 | // if inc not in remote, delete in local | 191 | // if inc not in remote, delete in local |
141 | // 2 look for raw inc in remote | 192 | // 2 look for raw inc in remote |
142 | // if inc in local, replace it | 193 | // if inc in local, replace it |
143 | // if not in local, add it to default calendar | 194 | // if not in local, add it to default calendar |
144 | QPtrList<Incidence> localInc = rawIncidences(); | 195 | QPtrList<Incidence> localInc = rawIncidences(); |
145 | Incidence* inL = localInc.first(); | 196 | Incidence* inL = localInc.first(); |
146 | while ( inL ) { | 197 | while ( inL ) { |
147 | if ( ! inL->isReadOnly () ) | 198 | if ( ! inL->isReadOnly () ) |
148 | if ( !remote->incidenceForUid( inL->uid(), true )) | 199 | if ( !remote->incidenceForUid( inL->uid(), true )) |
149 | deleteIncidence( inL ); | 200 | deleteIncidence( inL ); |
150 | inL = localInc.next(); | 201 | inL = localInc.next(); |
151 | } | 202 | } |
152 | QPtrList<Incidence> er = remote->rawIncidences(); | 203 | QPtrList<Incidence> er = remote->rawIncidences(); |
153 | Incidence* inR = er.first(); | 204 | Incidence* inR = er.first(); |
154 | while ( inR ) { | 205 | while ( inR ) { |
155 | inL = incidenceForUid( inR->uid(),false ); | 206 | inL = incidenceForUid( inR->uid(),false ); |
156 | if ( inL ) { | 207 | if ( inL ) { |
157 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { | 208 | if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { |
158 | int calID = inL->calID(); | 209 | int calID = inL->calID(); |
159 | deleteIncidence( inL ); | 210 | deleteIncidence( inL ); |
160 | inL = inR->clone(); | 211 | inL = inR->clone(); |
161 | inL->setCalID_block( calID ); | 212 | inL->setCalID_block( calID ); |
162 | addIncidence( inL ); | 213 | addIncidence( inL ); |
163 | } | 214 | } |
164 | } else { | 215 | } else { |
165 | inL = inR->clone(); | 216 | inL = inR->clone(); |
166 | inL->setCalID_block( 0 );// add to default cal | 217 | inL->setCalID_block( 0 );// add to default cal |
167 | addIncidence( inL ); | 218 | addIncidence( inL ); |
168 | } | 219 | } |
169 | inR = er.next(); | 220 | inR = er.next(); |
170 | } | 221 | } |
171 | return true; | 222 | return true; |
172 | } | 223 | } |
173 | 224 | ||
174 | 225 | ||
175 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 226 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
@@ -188,101 +239,97 @@ void CalendarLocal::setSyncEventsEnabled() | |||
188 | ev = mEventList.first(); | 239 | ev = mEventList.first(); |
189 | while ( ev ) { | 240 | while ( ev ) { |
190 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 241 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
191 | ev->setCalEnabled( true ); | 242 | ev->setCalEnabled( true ); |
192 | ev = mEventList.next(); | 243 | ev = mEventList.next(); |
193 | } | 244 | } |
194 | } | 245 | } |
195 | void CalendarLocal::setSyncEventsReadOnly() | 246 | void CalendarLocal::setSyncEventsReadOnly() |
196 | { | 247 | { |
197 | Event * ev; | 248 | Event * ev; |
198 | ev = mEventList.first(); | 249 | ev = mEventList.first(); |
199 | while ( ev ) { | 250 | while ( ev ) { |
200 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { | 251 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { |
201 | ev->setReadOnly( true ); | 252 | ev->setReadOnly( true ); |
202 | } | 253 | } |
203 | ev = mEventList.next(); | 254 | ev = mEventList.next(); |
204 | } | 255 | } |
205 | } | 256 | } |
206 | 257 | ||
207 | void CalendarLocal::addCalendar( Calendar* cal ) | 258 | void CalendarLocal::addCalendar( Calendar* cal ) |
208 | { | 259 | { |
209 | cal->setDontDeleteIncidencesOnClose(); | 260 | cal->setDontDeleteIncidencesOnClose(); |
210 | setSyncEventsEnabled(); | 261 | setSyncEventsEnabled(); |
211 | { | 262 | { |
212 | QPtrList<Event> EventList = cal->rawEvents(); | 263 | QPtrList<Event> EventList = cal->rawEvents(); |
213 | QPtrList<Event> el; | 264 | QPtrList<Event> el; |
214 | Event * ev = EventList.first(); | 265 | Event * ev = EventList.first(); |
215 | while ( ev ) { | 266 | while ( ev ) { |
216 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { | 267 | if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { |
217 | Event * se = event( ev->uid() ); | 268 | Event * se = event( ev->uid() ); |
218 | if ( se ) | 269 | if ( se ) |
219 | el.append( se ); | 270 | el.append( se ); |
220 | ev->setCalID_block( 1 ); | 271 | ev->setCalID_block( 1 ); |
221 | } | 272 | } |
222 | ev->unRegisterObserver( cal ); | 273 | ev->unRegisterObserver( cal ); |
223 | ev->registerObserver( this ); | 274 | ev->registerObserver( this ); |
224 | mEventList.append( ev ); | 275 | mEventList.append( ev ); |
225 | ev = EventList.next(); | 276 | ev = EventList.next(); |
226 | } | 277 | } |
227 | for ( ev = el.first(); ev; ev = el.next() ) { | 278 | for ( ev = el.first(); ev; ev = el.next() ) { |
228 | deleteIncidence ( ev ); | 279 | deleteIncidence ( ev ); |
229 | } | 280 | } |
230 | } | 281 | } |
231 | { | 282 | { |
232 | 283 | ||
233 | QPtrList<Todo> TodoList = cal->rawTodos(); | 284 | QPtrList<Todo> TodoList = cal->rawTodos(); |
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 | } |
243 | //TodoList = cal->rawTodos(); | 290 | //TodoList = cal->rawTodos(); |
244 | ev = TodoList.first(); | 291 | ev = TodoList.first(); |
245 | while ( ev ) { | 292 | while ( ev ) { |
246 | ev->unRegisterObserver( cal ); | 293 | ev->unRegisterObserver( cal ); |
247 | ev->registerObserver( this ); | 294 | ev->registerObserver( this ); |
248 | mTodoList.append( ev ); | 295 | mTodoList.append( ev ); |
249 | setupRelations( ev ); | 296 | setupRelations( ev ); |
250 | ev = TodoList.next(); | 297 | ev = TodoList.next(); |
251 | } | 298 | } |
252 | } | 299 | } |
253 | { | 300 | { |
254 | QPtrList<Journal> JournalList = cal->journals(); | 301 | QPtrList<Journal> JournalList = cal->journals(); |
255 | Journal * ev = JournalList.first(); | 302 | Journal * ev = JournalList.first(); |
256 | while ( ev ) { | 303 | while ( ev ) { |
257 | ev->unRegisterObserver( cal ); | 304 | ev->unRegisterObserver( cal ); |
258 | ev->registerObserver( this ); | 305 | ev->registerObserver( this ); |
259 | mJournalList.append( ev ); | 306 | mJournalList.append( ev ); |
260 | ev = JournalList.next(); | 307 | ev = JournalList.next(); |
261 | } | 308 | } |
262 | } | 309 | } |
263 | setModified( true ); | 310 | setModified( true ); |
264 | } | 311 | } |
265 | bool CalendarLocal::load( const QString &fileName ) | 312 | bool CalendarLocal::load( const QString &fileName ) |
266 | { | 313 | { |
267 | FileStorage storage( this, fileName ); | 314 | FileStorage storage( this, fileName ); |
268 | return storage.load(); | 315 | return storage.load(); |
269 | } | 316 | } |
270 | 317 | ||
271 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 318 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
272 | { | 319 | { |
273 | FileStorage storage( this, fileName, format ); | 320 | FileStorage storage( this, fileName, format ); |
274 | return storage.save(); | 321 | return storage.save(); |
275 | } | 322 | } |
276 | 323 | ||
277 | void CalendarLocal::stopAllTodos() | 324 | void CalendarLocal::stopAllTodos() |
278 | { | 325 | { |
279 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 326 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
280 | it->setRunning( false ); | 327 | it->setRunning( false ); |
281 | 328 | ||
282 | } | 329 | } |
283 | void CalendarLocal::close() | 330 | void CalendarLocal::close() |
284 | { | 331 | { |
285 | 332 | ||
286 | Todo * i; | 333 | Todo * i; |
287 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 334 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
288 | 335 | ||
@@ -367,103 +414,107 @@ void CalendarLocal::deleteEvent( Event *event ) | |||
367 | 414 | ||
368 | 415 | ||
369 | Event *CalendarLocal::event( const QString &uid ) | 416 | Event *CalendarLocal::event( const QString &uid ) |
370 | { | 417 | { |
371 | Event *event; | 418 | Event *event; |
372 | Event *retVal = 0; | 419 | Event *retVal = 0; |
373 | for ( event = mEventList.first(); event; event = mEventList.next() ) { | 420 | for ( event = mEventList.first(); event; event = mEventList.next() ) { |
374 | if ( event->calEnabled() && event->uid() == uid ) { | 421 | if ( event->calEnabled() && event->uid() == uid ) { |
375 | if ( retVal ) { | 422 | if ( retVal ) { |
376 | if ( retVal->calID() > event->calID() ) { | 423 | if ( retVal->calID() > event->calID() ) { |
377 | retVal = event; | 424 | retVal = event; |
378 | } | 425 | } |
379 | } else { | 426 | } else { |
380 | retVal = event; | 427 | retVal = event; |
381 | } | 428 | } |
382 | } | 429 | } |
383 | } | 430 | } |
384 | return retVal; | 431 | return retVal; |
385 | } | 432 | } |
386 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 433 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
387 | { | 434 | { |
388 | Todo * eve; | 435 | Todo * eve; |
389 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 436 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
390 | if ( *eve == *todo ) { | 437 | if ( *eve == *todo ) { |
391 | //qDebug("duplicate todo found! not inserted! "); | 438 | //qDebug("duplicate todo found! not inserted! "); |
392 | return false; | 439 | return false; |
393 | } | 440 | } |
394 | } | 441 | } |
395 | return addTodo( todo ); | 442 | return addTodo( todo ); |
396 | } | 443 | } |
397 | bool CalendarLocal::addTodo( Todo *todo ) | 444 | bool CalendarLocal::addTodo( Todo *todo ) |
398 | { | 445 | { |
399 | mTodoList.append( todo ); | 446 | mTodoList.append( todo ); |
400 | 447 | ||
401 | todo->registerObserver( this ); | 448 | todo->registerObserver( this ); |
402 | 449 | ||
403 | // Set up subtask relations | 450 | // Set up subtask relations |
404 | setupRelations( todo ); | 451 | setupRelations( todo ); |
405 | 452 | ||
406 | setModified( true ); | 453 | setModified( true ); |
407 | if ( todo->calID() == 0 ) | 454 | if ( todo->calID() == 0 ) |
408 | todo->setCalID_block( mDefaultCalendar ); | 455 | todo->setCalID_block( mDefaultCalendar ); |
409 | todo->setCalEnabled( true ); | 456 | todo->setCalEnabled( true ); |
410 | return true; | 457 | return true; |
411 | } | 458 | } |
412 | 459 | ||
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 ); |
417 | clearUndo(todo); | 465 | clearUndo(todo); |
418 | 466 | ||
419 | if ( mTodoList.removeRef( todo ) ) { | 467 | if ( mTodoList.removeRef( todo ) ) { |
420 | setModified( true ); | 468 | setModified( true ); |
421 | } | 469 | } |
470 | Todo* dup = todoForUid( uid ); | ||
471 | if ( dup ) | ||
472 | setupRelations( dup ); | ||
422 | } | 473 | } |
423 | 474 | ||
424 | QPtrList<Todo> CalendarLocal::rawTodos() | 475 | QPtrList<Todo> CalendarLocal::rawTodos() |
425 | { | 476 | { |
426 | QPtrList<Todo> el; | 477 | QPtrList<Todo> el; |
427 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 478 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
428 | if ( it->calEnabled() ) el.append( it ); | 479 | if ( it->calEnabled() ) el.append( it ); |
429 | return el; | 480 | return el; |
430 | } | 481 | } |
431 | Todo *CalendarLocal::todo( QString syncProf, QString id ) | 482 | Todo *CalendarLocal::todo( QString syncProf, QString id ) |
432 | { | 483 | { |
433 | Todo *todo; | 484 | Todo *todo; |
434 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 485 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
435 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; | 486 | if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; |
436 | } | 487 | } |
437 | 488 | ||
438 | return 0; | 489 | return 0; |
439 | } | 490 | } |
440 | void CalendarLocal::removeSyncInfo( QString syncProfile) | 491 | void CalendarLocal::removeSyncInfo( QString syncProfile) |
441 | { | 492 | { |
442 | QPtrList<Incidence> all = rawIncidences() ; | 493 | QPtrList<Incidence> all = rawIncidences() ; |
443 | Incidence *inc; | 494 | Incidence *inc; |
444 | for ( inc = all.first(); inc; inc = all.next() ) { | 495 | for ( inc = all.first(); inc; inc = all.next() ) { |
445 | inc->removeID( syncProfile ); | 496 | inc->removeID( syncProfile ); |
446 | } | 497 | } |
447 | if ( syncProfile.isEmpty() ) { | 498 | if ( syncProfile.isEmpty() ) { |
448 | QPtrList<Event> el; | 499 | QPtrList<Event> el; |
449 | Event *todo; | 500 | Event *todo; |
450 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 501 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
451 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 502 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
452 | el.append( todo ); | 503 | el.append( todo ); |
453 | } | 504 | } |
454 | for ( todo = el.first(); todo; todo = el.next() ) { | 505 | for ( todo = el.first(); todo; todo = el.next() ) { |
455 | deleteIncidence ( todo ); | 506 | deleteIncidence ( todo ); |
456 | } | 507 | } |
457 | } else { | 508 | } else { |
458 | Event *lse = event( "last-syncEvent-"+ syncProfile); | 509 | Event *lse = event( "last-syncEvent-"+ syncProfile); |
459 | if ( lse ) | 510 | if ( lse ) |
460 | deleteIncidence ( lse ); | 511 | deleteIncidence ( lse ); |
461 | } | 512 | } |
462 | } | 513 | } |
463 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 514 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
464 | { | 515 | { |
465 | QPtrList<Event> el; | 516 | QPtrList<Event> el; |
466 | Event *todo; | 517 | Event *todo; |
467 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 518 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
468 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 519 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
469 | if ( todo->summary().left(3) == "E: " ) | 520 | if ( todo->summary().left(3) == "E: " ) |