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 /libkcal | |
parent | 084180efc1bccba341bf3f2f718fd10cdfdaf18e (diff) | |
download | kdepimpi-b7522a13b64225bb91bdab4a21b44282f8c3e3b4.zip kdepimpi-b7522a13b64225bb91bdab4a21b44282f8c3e3b4.tar.gz kdepimpi-b7522a13b64225bb91bdab4a21b44282f8c3e3b4.tar.bz2 |
sync
-rw-r--r-- | libkcal/calendarlocal.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 980663f..8a5a76f 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -214,144 +214,153 @@ bool CalendarLocal::mergeCalendar( Calendar* remote ) | |||
214 | } | 214 | } |
215 | } else { | 215 | } else { |
216 | inL = inR->clone(); | 216 | inL = inR->clone(); |
217 | inL->setCalID_block( 0 );// add to default cal | 217 | inL->setCalID_block( 0 );// add to default cal |
218 | addIncidence( inL ); | 218 | addIncidence( inL ); |
219 | } | 219 | } |
220 | inR = er.next(); | 220 | inR = er.next(); |
221 | } | 221 | } |
222 | return true; | 222 | return true; |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | bool CalendarLocal::addCalendarFile( QString name, int id ) | 226 | bool CalendarLocal::addCalendarFile( QString name, int id ) |
227 | { | 227 | { |
228 | CalendarLocal calendar( timeZoneId() ); | 228 | CalendarLocal calendar( timeZoneId() ); |
229 | calendar.setDefaultCalendar( id ); | 229 | calendar.setDefaultCalendar( id ); |
230 | if ( calendar.load( name ) ) { | 230 | if ( calendar.load( name ) ) { |
231 | addCalendar( &calendar ); | 231 | addCalendar( &calendar ); |
232 | return true; | 232 | return true; |
233 | } | 233 | } |
234 | return false; | 234 | return false; |
235 | } | 235 | } |
236 | void CalendarLocal::setSyncEventsEnabled() | 236 | void CalendarLocal::setSyncEventsEnabled() |
237 | { | 237 | { |
238 | Event * ev; | 238 | Event * ev; |
239 | ev = mEventList.first(); | 239 | ev = mEventList.first(); |
240 | while ( ev ) { | 240 | while ( ev ) { |
241 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) | 241 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) |
242 | ev->setCalEnabled( true ); | 242 | ev->setCalEnabled( true ); |
243 | ev = mEventList.next(); | 243 | ev = mEventList.next(); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | void CalendarLocal::setSyncEventsReadOnly() | 246 | void CalendarLocal::setSyncEventsReadOnly() |
247 | { | 247 | { |
248 | Event * ev; | 248 | Event * ev; |
249 | ev = mEventList.first(); | 249 | ev = mEventList.first(); |
250 | while ( ev ) { | 250 | while ( ev ) { |
251 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { | 251 | if ( ev->uid().left(15) == QString("last-syncEvent-") ) { |
252 | ev->setReadOnly( true ); | 252 | ev->setReadOnly( true ); |
253 | } | 253 | } |
254 | ev = mEventList.next(); | 254 | ev = mEventList.next(); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | void CalendarLocal::addCalendar( Calendar* cal ) | 258 | 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 | ||
284 | QPtrList<Todo> TodoList = cal->rawTodos(); | 282 | QPtrList<Todo> TodoList = cal->rawTodos(); |
285 | Todo * ev = TodoList.first(); | 283 | Todo * ev = TodoList.first(); |
286 | while ( ev ) { | 284 | while ( ev ) { |
287 | ev->resetRelatedTo(); | 285 | ev->resetRelatedTo(); |
288 | ev = TodoList.next(); | 286 | ev = TodoList.next(); |
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 ); |
296 | setupRelations( ev ); | 297 | setupRelations( ev ); |
297 | ev = TodoList.next(); | 298 | ev = TodoList.next(); |
298 | } | 299 | } |
299 | } | 300 | } |
300 | { | 301 | { |
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 ) |
313 | { | 322 | { |
314 | FileStorage storage( this, fileName ); | 323 | FileStorage storage( this, fileName ); |
315 | return storage.load(); | 324 | return storage.load(); |
316 | } | 325 | } |
317 | 326 | ||
318 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) | 327 | bool CalendarLocal::save( const QString &fileName, CalFormat *format ) |
319 | { | 328 | { |
320 | FileStorage storage( this, fileName, format ); | 329 | FileStorage storage( this, fileName, format ); |
321 | return storage.save(); | 330 | return storage.save(); |
322 | } | 331 | } |
323 | 332 | ||
324 | void CalendarLocal::stopAllTodos() | 333 | void CalendarLocal::stopAllTodos() |
325 | { | 334 | { |
326 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) | 335 | for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) |
327 | it->setRunning( false ); | 336 | it->setRunning( false ); |
328 | 337 | ||
329 | } | 338 | } |
330 | void CalendarLocal::close() | 339 | void CalendarLocal::close() |
331 | { | 340 | { |
332 | 341 | ||
333 | Todo * i; | 342 | Todo * i; |
334 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); | 343 | for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); |
335 | 344 | ||
336 | mEventList.setAutoDelete( true ); | 345 | mEventList.setAutoDelete( true ); |
337 | mTodoList.setAutoDelete( true ); | 346 | mTodoList.setAutoDelete( true ); |
338 | mJournalList.setAutoDelete( true ); | 347 | mJournalList.setAutoDelete( true ); |
339 | 348 | ||
340 | mEventList.clear(); | 349 | mEventList.clear(); |
341 | mTodoList.clear(); | 350 | mTodoList.clear(); |
342 | mJournalList.clear(); | 351 | mJournalList.clear(); |
343 | 352 | ||
344 | mEventList.setAutoDelete( false ); | 353 | mEventList.setAutoDelete( false ); |
345 | mTodoList.setAutoDelete( false ); | 354 | mTodoList.setAutoDelete( false ); |
346 | mJournalList.setAutoDelete( false ); | 355 | mJournalList.setAutoDelete( false ); |
347 | 356 | ||
348 | setModified( false ); | 357 | setModified( false ); |
349 | } | 358 | } |
350 | 359 | ||
351 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) | 360 | bool CalendarLocal::addAnniversaryNoDup( Event *event ) |
352 | { | 361 | { |
353 | QString cat; | 362 | QString cat; |
354 | bool isBirthday = true; | 363 | bool isBirthday = true; |
355 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { | 364 | if( event->categoriesStr() == i18n( "Anniversary" ) ) { |
356 | isBirthday = false; | 365 | isBirthday = false; |
357 | cat = i18n( "Anniversary" ); | 366 | cat = i18n( "Anniversary" ); |