-rw-r--r-- | libkcal/incidence.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 52d94fb..549014e 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -366,257 +366,261 @@ void Incidence::setRevision(int rev) | |||
366 | if (mReadOnly) return; | 366 | if (mReadOnly) return; |
367 | mRevision = rev; | 367 | mRevision = rev; |
368 | 368 | ||
369 | updated(); | 369 | updated(); |
370 | } | 370 | } |
371 | 371 | ||
372 | int Incidence::revision() const | 372 | int Incidence::revision() const |
373 | { | 373 | { |
374 | return mRevision; | 374 | return mRevision; |
375 | } | 375 | } |
376 | 376 | ||
377 | void Incidence::setDtStart(const QDateTime &dtStart) | 377 | void Incidence::setDtStart(const QDateTime &dtStart) |
378 | { | 378 | { |
379 | 379 | ||
380 | QDateTime dt = getEvenTime(dtStart); | 380 | QDateTime dt = getEvenTime(dtStart); |
381 | 381 | ||
382 | if ( mRecurrence ) | 382 | if ( mRecurrence ) |
383 | mRecurrence->setRecurStart( dt); | 383 | mRecurrence->setRecurStart( dt); |
384 | IncidenceBase::setDtStart( dt ); | 384 | IncidenceBase::setDtStart( dt ); |
385 | } | 385 | } |
386 | 386 | ||
387 | void Incidence::setDescription(const QString &description) | 387 | void Incidence::setDescription(const QString &description) |
388 | { | 388 | { |
389 | if (mReadOnly) return; | 389 | if (mReadOnly) return; |
390 | mDescription = description; | 390 | mDescription = description; |
391 | updated(); | 391 | updated(); |
392 | } | 392 | } |
393 | 393 | ||
394 | QString Incidence::description() const | 394 | QString Incidence::description() const |
395 | { | 395 | { |
396 | return mDescription; | 396 | return mDescription; |
397 | } | 397 | } |
398 | 398 | ||
399 | 399 | ||
400 | void Incidence::setSummary(const QString &summary) | 400 | void Incidence::setSummary(const QString &summary) |
401 | { | 401 | { |
402 | if (mReadOnly) return; | 402 | if (mReadOnly) return; |
403 | mSummary = summary; | 403 | mSummary = summary; |
404 | updated(); | 404 | updated(); |
405 | } | 405 | } |
406 | 406 | ||
407 | QString Incidence::summary() const | 407 | QString Incidence::summary() const |
408 | { | 408 | { |
409 | return mSummary; | 409 | return mSummary; |
410 | } | 410 | } |
411 | void Incidence::checkCategories() | 411 | void Incidence::checkCategories() |
412 | { | 412 | { |
413 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 413 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
414 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 414 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
415 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 415 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
416 | } | 416 | } |
417 | 417 | ||
418 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 418 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
419 | { | 419 | { |
420 | if (mReadOnly) return; | 420 | if (mReadOnly) return; |
421 | int i; | 421 | int i; |
422 | for( i = 0; i < categories.count(); ++i ) { | 422 | for( i = 0; i < categories.count(); ++i ) { |
423 | if ( !mCategories.contains (categories[i])) | 423 | if ( !mCategories.contains (categories[i])) |
424 | mCategories.append( categories[i] ); | 424 | mCategories.append( categories[i] ); |
425 | } | 425 | } |
426 | checkCategories(); | 426 | checkCategories(); |
427 | updated(); | 427 | updated(); |
428 | if ( addToRelations ) { | 428 | if ( addToRelations ) { |
429 | Incidence * inc; | 429 | Incidence * inc; |
430 | QPtrList<Incidence> Relations = relations(); | 430 | QPtrList<Incidence> Relations = relations(); |
431 | for (inc=Relations.first();inc;inc=Relations.next()) { | 431 | for (inc=Relations.first();inc;inc=Relations.next()) { |
432 | inc->addCategories( categories, true ); | 432 | inc->addCategories( categories, true ); |
433 | } | 433 | } |
434 | } | 434 | } |
435 | } | 435 | } |
436 | 436 | ||
437 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 437 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
438 | { | 438 | { |
439 | if (mReadOnly) return; | 439 | if (mReadOnly) return; |
440 | mCategories = categories; | 440 | mCategories = categories; |
441 | checkCategories(); | 441 | checkCategories(); |
442 | updated(); | 442 | updated(); |
443 | if ( setForRelations ) { | 443 | if ( setForRelations ) { |
444 | Incidence * inc; | 444 | Incidence * inc; |
445 | QPtrList<Incidence> Relations = relations(); | 445 | QPtrList<Incidence> Relations = relations(); |
446 | for (inc=Relations.first();inc;inc=Relations.next()) { | 446 | for (inc=Relations.first();inc;inc=Relations.next()) { |
447 | inc->setCategories( categories, true ); | 447 | inc->setCategories( categories, true ); |
448 | } | 448 | } |
449 | } | 449 | } |
450 | } | 450 | } |
451 | 451 | ||
452 | // TODO: remove setCategories(QString) function | 452 | // TODO: remove setCategories(QString) function |
453 | void Incidence::setCategories(const QString &catStr) | 453 | void Incidence::setCategories(const QString &catStr) |
454 | { | 454 | { |
455 | if (mReadOnly) return; | 455 | if (mReadOnly) return; |
456 | mCategories.clear(); | 456 | mCategories.clear(); |
457 | 457 | ||
458 | if (catStr.isEmpty()) return; | 458 | if (catStr.isEmpty()) return; |
459 | 459 | ||
460 | mCategories = QStringList::split(",",catStr); | 460 | mCategories = QStringList::split(",",catStr); |
461 | 461 | ||
462 | QStringList::Iterator it; | 462 | QStringList::Iterator it; |
463 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 463 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
464 | *it = (*it).stripWhiteSpace(); | 464 | *it = (*it).stripWhiteSpace(); |
465 | } | 465 | } |
466 | checkCategories(); | 466 | checkCategories(); |
467 | updated(); | 467 | updated(); |
468 | } | 468 | } |
469 | // using this makes filtering 3 times faster | 469 | // using this makes filtering 3 times faster |
470 | QStringList* Incidence::categoriesP() | 470 | QStringList* Incidence::categoriesP() |
471 | { | 471 | { |
472 | return &mCategories; | 472 | return &mCategories; |
473 | } | 473 | } |
474 | 474 | ||
475 | QStringList Incidence::categories() const | 475 | QStringList Incidence::categories() const |
476 | { | 476 | { |
477 | return mCategories; | 477 | return mCategories; |
478 | } | 478 | } |
479 | 479 | ||
480 | QString Incidence::categoriesStr() | 480 | QString Incidence::categoriesStr() |
481 | { | 481 | { |
482 | return mCategories.join(","); | 482 | return mCategories.join(","); |
483 | } | 483 | } |
484 | QString Incidence::categoriesStrWithSpace() | 484 | QString Incidence::categoriesStrWithSpace() |
485 | { | 485 | { |
486 | return mCategories.join(", "); | 486 | return mCategories.join(", "); |
487 | } | 487 | } |
488 | 488 | ||
489 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 489 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
490 | { | 490 | { |
491 | if (mReadOnly) return; | 491 | if (mReadOnly) return; |
492 | mRelatedToUid = relatedToUid; | 492 | mRelatedToUid = relatedToUid; |
493 | } | 493 | } |
494 | 494 | void Incidence::clearRelations() | |
495 | { | ||
496 | mRelatedTo = 0; | ||
497 | mRelations.clear(); | ||
498 | } | ||
495 | QString Incidence::relatedToUid() const | 499 | QString Incidence::relatedToUid() const |
496 | { | 500 | { |
497 | return mRelatedToUid; | 501 | return mRelatedToUid; |
498 | } | 502 | } |
499 | 503 | ||
500 | void Incidence::setRelatedTo(Incidence *relatedTo) | 504 | void Incidence::setRelatedTo(Incidence *relatedTo) |
501 | { | 505 | { |
502 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 506 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
503 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 507 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
504 | if (mReadOnly || mRelatedTo == relatedTo) return; | 508 | if (mReadOnly || mRelatedTo == relatedTo) return; |
505 | if(mRelatedTo) { | 509 | if(mRelatedTo) { |
506 | // updated(); | 510 | // updated(); |
507 | mRelatedTo->removeRelation(this); | 511 | mRelatedTo->removeRelation(this); |
508 | } | 512 | } |
509 | mRelatedTo = relatedTo; | 513 | mRelatedTo = relatedTo; |
510 | if (mRelatedTo) { | 514 | if (mRelatedTo) { |
511 | mRelatedTo->addRelation(this); | 515 | mRelatedTo->addRelation(this); |
512 | mRelatedToUid = mRelatedTo->uid(); | 516 | mRelatedToUid = mRelatedTo->uid(); |
513 | } else { | 517 | } else { |
514 | mRelatedToUid = ""; | 518 | mRelatedToUid = ""; |
515 | } | 519 | } |
516 | } | 520 | } |
517 | 521 | ||
518 | Incidence *Incidence::relatedTo() const | 522 | Incidence *Incidence::relatedTo() const |
519 | { | 523 | { |
520 | return mRelatedTo; | 524 | return mRelatedTo; |
521 | } | 525 | } |
522 | 526 | ||
523 | QPtrList<Incidence> Incidence::relations() const | 527 | QPtrList<Incidence> Incidence::relations() const |
524 | { | 528 | { |
525 | return mRelations; | 529 | return mRelations; |
526 | } | 530 | } |
527 | 531 | ||
528 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 532 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
529 | { | 533 | { |
530 | Incidence* inc; | 534 | Incidence* inc; |
531 | QPtrList<Incidence> Relations = relations(); | 535 | QPtrList<Incidence> Relations = relations(); |
532 | for (inc=Relations.first();inc;inc=Relations.next()) { | 536 | for (inc=Relations.first();inc;inc=Relations.next()) { |
533 | inc->addRelationsToList( rel ); | 537 | inc->addRelationsToList( rel ); |
534 | } | 538 | } |
535 | if ( rel->findRef( this ) == -1 ) | 539 | if ( rel->findRef( this ) == -1 ) |
536 | rel->append( this ); | 540 | rel->append( this ); |
537 | } | 541 | } |
538 | 542 | ||
539 | void Incidence::addRelation(Incidence *event) | 543 | void Incidence::addRelation(Incidence *event) |
540 | { | 544 | { |
541 | setLastModifiedSubInvalid(); | 545 | setLastModifiedSubInvalid(); |
542 | if( mRelations.findRef( event ) == -1 ) { | 546 | if( mRelations.findRef( event ) == -1 ) { |
543 | mRelations.append(event); | 547 | mRelations.append(event); |
544 | //updated(); | 548 | //updated(); |
545 | } | 549 | } |
546 | } | 550 | } |
547 | 551 | ||
548 | void Incidence::removeRelation(Incidence *event) | 552 | void Incidence::removeRelation(Incidence *event) |
549 | { | 553 | { |
550 | setLastModifiedSubInvalid(); | 554 | setLastModifiedSubInvalid(); |
551 | mRelations.removeRef(event); | 555 | mRelations.removeRef(event); |
552 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 556 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
553 | } | 557 | } |
554 | 558 | ||
555 | bool Incidence::recursOn(const QDate &qd) const | 559 | bool Incidence::recursOn(const QDate &qd) const |
556 | { | 560 | { |
557 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; | 561 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; |
558 | else return false; | 562 | else return false; |
559 | } | 563 | } |
560 | 564 | ||
561 | void Incidence::setExDates(const DateList &exDates) | 565 | void Incidence::setExDates(const DateList &exDates) |
562 | { | 566 | { |
563 | if (mReadOnly) return; | 567 | if (mReadOnly) return; |
564 | mExDates = exDates; | 568 | mExDates = exDates; |
565 | recurrence()->setRecurExDatesCount(mExDates.count()); | 569 | recurrence()->setRecurExDatesCount(mExDates.count()); |
566 | 570 | ||
567 | updated(); | 571 | updated(); |
568 | } | 572 | } |
569 | 573 | ||
570 | void Incidence::addExDate(const QDate &date) | 574 | void Incidence::addExDate(const QDate &date) |
571 | { | 575 | { |
572 | if (mReadOnly) return; | 576 | if (mReadOnly) return; |
573 | mExDates.append(date); | 577 | mExDates.append(date); |
574 | 578 | ||
575 | recurrence()->setRecurExDatesCount(mExDates.count()); | 579 | recurrence()->setRecurExDatesCount(mExDates.count()); |
576 | 580 | ||
577 | updated(); | 581 | updated(); |
578 | } | 582 | } |
579 | 583 | ||
580 | DateList Incidence::exDates() const | 584 | DateList Incidence::exDates() const |
581 | { | 585 | { |
582 | return mExDates; | 586 | return mExDates; |
583 | } | 587 | } |
584 | 588 | ||
585 | bool Incidence::isException(const QDate &date) const | 589 | bool Incidence::isException(const QDate &date) const |
586 | { | 590 | { |
587 | DateList::ConstIterator it; | 591 | DateList::ConstIterator it; |
588 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 592 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
589 | if ( (*it) == date ) { | 593 | if ( (*it) == date ) { |
590 | return true; | 594 | return true; |
591 | } | 595 | } |
592 | } | 596 | } |
593 | 597 | ||
594 | return false; | 598 | return false; |
595 | } | 599 | } |
596 | 600 | ||
597 | void Incidence::addAttachment(Attachment *attachment) | 601 | void Incidence::addAttachment(Attachment *attachment) |
598 | { | 602 | { |
599 | if (mReadOnly || !attachment) return; | 603 | if (mReadOnly || !attachment) return; |
600 | mAttachments.append(attachment); | 604 | mAttachments.append(attachment); |
601 | updated(); | 605 | updated(); |
602 | } | 606 | } |
603 | 607 | ||
604 | void Incidence::deleteAttachment(Attachment *attachment) | 608 | void Incidence::deleteAttachment(Attachment *attachment) |
605 | { | 609 | { |
606 | mAttachments.removeRef(attachment); | 610 | mAttachments.removeRef(attachment); |
607 | } | 611 | } |
608 | 612 | ||
609 | void Incidence::deleteAttachments(const QString& mime) | 613 | void Incidence::deleteAttachments(const QString& mime) |
610 | { | 614 | { |
611 | Attachment *at = mAttachments.first(); | 615 | Attachment *at = mAttachments.first(); |
612 | while (at) { | 616 | while (at) { |
613 | if (at->mimeType() == mime) | 617 | if (at->mimeType() == mime) |
614 | mAttachments.remove(); | 618 | mAttachments.remove(); |
615 | else | 619 | else |
616 | at = mAttachments.next(); | 620 | at = mAttachments.next(); |
617 | } | 621 | } |
618 | } | 622 | } |
619 | 623 | ||
620 | QPtrList<Attachment> Incidence::attachments() const | 624 | QPtrList<Attachment> Incidence::attachments() const |
621 | { | 625 | { |
622 | return mAttachments; | 626 | return mAttachments; |