summaryrefslogtreecommitdiffabout
path: root/libkcal/calendar.cpp
authorzautrix <zautrix>2005-06-13 13:57:22 (UTC)
committer zautrix <zautrix>2005-06-13 13:57:22 (UTC)
commit56de219c5ce910a470a01a0e5003d1a113837ef4 (patch) (unidiff)
tree3393cb306cec8dcdc05d6ed0fae3ae7d374f2794 /libkcal/calendar.cpp
parent4f3ff02932b39bf16b9692c3cb69c101a28b4616 (diff)
downloadkdepimpi-56de219c5ce910a470a01a0e5003d1a113837ef4.zip
kdepimpi-56de219c5ce910a470a01a0e5003d1a113837ef4.tar.gz
kdepimpi-56de219c5ce910a470a01a0e5003d1a113837ef4.tar.bz2
fixxx
Diffstat (limited to 'libkcal/calendar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp54
1 files changed, 27 insertions, 27 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 5092d1a..a662eeb 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -337,152 +337,152 @@ QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
337 bool inclusive) 337 bool inclusive)
338{ 338{
339 QPtrList<Event> el = rawEvents(start,end,inclusive); 339 QPtrList<Event> el = rawEvents(start,end,inclusive);
340 mFilter->apply(&el); 340 mFilter->apply(&el);
341 return el; 341 return el;
342} 342}
343 343
344QPtrList<Event> Calendar::events() 344QPtrList<Event> Calendar::events()
345{ 345{
346 QPtrList<Event> el = rawEvents(); 346 QPtrList<Event> el = rawEvents();
347 mFilter->apply(&el); 347 mFilter->apply(&el);
348 return el; 348 return el;
349} 349}
350void Calendar::addIncidenceBranch(Incidence *i) 350void Calendar::addIncidenceBranch(Incidence *i)
351{ 351{
352 addIncidence( i ); 352 addIncidence( i );
353 Incidence * inc; 353 Incidence * inc;
354 QPtrList<Incidence> Relations = i->relations(); 354 QPtrList<Incidence> Relations = i->relations();
355 for (inc=Relations.first();inc;inc=Relations.next()) { 355 for (inc=Relations.first();inc;inc=Relations.next()) {
356 addIncidenceBranch( inc ); 356 addIncidenceBranch( inc );
357 } 357 }
358} 358}
359 359
360bool Calendar::addIncidence(Incidence *i) 360bool Calendar::addIncidence(Incidence *i)
361{ 361{
362 Incidence::AddVisitor<Calendar> v(this); 362 Incidence::AddVisitor<Calendar> v(this);
363 i->setCalID( mDefaultCalendar ); 363 i->setCalID( mDefaultCalendar );
364 i->setCalEnabled( true ); 364 i->setCalEnabled( true );
365 return i->accept(v); 365 return i->accept(v);
366} 366}
367void Calendar::deleteIncidence(Incidence *in) 367void Calendar::deleteIncidence(Incidence *in)
368{ 368{
369 if ( in->typeID() == eventID ) 369 if ( in->typeID() == eventID )
370 deleteEvent( (Event*) in ); 370 deleteEvent( (Event*) in );
371 else if ( in->typeID() == todoID ) 371 else if ( in->typeID() == todoID )
372 deleteTodo( (Todo*) in); 372 deleteTodo( (Todo*) in);
373 else if ( in->typeID() == journalID ) 373 else if ( in->typeID() == journalID )
374 deleteJournal( (Journal*) in ); 374 deleteJournal( (Journal*) in );
375} 375}
376 376
377Incidence* Calendar::incidence( const QString& uid ) 377Incidence* Calendar::incidence( const QString& uid )
378{ 378{
379 Incidence* i; 379 Incidence* i;
380 380
381 if( (i = todo( uid )) != 0 ) 381 if( (i = todo( uid )) != 0 )
382 return i; 382 return i;
383 if( (i = event( uid )) != 0 ) 383 if( (i = event( uid )) != 0 )
384 return i; 384 return i;
385 if( (i = journal( uid )) != 0 ) 385 if( (i = journal( uid )) != 0 )
386 return i; 386 return i;
387 387
388 return 0; 388 return 0;
389} 389}
390 390
391QPtrList<Todo> Calendar::todos() 391QPtrList<Todo> Calendar::todos()
392{ 392{
393 QPtrList<Todo> tl = rawTodos(); 393 QPtrList<Todo> tl = rawTodos();
394 mFilter->apply( &tl ); 394 mFilter->apply( &tl );
395 return tl; 395 return tl;
396} 396}
397 397
398// When this is called, the todo have already been added to the calendar. 398// When this is called, the todo have already been added to the calendar.
399// This method is only about linking related todos 399// This method is only about linking related todos
400void Calendar::setupRelations( Incidence *incidence ) 400void Calendar::setupRelations( Incidence *incidence )
401{ 401{
402 QString uid = incidence->uid(); 402 QString uid = incidence->uid();
403 //qDebug("Calendar::setupRelations "); 403 //qDebug("Calendar::setupRelations ");
404 // First, go over the list of orphans and see if this is their parent 404 // First, go over the list of orphans and see if this is their parent
405 while( Incidence* i = mOrphans[ uid ] ) { 405 while( Incidence* i = mOrphans[ uid ] ) {
406 mOrphans.remove( uid ); 406 mOrphans.remove( uid );
407 i->setRelatedTo( incidence ); 407 i->setRelatedTo( incidence );
408 incidence->addRelation( i ); 408 incidence->addRelation( i );
409 mOrphanUids.remove( i->uid() ); 409 mOrphanUids.remove( i->uid() );
410 } 410 }
411 411
412 // Now see about this incidences parent 412 // Now see about this incidences parent
413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
414 // This incidence has a uid it is related to, but is not registered to it yet 414 // This incidence has a uid it is related to, but is not registered to it yet
415 // Try to find it 415 // Try to find it
416 Incidence* parent = this->incidence( incidence->relatedToUid() ); 416 Incidence* parent = this->incidence( incidence->relatedToUid() );
417 if( parent ) { 417 if( parent ) {
418 // Found it 418 // Found it
419 incidence->setRelatedTo( parent ); 419 incidence->setRelatedTo( parent );
420 parent->addRelation( incidence ); 420 parent->addRelation( incidence );
421 } else { 421 } else {
422 // Not found, put this in the mOrphans list 422 // Not found, put this in the mOrphans list
423 mOrphans.insert( incidence->relatedToUid(), incidence ); 423 mOrphans.insert( incidence->relatedToUid(), incidence );
424 mOrphanUids.insert( incidence->uid(), incidence ); 424 mOrphanUids.insert( incidence->uid(), incidence );
425 } 425 }
426 } 426 }
427} 427}
428 428
429// If a task with subtasks is deleted, move it's subtasks to the orphans list 429// If a task with subtasks is deleted, move it's subtasks to the orphans list
430void Calendar::removeRelations( Incidence *incidence ) 430void Calendar::removeRelations( Incidence *incidence )
431{ 431{
432 // qDebug("Calendar::removeRelations "); 432 // qDebug("Calendar::removeRelations ");
433 QString uid = incidence->uid(); 433 QString uid = incidence->uid();
434 434
435 QPtrList<Incidence> relations = incidence->relations(); 435 QPtrList<Incidence> relations = incidence->relations();
436 for( Incidence* i = relations.first(); i; i = relations.next() ) 436 for( Incidence* i = relations.first(); i; i = relations.next() )
437 if( !mOrphanUids.find( i->uid() ) ) { 437 if( !mOrphanUids.find( i->uid() ) ) {
438 mOrphans.insert( uid, i ); 438 mOrphans.insert( uid, i );
439 mOrphanUids.insert( i->uid(), i ); 439 mOrphanUids.insert( i->uid(), i );
440 i->setRelatedTo( 0 ); 440 i->setRelatedTo( 0 );
441 i->setRelatedToUid( uid ); 441 i->setRelatedToUid( uid );
442 } 442 }
443 443
444 // If this incidence is related to something else, tell that about it 444 // If this incidence is related to something else, tell that about it
445 if( incidence->relatedTo() ) 445 if( incidence->relatedTo() )
446 incidence->relatedTo()->removeRelation( incidence ); 446 incidence->relatedTo()->removeRelation( incidence );
447 447
448 // Remove this one from the orphans list 448 // Remove this one from the orphans list
449 if( mOrphanUids.remove( uid ) ) 449 if( mOrphanUids.remove( uid ) )
450 // This incidence is located in the orphans list - it should be removed 450 // This incidence is located in the orphans list - it should be removed
451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
452 // Removing wasn't that easy 452 // Removing wasn't that easy
453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
454 if( it.current()->uid() == uid ) { 454 if( it.current()->uid() == uid ) {
455 mOrphans.remove( it.currentKey() ); 455 mOrphans.remove( it.currentKey() );
456 break; 456 break;
457 } 457 }
458 } 458 }
459 } 459 }
460} 460}
461 461
462void Calendar::registerObserver( Observer *observer ) 462void Calendar::registerObserver( Observer *observer )
463{ 463{
464 mObserver = observer; 464 mObserver = observer;
465 mNewObserver = true; 465 mNewObserver = true;
466} 466}
467 467
468void Calendar::setModified( bool modified ) 468void Calendar::setModified( bool modified )
469{ 469{
470 if ( mObserver ) mObserver->calendarModified( modified, this ); 470 if ( mObserver ) mObserver->calendarModified( modified, this );
471 if ( modified != mModified || mNewObserver ) { 471 if ( modified != mModified || mNewObserver ) {
472 mNewObserver = false; 472 mNewObserver = false;
473 // if ( mObserver ) mObserver->calendarModified( modified, this ); 473 // if ( mObserver ) mObserver->calendarModified( modified, this );
474 mModified = modified; 474 mModified = modified;
475 } 475 }
476} 476}
477 477
478void Calendar::setLoadedProductId( const QString &id ) 478void Calendar::setLoadedProductId( const QString &id )
479{ 479{
480 mLoadedProductId = id; 480 mLoadedProductId = id;
481} 481}
482 482
483QString Calendar::loadedProductId() 483QString Calendar::loadedProductId()
484{ 484{
485 return mLoadedProductId; 485 return mLoadedProductId;
486} 486}
487 487
488//#include "calendar.moc" 488//#include "calendar.moc"