author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/calendar.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | libkcal/calendar.cpp | 66 |
1 files changed, 34 insertions, 32 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index 9b38d3f..bf095cf 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -25,16 +25,18 @@ | |||
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | #include <klocale.h> | 26 | #include <klocale.h> |
27 | 27 | ||
28 | #include "exceptions.h" | 28 | #include "exceptions.h" |
29 | #include "calfilter.h" | 29 | #include "calfilter.h" |
30 | 30 | ||
31 | #include "calendar.h" | 31 | #include "calendar.h" |
32 | #include "syncdefines.h" | 32 | #include "syncdefines.h" |
33 | //Added by qt3to4: | ||
34 | #include <Q3PtrList> | ||
33 | 35 | ||
34 | using namespace KCal; | 36 | using namespace KCal; |
35 | 37 | ||
36 | Calendar::Calendar() | 38 | Calendar::Calendar() |
37 | { | 39 | { |
38 | 40 | ||
39 | init(); | 41 | init(); |
40 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); | 42 | setTimeZoneId( " 00:00 Europe/London(UTC)" ); |
@@ -266,115 +268,115 @@ void Calendar::setFilter(CalFilter *filter) | |||
266 | mFilter = filter; | 268 | mFilter = filter; |
267 | } | 269 | } |
268 | 270 | ||
269 | CalFilter *Calendar::filter() | 271 | CalFilter *Calendar::filter() |
270 | { | 272 | { |
271 | return mFilter; | 273 | return mFilter; |
272 | } | 274 | } |
273 | 275 | ||
274 | QPtrList<Incidence> Calendar::incidences() | 276 | Q3PtrList<Incidence> Calendar::incidences() |
275 | { | 277 | { |
276 | QPtrList<Incidence> incidences; | 278 | Q3PtrList<Incidence> incidences; |
277 | 279 | ||
278 | Incidence *i; | 280 | Incidence *i; |
279 | 281 | ||
280 | QPtrList<Event> e = events(); | 282 | Q3PtrList<Event> e = events(); |
281 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 283 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
282 | 284 | ||
283 | QPtrList<Todo> t = todos(); | 285 | Q3PtrList<Todo> t = todos(); |
284 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 286 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
285 | 287 | ||
286 | QPtrList<Journal> j = journals(); | 288 | Q3PtrList<Journal> j = journals(); |
287 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 289 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
288 | 290 | ||
289 | return incidences; | 291 | return incidences; |
290 | } | 292 | } |
291 | 293 | ||
292 | void Calendar::resetPilotStat(int id ) | 294 | void Calendar::resetPilotStat(int id ) |
293 | { | 295 | { |
294 | QPtrList<Incidence> incidences; | 296 | Q3PtrList<Incidence> incidences; |
295 | 297 | ||
296 | Incidence *i; | 298 | Incidence *i; |
297 | 299 | ||
298 | QPtrList<Event> e = rawEvents(); | 300 | Q3PtrList<Event> e = rawEvents(); |
299 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); | 301 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
300 | 302 | ||
301 | QPtrList<Todo> t = rawTodos(); | 303 | Q3PtrList<Todo> t = rawTodos(); |
302 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); | 304 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
303 | 305 | ||
304 | QPtrList<Journal> j = journals(); | 306 | Q3PtrList<Journal> j = journals(); |
305 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); | 307 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
306 | } | 308 | } |
307 | void Calendar::resetTempSyncStat() | 309 | void Calendar::resetTempSyncStat() |
308 | { | 310 | { |
309 | QPtrList<Incidence> incidences; | 311 | Q3PtrList<Incidence> incidences; |
310 | 312 | ||
311 | Incidence *i; | 313 | Incidence *i; |
312 | 314 | ||
313 | QPtrList<Event> e = rawEvents(); | 315 | Q3PtrList<Event> e = rawEvents(); |
314 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 316 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
315 | 317 | ||
316 | QPtrList<Todo> t = rawTodos(); | 318 | Q3PtrList<Todo> t = rawTodos(); |
317 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 319 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
318 | 320 | ||
319 | QPtrList<Journal> j = journals(); | 321 | Q3PtrList<Journal> j = journals(); |
320 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 322 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
321 | } | 323 | } |
322 | QPtrList<Incidence> Calendar::rawIncidences() | 324 | Q3PtrList<Incidence> Calendar::rawIncidences() |
323 | { | 325 | { |
324 | QPtrList<Incidence> incidences; | 326 | Q3PtrList<Incidence> incidences; |
325 | 327 | ||
326 | Incidence *i; | 328 | Incidence *i; |
327 | 329 | ||
328 | QPtrList<Event> e = rawEvents(); | 330 | Q3PtrList<Event> e = rawEvents(); |
329 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 331 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
330 | 332 | ||
331 | QPtrList<Todo> t = rawTodos(); | 333 | Q3PtrList<Todo> t = rawTodos(); |
332 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 334 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
333 | 335 | ||
334 | QPtrList<Journal> j = journals(); | 336 | Q3PtrList<Journal> j = journals(); |
335 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 337 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
336 | 338 | ||
337 | return incidences; | 339 | return incidences; |
338 | } | 340 | } |
339 | 341 | ||
340 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 342 | Q3PtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
341 | { | 343 | { |
342 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 344 | Q3PtrList<Event> el = rawEventsForDate(date,sorted); |
343 | mFilter->apply(&el); | 345 | mFilter->apply(&el); |
344 | return el; | 346 | return el; |
345 | } | 347 | } |
346 | 348 | ||
347 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 349 | Q3PtrList<Event> Calendar::events( const QDateTime &qdt ) |
348 | { | 350 | { |
349 | QPtrList<Event> el = rawEventsForDate(qdt); | 351 | Q3PtrList<Event> el = rawEventsForDate(qdt); |
350 | mFilter->apply(&el); | 352 | mFilter->apply(&el); |
351 | return el; | 353 | return el; |
352 | } | 354 | } |
353 | 355 | ||
354 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 356 | Q3PtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
355 | bool inclusive) | 357 | bool inclusive) |
356 | { | 358 | { |
357 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 359 | Q3PtrList<Event> el = rawEvents(start,end,inclusive); |
358 | mFilter->apply(&el); | 360 | mFilter->apply(&el); |
359 | return el; | 361 | return el; |
360 | } | 362 | } |
361 | 363 | ||
362 | QPtrList<Event> Calendar::events() | 364 | Q3PtrList<Event> Calendar::events() |
363 | { | 365 | { |
364 | QPtrList<Event> el = rawEvents(); | 366 | Q3PtrList<Event> el = rawEvents(); |
365 | mFilter->apply(&el); | 367 | mFilter->apply(&el); |
366 | return el; | 368 | return el; |
367 | } | 369 | } |
368 | void Calendar::addIncidenceBranch(Incidence *i) | 370 | void Calendar::addIncidenceBranch(Incidence *i) |
369 | { | 371 | { |
370 | addIncidence( i ); | 372 | addIncidence( i ); |
371 | Incidence * inc; | 373 | Incidence * inc; |
372 | QPtrList<Incidence> Relations = i->relations(); | 374 | Q3PtrList<Incidence> Relations = i->relations(); |
373 | for (inc=Relations.first();inc;inc=Relations.next()) { | 375 | for (inc=Relations.first();inc;inc=Relations.next()) { |
374 | addIncidenceBranch( inc ); | 376 | addIncidenceBranch( inc ); |
375 | } | 377 | } |
376 | } | 378 | } |
377 | 379 | ||
378 | bool Calendar::addIncidence(Incidence *i) | 380 | bool Calendar::addIncidence(Incidence *i) |
379 | { | 381 | { |
380 | Incidence::AddVisitor<Calendar> v(this); | 382 | Incidence::AddVisitor<Calendar> v(this); |
@@ -402,19 +404,19 @@ Incidence* Calendar::incidence( const QString& uid ) | |||
402 | if( (i = event( uid )) != 0 ) | 404 | if( (i = event( uid )) != 0 ) |
403 | return i; | 405 | return i; |
404 | if( (i = journal( uid )) != 0 ) | 406 | if( (i = journal( uid )) != 0 ) |
405 | return i; | 407 | return i; |
406 | 408 | ||
407 | return 0; | 409 | return 0; |
408 | } | 410 | } |
409 | 411 | ||
410 | QPtrList<Todo> Calendar::todos() | 412 | Q3PtrList<Todo> Calendar::todos() |
411 | { | 413 | { |
412 | QPtrList<Todo> tl = rawTodos(); | 414 | Q3PtrList<Todo> tl = rawTodos(); |
413 | mFilter->apply( &tl ); | 415 | mFilter->apply( &tl ); |
414 | return tl; | 416 | return tl; |
415 | } | 417 | } |
416 | 418 | ||
417 | // When this is called, the todo have already been added to the calendar. | 419 | // When this is called, the todo have already been added to the calendar. |
418 | // This method is only about linking related todos | 420 | // This method is only about linking related todos |
419 | void Calendar::setupRelations( Incidence *incidence ) | 421 | void Calendar::setupRelations( Incidence *incidence ) |
420 | { | 422 | { |
@@ -450,49 +452,49 @@ void Calendar::setupRelations( Incidence *incidence ) | |||
450 | } | 452 | } |
451 | 453 | ||
452 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 454 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
453 | void Calendar::removeRelations( Incidence *incidence ) | 455 | void Calendar::removeRelations( Incidence *incidence ) |
454 | { | 456 | { |
455 | // qDebug("Calendar::removeRelations "); | 457 | // qDebug("Calendar::removeRelations "); |
456 | QString uid = incidence->uid(); | 458 | QString uid = incidence->uid(); |
457 | 459 | ||
458 | QPtrList<Incidence> relations = incidence->relations(); | 460 | Q3PtrList<Incidence> relations = incidence->relations(); |
459 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 461 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
460 | if( !mOrphanUids.find( i->uid() ) ) { | 462 | if( !mOrphanUids.find( i->uid() ) ) { |
461 | mOrphans.insert( uid, i ); | 463 | mOrphans.insert( uid, i ); |
462 | mOrphanUids.insert( i->uid(), i ); | 464 | mOrphanUids.insert( i->uid(), i ); |
463 | i->setRelatedTo( 0 ); | 465 | i->setRelatedTo( 0 ); |
464 | i->setRelatedToUid( uid ); | 466 | i->setRelatedToUid( uid ); |
465 | } | 467 | } |
466 | 468 | ||
467 | // If this incidence is related to something else, tell that about it | 469 | // If this incidence is related to something else, tell that about it |
468 | if( incidence->relatedTo() ) | 470 | if( incidence->relatedTo() ) |
469 | incidence->relatedTo()->removeRelation( incidence ); | 471 | incidence->relatedTo()->removeRelation( incidence ); |
470 | 472 | ||
471 | // Remove this one from the orphans list | 473 | // Remove this one from the orphans list |
472 | if( mOrphanUids.remove( uid ) ) { | 474 | if( mOrphanUids.remove( uid ) ) { |
473 | QString r2uid = incidence->relatedToUid(); | 475 | QString r2uid = incidence->relatedToUid(); |
474 | QPtrList<Incidence> tempList; | 476 | Q3PtrList<Incidence> tempList; |
475 | while( Incidence* i = mOrphans[ r2uid ] ) { | 477 | while( Incidence* i = mOrphans[ r2uid ] ) { |
476 | mOrphans.remove( r2uid ); | 478 | mOrphans.remove( r2uid ); |
477 | if ( i != incidence ) tempList.append( i ); | 479 | if ( i != incidence ) tempList.append( i ); |
478 | } | 480 | } |
479 | Incidence* inc = tempList.first(); | 481 | Incidence* inc = tempList.first(); |
480 | while ( inc ) { | 482 | while ( inc ) { |
481 | mOrphans.insert( r2uid, inc ); | 483 | mOrphans.insert( r2uid, inc ); |
482 | inc = tempList.next(); | 484 | inc = tempList.next(); |
483 | } | 485 | } |
484 | } | 486 | } |
485 | // LR: and another big bad bug found | 487 | // LR: and another big bad bug found |
486 | #if 0 | 488 | #if 0 |
487 | // This incidence is located in the orphans list - it should be removed | 489 | // This incidence is located in the orphans list - it should be removed |
488 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 490 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
489 | // Removing wasn't that easy | 491 | // Removing wasn't that easy |
490 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 492 | for( Q3DictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
491 | if( it.current()->uid() == uid ) { | 493 | if( it.current()->uid() == uid ) { |
492 | mOrphans.remove( it.currentKey() ); | 494 | mOrphans.remove( it.currentKey() ); |
493 | break; | 495 | break; |
494 | } | 496 | } |
495 | } | 497 | } |
496 | } | 498 | } |
497 | #endif | 499 | #endif |
498 | } | 500 | } |