-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 | |||
@@ -395,256 +395,262 @@ int Incidence::revision() const | |||
395 | } | 395 | } |
396 | 396 | ||
397 | void Incidence::setDtStart(const QDateTime &dtStart) | 397 | void Incidence::setDtStart(const QDateTime &dtStart) |
398 | { | 398 | { |
399 | 399 | ||
400 | QDateTime dt = getEvenTime(dtStart); | 400 | QDateTime dt = getEvenTime(dtStart); |
401 | 401 | ||
402 | if ( mRecurrence ) | 402 | if ( mRecurrence ) |
403 | mRecurrence->setRecurStart( dt); | 403 | mRecurrence->setRecurStart( dt); |
404 | IncidenceBase::setDtStart( dt ); | 404 | IncidenceBase::setDtStart( dt ); |
405 | } | 405 | } |
406 | 406 | ||
407 | void Incidence::setDescription(const QString &description) | 407 | void Incidence::setDescription(const QString &description) |
408 | { | 408 | { |
409 | if (mReadOnly) return; | 409 | if (mReadOnly) return; |
410 | mDescription = description; | 410 | mDescription = description; |
411 | updated(); | 411 | updated(); |
412 | } | 412 | } |
413 | 413 | ||
414 | QString Incidence::description() const | 414 | QString Incidence::description() const |
415 | { | 415 | { |
416 | return mDescription; | 416 | return mDescription; |
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | void Incidence::setSummary(const QString &summary) | 420 | void Incidence::setSummary(const QString &summary) |
421 | { | 421 | { |
422 | if (mReadOnly) return; | 422 | if (mReadOnly) return; |
423 | mSummary = summary; | 423 | mSummary = summary; |
424 | updated(); | 424 | updated(); |
425 | } | 425 | } |
426 | 426 | ||
427 | QString Incidence::summary() const | 427 | QString Incidence::summary() const |
428 | { | 428 | { |
429 | return mSummary; | 429 | return mSummary; |
430 | } | 430 | } |
431 | void Incidence::checkCategories() | 431 | void Incidence::checkCategories() |
432 | { | 432 | { |
433 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 433 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
434 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 434 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
435 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 435 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
436 | } | 436 | } |
437 | 437 | ||
438 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 438 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
439 | { | 439 | { |
440 | if (mReadOnly) return; | 440 | if (mReadOnly) return; |
441 | int i; | 441 | int i; |
442 | for( i = 0; i < categories.count(); ++i ) { | 442 | for( i = 0; i < categories.count(); ++i ) { |
443 | if ( !mCategories.contains (categories[i])) | 443 | if ( !mCategories.contains (categories[i])) |
444 | mCategories.append( categories[i] ); | 444 | mCategories.append( categories[i] ); |
445 | } | 445 | } |
446 | checkCategories(); | 446 | checkCategories(); |
447 | updated(); | 447 | updated(); |
448 | if ( addToRelations ) { | 448 | if ( addToRelations ) { |
449 | Incidence * inc; | 449 | Incidence * inc; |
450 | QPtrList<Incidence> Relations = relations(); | 450 | QPtrList<Incidence> Relations = relations(); |
451 | for (inc=Relations.first();inc;inc=Relations.next()) { | 451 | for (inc=Relations.first();inc;inc=Relations.next()) { |
452 | inc->addCategories( categories, true ); | 452 | inc->addCategories( categories, true ); |
453 | } | 453 | } |
454 | } | 454 | } |
455 | } | 455 | } |
456 | 456 | ||
457 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 457 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
458 | { | 458 | { |
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 | { |
587 | if (mReadOnly) return; | 593 | if (mReadOnly) return; |
588 | mExDates = exDates; | 594 | mExDates = exDates; |
589 | recurrence()->setRecurExDatesCount(mExDates.count()); | 595 | recurrence()->setRecurExDatesCount(mExDates.count()); |
590 | 596 | ||
591 | updated(); | 597 | updated(); |
592 | } | 598 | } |
593 | 599 | ||
594 | void Incidence::addExDate(const QDate &date) | 600 | void Incidence::addExDate(const QDate &date) |
595 | { | 601 | { |
596 | if (mReadOnly) return; | 602 | if (mReadOnly) return; |
597 | mExDates.append(date); | 603 | mExDates.append(date); |
598 | 604 | ||
599 | recurrence()->setRecurExDatesCount(mExDates.count()); | 605 | recurrence()->setRecurExDatesCount(mExDates.count()); |
600 | 606 | ||
601 | updated(); | 607 | updated(); |
602 | } | 608 | } |
603 | 609 | ||
604 | DateList Incidence::exDates() const | 610 | DateList Incidence::exDates() const |
605 | { | 611 | { |
606 | return mExDates; | 612 | return mExDates; |
607 | } | 613 | } |
608 | 614 | ||
609 | bool Incidence::isException(const QDate &date) const | 615 | bool Incidence::isException(const QDate &date) const |
610 | { | 616 | { |
611 | DateList::ConstIterator it; | 617 | DateList::ConstIterator it; |
612 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 618 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
613 | if ( (*it) == date ) { | 619 | if ( (*it) == date ) { |
614 | return true; | 620 | return true; |
615 | } | 621 | } |
616 | } | 622 | } |
617 | 623 | ||
618 | return false; | 624 | return false; |
619 | } | 625 | } |
620 | 626 | ||
621 | void Incidence::addAttachment(Attachment *attachment) | 627 | void Incidence::addAttachment(Attachment *attachment) |
622 | { | 628 | { |
623 | if (mReadOnly || !attachment) return; | 629 | if (mReadOnly || !attachment) return; |
624 | mAttachments.append(attachment); | 630 | mAttachments.append(attachment); |
625 | updated(); | 631 | updated(); |
626 | } | 632 | } |
627 | 633 | ||
628 | void Incidence::deleteAttachment(Attachment *attachment) | 634 | void Incidence::deleteAttachment(Attachment *attachment) |
629 | { | 635 | { |
630 | mAttachments.removeRef(attachment); | 636 | mAttachments.removeRef(attachment); |
631 | } | 637 | } |
632 | 638 | ||
633 | void Incidence::deleteAttachments(const QString& mime) | 639 | void Incidence::deleteAttachments(const QString& mime) |
634 | { | 640 | { |
635 | Attachment *at = mAttachments.first(); | 641 | Attachment *at = mAttachments.first(); |
636 | while (at) { | 642 | while (at) { |
637 | if (at->mimeType() == mime) | 643 | if (at->mimeType() == mime) |
638 | mAttachments.remove(); | 644 | mAttachments.remove(); |
639 | else | 645 | else |
640 | at = mAttachments.next(); | 646 | at = mAttachments.next(); |
641 | } | 647 | } |
642 | } | 648 | } |
643 | 649 | ||
644 | QPtrList<Attachment> Incidence::attachments() const | 650 | QPtrList<Attachment> Incidence::attachments() const |
645 | { | 651 | { |
646 | return mAttachments; | 652 | return mAttachments; |
647 | } | 653 | } |
648 | 654 | ||
649 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 655 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
650 | { | 656 | { |