summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 1350f6d..9b38d3f 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -326,201 +326,201 @@ QPtrList<Incidence> Calendar::rawIncidences()
326 Incidence *i; 326 Incidence *i;
327 327
328 QPtrList<Event> e = rawEvents(); 328 QPtrList<Event> e = rawEvents();
329 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 329 for( i = e.first(); i; i = e.next() ) incidences.append( i );
330 330
331 QPtrList<Todo> t = rawTodos(); 331 QPtrList<Todo> t = rawTodos();
332 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 332 for( i = t.first(); i; i = t.next() ) incidences.append( i );
333 333
334 QPtrList<Journal> j = journals(); 334 QPtrList<Journal> j = journals();
335 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 335 for( i = j.first(); i; i = j.next() ) incidences.append( i );
336 336
337 return incidences; 337 return incidences;
338} 338}
339 339
340QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 340QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
341{ 341{
342 QPtrList<Event> el = rawEventsForDate(date,sorted); 342 QPtrList<Event> el = rawEventsForDate(date,sorted);
343 mFilter->apply(&el); 343 mFilter->apply(&el);
344 return el; 344 return el;
345} 345}
346 346
347QPtrList<Event> Calendar::events( const QDateTime &qdt ) 347QPtrList<Event> Calendar::events( const QDateTime &qdt )
348{ 348{
349 QPtrList<Event> el = rawEventsForDate(qdt); 349 QPtrList<Event> el = rawEventsForDate(qdt);
350 mFilter->apply(&el); 350 mFilter->apply(&el);
351 return el; 351 return el;
352} 352}
353 353
354QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 354QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
355 bool inclusive) 355 bool inclusive)
356{ 356{
357 QPtrList<Event> el = rawEvents(start,end,inclusive); 357 QPtrList<Event> el = rawEvents(start,end,inclusive);
358 mFilter->apply(&el); 358 mFilter->apply(&el);
359 return el; 359 return el;
360} 360}
361 361
362QPtrList<Event> Calendar::events() 362QPtrList<Event> Calendar::events()
363{ 363{
364 QPtrList<Event> el = rawEvents(); 364 QPtrList<Event> el = rawEvents();
365 mFilter->apply(&el); 365 mFilter->apply(&el);
366 return el; 366 return el;
367} 367}
368void Calendar::addIncidenceBranch(Incidence *i) 368void Calendar::addIncidenceBranch(Incidence *i)
369{ 369{
370 addIncidence( i ); 370 addIncidence( i );
371 Incidence * inc; 371 Incidence * inc;
372 QPtrList<Incidence> Relations = i->relations(); 372 QPtrList<Incidence> Relations = i->relations();
373 for (inc=Relations.first();inc;inc=Relations.next()) { 373 for (inc=Relations.first();inc;inc=Relations.next()) {
374 addIncidenceBranch( inc ); 374 addIncidenceBranch( inc );
375 } 375 }
376} 376}
377 377
378bool Calendar::addIncidence(Incidence *i) 378bool Calendar::addIncidence(Incidence *i)
379{ 379{
380 Incidence::AddVisitor<Calendar> v(this); 380 Incidence::AddVisitor<Calendar> v(this);
381 if ( i->calID() == 0 ) 381 if ( i->calID() == 0 )
382 i->setCalID_block( mDefaultCalendar ); 382 i->setCalID_block( mDefaultCalendar );
383 i->setCalEnabled( true ); 383 i->setCalEnabled( true );
384 return i->accept(v); 384 return i->accept(v);
385} 385}
386void Calendar::deleteIncidence(Incidence *in) 386void Calendar::deleteIncidence(Incidence *in)
387{ 387{
388 if ( in->typeID() == eventID ) 388 if ( in->typeID() == eventID )
389 deleteEvent( (Event*) in ); 389 deleteEvent( (Event*) in );
390 else if ( in->typeID() == todoID ) 390 else if ( in->typeID() == todoID )
391 deleteTodo( (Todo*) in); 391 deleteTodo( (Todo*) in);
392 else if ( in->typeID() == journalID ) 392 else if ( in->typeID() == journalID )
393 deleteJournal( (Journal*) in ); 393 deleteJournal( (Journal*) in );
394} 394}
395 395
396Incidence* Calendar::incidence( const QString& uid ) 396Incidence* Calendar::incidence( const QString& uid )
397{ 397{
398 Incidence* i; 398 Incidence* i;
399 399
400 if( (i = todo( uid )) != 0 ) 400 if( (i = todo( uid )) != 0 )
401 return i; 401 return i;
402 if( (i = event( uid )) != 0 ) 402 if( (i = event( uid )) != 0 )
403 return i; 403 return i;
404 if( (i = journal( uid )) != 0 ) 404 if( (i = journal( uid )) != 0 )
405 return i; 405 return i;
406 406
407 return 0; 407 return 0;
408} 408}
409 409
410QPtrList<Todo> Calendar::todos() 410QPtrList<Todo> Calendar::todos()
411{ 411{
412 QPtrList<Todo> tl = rawTodos(); 412 QPtrList<Todo> tl = rawTodos();
413 mFilter->apply( &tl ); 413 mFilter->apply( &tl );
414 return tl; 414 return tl;
415} 415}
416 416
417// When this is called, the todo have already been added to the calendar. 417// When this is called, the todo have already been added to the calendar.
418// This method is only about linking related todos 418// This method is only about linking related todos
419void Calendar::setupRelations( Incidence *incidence ) 419void Calendar::setupRelations( Incidence *incidence )
420{ 420{
421 QString uid = incidence->uid(); 421 QString uid = incidence->uid();
422 //qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); 422 qDebug("Calendar::setupRelations %s", incidence->summary().latin1());
423 // 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
424 while( Incidence* i = mOrphans[ uid ] ) { 424 while( Incidence* i = mOrphans[ uid ] ) {
425 mOrphans.remove( uid ); 425 mOrphans.remove( uid );
426 i->setRelatedTo( incidence ); 426 i->setRelatedTo( incidence );
427 //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1()); 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() );
430 } 430 }
431 431
432 // Now see about this incidences parent 432 // Now see about this incidences parent
433 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 433 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
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 //qDebug("Test parent for %s", incidence->summary().latin1()); 436 qDebug("Test parent for %s", incidence->summary().latin1());
437 Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true ); 437 Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true );
438 if( parent ) { 438 if( parent ) {
439 // Found it 439 // Found it
440 // qDebug("parent found for for %s", incidence->summary().latin1()); 440 qDebug("parent found for for %s", incidence->summary().latin1());
441 incidence->setRelatedTo( parent ); 441 incidence->setRelatedTo( parent );
442 parent->addRelation( incidence ); 442 parent->addRelation( incidence );
443 } else { 443 } else {
444 // qDebug("NO parent found for for %s", incidence->summary().latin1()); 444 qDebug("NO parent found for for %s", incidence->summary().latin1());
445 // Not found, put this in the mOrphans list 445 // Not found, put this in the mOrphans list
446 mOrphans.insert( incidence->relatedToUid(), incidence ); 446 mOrphans.insert( incidence->relatedToUid(), incidence );
447 mOrphanUids.insert( incidence->uid(), incidence ); 447 mOrphanUids.insert( incidence->uid(), incidence );
448 } 448 }
449 } 449 }
450} 450}
451 451
452// If a task with subtasks is deleted, move it's subtasks to the orphans list 452// If a task with subtasks is deleted, move it's subtasks to the orphans list
453void Calendar::removeRelations( Incidence *incidence ) 453void Calendar::removeRelations( Incidence *incidence )
454{ 454{
455 // qDebug("Calendar::removeRelations "); 455 // qDebug("Calendar::removeRelations ");
456 QString uid = incidence->uid(); 456 QString uid = incidence->uid();
457 457
458 QPtrList<Incidence> relations = incidence->relations(); 458 QPtrList<Incidence> relations = incidence->relations();
459 for( Incidence* i = relations.first(); i; i = relations.next() ) 459 for( Incidence* i = relations.first(); i; i = relations.next() )
460 if( !mOrphanUids.find( i->uid() ) ) { 460 if( !mOrphanUids.find( i->uid() ) ) {
461 mOrphans.insert( uid, i ); 461 mOrphans.insert( uid, i );
462 mOrphanUids.insert( i->uid(), i ); 462 mOrphanUids.insert( i->uid(), i );
463 i->setRelatedTo( 0 ); 463 i->setRelatedTo( 0 );
464 i->setRelatedToUid( uid ); 464 i->setRelatedToUid( uid );
465 } 465 }
466 466
467 // If this incidence is related to something else, tell that about it 467 // If this incidence is related to something else, tell that about it
468 if( incidence->relatedTo() ) 468 if( incidence->relatedTo() )
469 incidence->relatedTo()->removeRelation( incidence ); 469 incidence->relatedTo()->removeRelation( incidence );
470 470
471 // Remove this one from the orphans list 471 // Remove this one from the orphans list
472 if( mOrphanUids.remove( uid ) ) { 472 if( mOrphanUids.remove( uid ) ) {
473 QString r2uid = incidence->relatedToUid(); 473 QString r2uid = incidence->relatedToUid();
474 QPtrList<Incidence> tempList; 474 QPtrList<Incidence> tempList;
475 while( Incidence* i = mOrphans[ r2uid ] ) { 475 while( Incidence* i = mOrphans[ r2uid ] ) {
476 mOrphans.remove( r2uid ); 476 mOrphans.remove( r2uid );
477 if ( i != incidence ) tempList.append( i ); 477 if ( i != incidence ) tempList.append( i );
478 } 478 }
479 Incidence* inc = tempList.first(); 479 Incidence* inc = tempList.first();
480 while ( inc ) { 480 while ( inc ) {
481 mOrphans.insert( r2uid, inc ); 481 mOrphans.insert( r2uid, inc );
482 inc = tempList.next(); 482 inc = tempList.next();
483 } 483 }
484 } 484 }
485 // LR: and another big bad bug found 485 // LR: and another big bad bug found
486#if 0 486#if 0
487 // This incidence is located in the orphans list - it should be removed 487 // This incidence is located in the orphans list - it should be removed
488 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 488 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
489 // Removing wasn't that easy 489 // Removing wasn't that easy
490 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 490 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
491 if( it.current()->uid() == uid ) { 491 if( it.current()->uid() == uid ) {
492 mOrphans.remove( it.currentKey() ); 492 mOrphans.remove( it.currentKey() );
493 break; 493 break;
494 } 494 }
495 } 495 }
496 } 496 }
497#endif 497#endif
498} 498}
499 499
500void Calendar::registerObserver( Observer *observer ) 500void Calendar::registerObserver( Observer *observer )
501{ 501{
502 mObserver = observer; 502 mObserver = observer;
503 mNewObserver = true; 503 mNewObserver = true;
504} 504}
505 505
506void Calendar::setModified( bool modified ) 506void Calendar::setModified( bool modified )
507{ 507{
508 if ( mObserver ) mObserver->calendarModified( modified, this ); 508 if ( mObserver ) mObserver->calendarModified( modified, this );
509 if ( modified != mModified || mNewObserver ) { 509 if ( modified != mModified || mNewObserver ) {
510 mNewObserver = false; 510 mNewObserver = false;
511 // if ( mObserver ) mObserver->calendarModified( modified, this ); 511 // if ( mObserver ) mObserver->calendarModified( modified, this );
512 mModified = modified; 512 mModified = modified;
513 } 513 }
514} 514}
515 515
516void Calendar::setLoadedProductId( const QString &id ) 516void Calendar::setLoadedProductId( const QString &id )
517{ 517{
518 mLoadedProductId = id; 518 mLoadedProductId = id;
519} 519}
520 520
521QString Calendar::loadedProductId() 521QString Calendar::loadedProductId()
522{ 522{
523 return mLoadedProductId; 523 return mLoadedProductId;
524} 524}
525 525
526//#include "calendar.moc" 526//#include "calendar.moc"