-rw-r--r-- | libkcal/incidence.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index fe9f854..7dd9bd2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -459,128 +459,134 @@ void Incidence::setCategories(const QStringList &categories, bool setForRelation | |||
459 | if (mReadOnly) return; | 459 | if (mReadOnly) return; |
460 | mCategories = categories; | 460 | mCategories = categories; |
461 | checkCategories(); | 461 | checkCategories(); |
462 | updated(); | 462 | updated(); |
463 | if ( setForRelations ) { | 463 | if ( setForRelations ) { |
464 | Incidence * inc; | 464 | Incidence * inc; |
465 | QPtrList<Incidence> Relations = relations(); | 465 | QPtrList<Incidence> Relations = relations(); |
466 | for (inc=Relations.first();inc;inc=Relations.next()) { | 466 | for (inc=Relations.first();inc;inc=Relations.next()) { |
467 | inc->setCategories( categories, true ); | 467 | inc->setCategories( categories, true ); |
468 | } | 468 | } |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | // TODO: remove setCategories(QString) function | 472 | // TODO: remove setCategories(QString) function |
473 | void Incidence::setCategories(const QString &catStr) | 473 | void Incidence::setCategories(const QString &catStr) |
474 | { | 474 | { |
475 | if (mReadOnly) return; | 475 | if (mReadOnly) return; |
476 | mCategories.clear(); | 476 | mCategories.clear(); |
477 | 477 | ||
478 | if (catStr.isEmpty()) return; | 478 | if (catStr.isEmpty()) return; |
479 | 479 | ||
480 | mCategories = QStringList::split(",",catStr); | 480 | mCategories = QStringList::split(",",catStr); |
481 | 481 | ||
482 | QStringList::Iterator it; | 482 | QStringList::Iterator it; |
483 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 483 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
484 | *it = (*it).stripWhiteSpace(); | 484 | *it = (*it).stripWhiteSpace(); |
485 | } | 485 | } |
486 | checkCategories(); | 486 | checkCategories(); |
487 | updated(); | 487 | updated(); |
488 | } | 488 | } |
489 | // using this makes filtering 3 times faster | 489 | // using this makes filtering 3 times faster |
490 | QStringList* Incidence::categoriesP() | 490 | QStringList* Incidence::categoriesP() |
491 | { | 491 | { |
492 | return &mCategories; | 492 | return &mCategories; |
493 | } | 493 | } |
494 | 494 | ||
495 | QStringList Incidence::categories() const | 495 | QStringList Incidence::categories() const |
496 | { | 496 | { |
497 | return mCategories; | 497 | return mCategories; |
498 | } | 498 | } |
499 | 499 | ||
500 | QString Incidence::categoriesStr() | 500 | QString Incidence::categoriesStr() |
501 | { | 501 | { |
502 | return mCategories.join(","); | 502 | return mCategories.join(","); |
503 | } | 503 | } |
504 | QString Incidence::categoriesStrWithSpace() | 504 | QString Incidence::categoriesStrWithSpace() |
505 | { | 505 | { |
506 | return mCategories.join(", "); | 506 | return mCategories.join(", "); |
507 | } | 507 | } |
508 | 508 | ||
509 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 509 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
510 | { | 510 | { |
511 | if (mReadOnly) return; | 511 | if (mReadOnly) return; |
512 | mRelatedToUid = relatedToUid; | 512 | mRelatedToUid = relatedToUid; |
513 | } | 513 | } |
514 | void Incidence::clearRelations() | 514 | void Incidence::clearRelations() |
515 | { | 515 | { |
516 | mRelatedTo = 0; | 516 | mRelatedTo = 0; |
517 | mRelations.clear(); | 517 | mRelations.clear(); |
518 | } | 518 | } |
519 | QString Incidence::relatedToUid() const | 519 | QString Incidence::relatedToUid() const |
520 | { | 520 | { |
521 | return mRelatedToUid; | 521 | return mRelatedToUid; |
522 | } | 522 | } |
523 | void Incidence::resetRelatedTo() | ||
524 | { | ||
525 | QString store = mRelatedToUid; | ||
526 | setRelatedTo( 0 ); | ||
527 | mRelatedToUid = store; | ||
528 | } | ||
523 | 529 | ||
524 | void Incidence::setRelatedTo(Incidence *relatedTo) | 530 | void Incidence::setRelatedTo(Incidence *relatedTo) |
525 | { | 531 | { |
526 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 532 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
527 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 533 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
528 | if (mReadOnly || mRelatedTo == relatedTo) return; | 534 | if (mReadOnly || mRelatedTo == relatedTo) return; |
529 | if(mRelatedTo) { | 535 | if(mRelatedTo) { |
530 | // updated(); | 536 | // updated(); |
531 | mRelatedTo->removeRelation(this); | 537 | mRelatedTo->removeRelation(this); |
532 | } | 538 | } |
533 | mRelatedTo = relatedTo; | 539 | mRelatedTo = relatedTo; |
534 | if (mRelatedTo) { | 540 | if (mRelatedTo) { |
535 | mRelatedTo->addRelation(this); | 541 | mRelatedTo->addRelation(this); |
536 | mRelatedToUid = mRelatedTo->uid(); | 542 | mRelatedToUid = mRelatedTo->uid(); |
537 | } else { | 543 | } else { |
538 | mRelatedToUid = ""; | 544 | mRelatedToUid = ""; |
539 | } | 545 | } |
540 | } | 546 | } |
541 | 547 | ||
542 | Incidence *Incidence::relatedTo() const | 548 | Incidence *Incidence::relatedTo() const |
543 | { | 549 | { |
544 | return mRelatedTo; | 550 | return mRelatedTo; |
545 | } | 551 | } |
546 | 552 | ||
547 | QPtrList<Incidence> Incidence::relations() const | 553 | QPtrList<Incidence> Incidence::relations() const |
548 | { | 554 | { |
549 | return mRelations; | 555 | return mRelations; |
550 | } | 556 | } |
551 | 557 | ||
552 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 558 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
553 | { | 559 | { |
554 | Incidence* inc; | 560 | Incidence* inc; |
555 | QPtrList<Incidence> Relations = relations(); | 561 | QPtrList<Incidence> Relations = relations(); |
556 | for (inc=Relations.first();inc;inc=Relations.next()) { | 562 | for (inc=Relations.first();inc;inc=Relations.next()) { |
557 | inc->addRelationsToList( rel ); | 563 | inc->addRelationsToList( rel ); |
558 | } | 564 | } |
559 | if ( rel->findRef( this ) == -1 ) | 565 | if ( rel->findRef( this ) == -1 ) |
560 | rel->append( this ); | 566 | rel->append( this ); |
561 | } | 567 | } |
562 | 568 | ||
563 | void Incidence::addRelation(Incidence *event) | 569 | void Incidence::addRelation(Incidence *event) |
564 | { | 570 | { |
565 | setLastModifiedSubInvalid(); | 571 | setLastModifiedSubInvalid(); |
566 | if( mRelations.findRef( event ) == -1 ) { | 572 | if( mRelations.findRef( event ) == -1 ) { |
567 | mRelations.append(event); | 573 | mRelations.append(event); |
568 | //updated(); | 574 | //updated(); |
569 | } | 575 | } |
570 | } | 576 | } |
571 | 577 | ||
572 | void Incidence::removeRelation(Incidence *event) | 578 | void Incidence::removeRelation(Incidence *event) |
573 | { | 579 | { |
574 | setLastModifiedSubInvalid(); | 580 | setLastModifiedSubInvalid(); |
575 | mRelations.removeRef(event); | 581 | mRelations.removeRef(event); |
576 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 582 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
577 | } | 583 | } |
578 | 584 | ||
579 | bool Incidence::recursOn(const QDate &qd) const | 585 | bool Incidence::recursOn(const QDate &qd) const |
580 | { | 586 | { |
581 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; | 587 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; |
582 | else return false; | 588 | else return false; |
583 | } | 589 | } |
584 | 590 | ||
585 | void Incidence::setExDates(const DateList &exDates) | 591 | void Incidence::setExDates(const DateList &exDates) |
586 | { | 592 | { |