summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 201f593..52d94fb 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -371,470 +371,471 @@ void Incidence::setRevision(int rev)
371 371
372int Incidence::revision() const 372int Incidence::revision() const
373{ 373{
374 return mRevision; 374 return mRevision;
375} 375}
376 376
377void Incidence::setDtStart(const QDateTime &dtStart) 377void 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
387void Incidence::setDescription(const QString &description) 387void 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
394QString Incidence::description() const 394QString Incidence::description() const
395{ 395{
396 return mDescription; 396 return mDescription;
397} 397}
398 398
399 399
400void Incidence::setSummary(const QString &summary) 400void 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
407QString Incidence::summary() const 407QString Incidence::summary() const
408{ 408{
409 return mSummary; 409 return mSummary;
410} 410}
411void Incidence::checkCategories() 411void 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
418void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 418void 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
437void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 437void 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
453void Incidence::setCategories(const QString &catStr) 453void 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
470QStringList* Incidence::categoriesP() 470QStringList* Incidence::categoriesP()
471{ 471{
472 return &mCategories; 472 return &mCategories;
473} 473}
474 474
475QStringList Incidence::categories() const 475QStringList Incidence::categories() const
476{ 476{
477 return mCategories; 477 return mCategories;
478} 478}
479 479
480QString Incidence::categoriesStr() 480QString Incidence::categoriesStr()
481{ 481{
482 return mCategories.join(","); 482 return mCategories.join(",");
483} 483}
484QString Incidence::categoriesStrWithSpace() 484QString Incidence::categoriesStrWithSpace()
485{ 485{
486 return mCategories.join(", "); 486 return mCategories.join(", ");
487} 487}
488 488
489void Incidence::setRelatedToUid(const QString &relatedToUid) 489void 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
495QString Incidence::relatedToUid() const 495QString Incidence::relatedToUid() const
496{ 496{
497 return mRelatedToUid; 497 return mRelatedToUid;
498} 498}
499 499
500void Incidence::setRelatedTo(Incidence *relatedTo) 500void Incidence::setRelatedTo(Incidence *relatedTo)
501{ 501{
502 //qDebug("Incidence::setRelatedTo %d ", relatedTo); 502 //qDebug("Incidence::setRelatedTo %d ", relatedTo);
503 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); 503 //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() );
504 if (mReadOnly || mRelatedTo == relatedTo) return; 504 if (mReadOnly || mRelatedTo == relatedTo) return;
505 if(mRelatedTo) { 505 if(mRelatedTo) {
506 // updated(); 506 // updated();
507 mRelatedTo->removeRelation(this); 507 mRelatedTo->removeRelation(this);
508 } 508 }
509 mRelatedTo = relatedTo; 509 mRelatedTo = relatedTo;
510 if (mRelatedTo) { 510 if (mRelatedTo) {
511 mRelatedTo->addRelation(this); 511 mRelatedTo->addRelation(this);
512 mRelatedToUid = mRelatedTo->uid(); 512 mRelatedToUid = mRelatedTo->uid();
513 } else { 513 } else {
514 mRelatedToUid = ""; 514 mRelatedToUid = "";
515 } 515 }
516} 516}
517 517
518Incidence *Incidence::relatedTo() const 518Incidence *Incidence::relatedTo() const
519{ 519{
520 return mRelatedTo; 520 return mRelatedTo;
521} 521}
522 522
523QPtrList<Incidence> Incidence::relations() const 523QPtrList<Incidence> Incidence::relations() const
524{ 524{
525 return mRelations; 525 return mRelations;
526} 526}
527 527
528void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 528void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
529{ 529{
530 Incidence* inc; 530 Incidence* inc;
531 QPtrList<Incidence> Relations = relations(); 531 QPtrList<Incidence> Relations = relations();
532 for (inc=Relations.first();inc;inc=Relations.next()) { 532 for (inc=Relations.first();inc;inc=Relations.next()) {
533 inc->addRelationsToList( rel ); 533 inc->addRelationsToList( rel );
534 } 534 }
535 if ( rel->findRef( this ) == -1 ) 535 if ( rel->findRef( this ) == -1 )
536 rel->append( this ); 536 rel->append( this );
537} 537}
538 538
539void Incidence::addRelation(Incidence *event) 539void Incidence::addRelation(Incidence *event)
540{ 540{
541 setLastModifiedSubInvalid(); 541 setLastModifiedSubInvalid();
542 if( mRelations.findRef( event ) == -1 ) { 542 if( mRelations.findRef( event ) == -1 ) {
543 mRelations.append(event); 543 mRelations.append(event);
544 //updated(); 544 //updated();
545 } 545 }
546} 546}
547 547
548void Incidence::removeRelation(Incidence *event) 548void Incidence::removeRelation(Incidence *event)
549{ 549{
550 setLastModifiedSubInvalid(); 550 setLastModifiedSubInvalid();
551 mRelations.removeRef(event); 551 mRelations.removeRef(event);
552// if (event->getRelatedTo() == this) event->setRelatedTo(0); 552// if (event->getRelatedTo() == this) event->setRelatedTo(0);
553} 553}
554 554
555bool Incidence::recursOn(const QDate &qd) const 555bool Incidence::recursOn(const QDate &qd) const
556{ 556{
557 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; 557 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true;
558 else return false; 558 else return false;
559} 559}
560 560
561void Incidence::setExDates(const DateList &exDates) 561void Incidence::setExDates(const DateList &exDates)
562{ 562{
563 if (mReadOnly) return; 563 if (mReadOnly) return;
564 mExDates = exDates; 564 mExDates = exDates;
565 recurrence()->setRecurExDatesCount(mExDates.count()); 565 recurrence()->setRecurExDatesCount(mExDates.count());
566 566
567 updated(); 567 updated();
568} 568}
569 569
570void Incidence::addExDate(const QDate &date) 570void Incidence::addExDate(const QDate &date)
571{ 571{
572 if (mReadOnly) return; 572 if (mReadOnly) return;
573 mExDates.append(date); 573 mExDates.append(date);
574 574
575 recurrence()->setRecurExDatesCount(mExDates.count()); 575 recurrence()->setRecurExDatesCount(mExDates.count());
576 576
577 updated(); 577 updated();
578} 578}
579 579
580DateList Incidence::exDates() const 580DateList Incidence::exDates() const
581{ 581{
582 return mExDates; 582 return mExDates;
583} 583}
584 584
585bool Incidence::isException(const QDate &date) const 585bool Incidence::isException(const QDate &date) const
586{ 586{
587 DateList::ConstIterator it; 587 DateList::ConstIterator it;
588 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 588 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
589 if ( (*it) == date ) { 589 if ( (*it) == date ) {
590 return true; 590 return true;
591 } 591 }
592 } 592 }
593 593
594 return false; 594 return false;
595} 595}
596 596
597void Incidence::addAttachment(Attachment *attachment) 597void Incidence::addAttachment(Attachment *attachment)
598{ 598{
599 if (mReadOnly || !attachment) return; 599 if (mReadOnly || !attachment) return;
600 mAttachments.append(attachment); 600 mAttachments.append(attachment);
601 updated(); 601 updated();
602} 602}
603 603
604void Incidence::deleteAttachment(Attachment *attachment) 604void Incidence::deleteAttachment(Attachment *attachment)
605{ 605{
606 mAttachments.removeRef(attachment); 606 mAttachments.removeRef(attachment);
607} 607}
608 608
609void Incidence::deleteAttachments(const QString& mime) 609void Incidence::deleteAttachments(const QString& mime)
610{ 610{
611 Attachment *at = mAttachments.first(); 611 Attachment *at = mAttachments.first();
612 while (at) { 612 while (at) {
613 if (at->mimeType() == mime) 613 if (at->mimeType() == mime)
614 mAttachments.remove(); 614 mAttachments.remove();
615 else 615 else
616 at = mAttachments.next(); 616 at = mAttachments.next();
617 } 617 }
618} 618}
619 619
620QPtrList<Attachment> Incidence::attachments() const 620QPtrList<Attachment> Incidence::attachments() const
621{ 621{
622 return mAttachments; 622 return mAttachments;
623} 623}
624 624
625QPtrList<Attachment> Incidence::attachments(const QString& mime) const 625QPtrList<Attachment> Incidence::attachments(const QString& mime) const
626{ 626{
627 QPtrList<Attachment> attachments; 627 QPtrList<Attachment> attachments;
628 QPtrListIterator<Attachment> it( mAttachments ); 628 QPtrListIterator<Attachment> it( mAttachments );
629 Attachment *at; 629 Attachment *at;
630 while ( (at = it.current()) ) { 630 while ( (at = it.current()) ) {
631 if (at->mimeType() == mime) 631 if (at->mimeType() == mime)
632 attachments.append(at); 632 attachments.append(at);
633 ++it; 633 ++it;
634 } 634 }
635 635
636 return attachments; 636 return attachments;
637} 637}
638 638
639void Incidence::setResources(const QStringList &resources) 639void Incidence::setResources(const QStringList &resources)
640{ 640{
641 if (mReadOnly) return; 641 if (mReadOnly) return;
642 mResources = resources; 642 mResources = resources;
643 updated(); 643 updated();
644} 644}
645 645
646QStringList Incidence::resources() const 646QStringList Incidence::resources() const
647{ 647{
648 return mResources; 648 return mResources;
649} 649}
650 650
651 651
652void Incidence::setPriority(int priority) 652void Incidence::setPriority(int priority)
653{ 653{
654 if (mReadOnly) return; 654 if (mReadOnly) return;
655 mPriority = priority; 655 mPriority = priority;
656 updated(); 656 updated();
657} 657}
658 658
659int Incidence::priority() const 659int Incidence::priority() const
660{ 660{
661 return mPriority; 661 return mPriority;
662} 662}
663 663
664void Incidence::setSecrecy(int sec) 664void Incidence::setSecrecy(int sec)
665{ 665{
666 if (mReadOnly) return; 666 if (mReadOnly) return;
667 mSecrecy = sec; 667 mSecrecy = sec;
668 updated(); 668 updated();
669} 669}
670 670
671int Incidence::secrecy() const 671int Incidence::secrecy() const
672{ 672{
673 return mSecrecy; 673 return mSecrecy;
674} 674}
675 675
676QString Incidence::secrecyStr() const 676QString Incidence::secrecyStr() const
677{ 677{
678 return secrecyName(mSecrecy); 678 return secrecyName(mSecrecy);
679} 679}
680 680
681QString Incidence::secrecyName(int secrecy) 681QString Incidence::secrecyName(int secrecy)
682{ 682{
683 switch (secrecy) { 683 switch (secrecy) {
684 case SecrecyPublic: 684 case SecrecyPublic:
685 return i18n("Public"); 685 return i18n("Public");
686 break; 686 break;
687 case SecrecyPrivate: 687 case SecrecyPrivate:
688 return i18n("Private"); 688 return i18n("Private");
689 break; 689 break;
690 case SecrecyConfidential: 690 case SecrecyConfidential:
691 return i18n("Confidential"); 691 return i18n("Confidential");
692 break; 692 break;
693 default: 693 default:
694 return i18n("Undefined"); 694 return i18n("Undefined");
695 break; 695 break;
696 } 696 }
697} 697}
698 698
699QStringList Incidence::secrecyList() 699QStringList Incidence::secrecyList()
700{ 700{
701 QStringList list; 701 QStringList list;
702 list << secrecyName(SecrecyPublic); 702 list << secrecyName(SecrecyPublic);
703 list << secrecyName(SecrecyPrivate); 703 list << secrecyName(SecrecyPrivate);
704 list << secrecyName(SecrecyConfidential); 704 list << secrecyName(SecrecyConfidential);
705 705
706 return list; 706 return list;
707} 707}
708 708
709 709
710QPtrList<Alarm> Incidence::alarms() const 710QPtrList<Alarm> Incidence::alarms() const
711{ 711{
712 return mAlarms; 712 return mAlarms;
713} 713}
714 714
715Alarm* Incidence::newAlarm() 715Alarm* Incidence::newAlarm()
716{ 716{
717 Alarm* alarm = new Alarm(this); 717 Alarm* alarm = new Alarm(this);
718 mAlarms.append(alarm); 718 mAlarms.append(alarm);
719// updated(); 719// updated();
720 return alarm; 720 return alarm;
721} 721}
722 722
723void Incidence::addAlarm(Alarm *alarm) 723void Incidence::addAlarm(Alarm *alarm)
724{ 724{
725 mAlarms.append(alarm); 725 mAlarms.append(alarm);
726 updated(); 726 updated();
727} 727}
728 728
729void Incidence::removeAlarm(Alarm *alarm) 729void Incidence::removeAlarm(Alarm *alarm)
730{ 730{
731 mAlarms.removeRef(alarm); 731 mAlarms.removeRef(alarm);
732 updated(); 732 updated();
733} 733}
734 734
735void Incidence::clearAlarms() 735void Incidence::clearAlarms()
736{ 736{
737 mAlarms.clear(); 737 mAlarms.clear();
738 updated(); 738 updated();
739} 739}
740 740
741bool Incidence::isAlarmEnabled() const 741bool Incidence::isAlarmEnabled() const
742{ 742{
743 Alarm* alarm; 743 Alarm* alarm;
744 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 744 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
745 if (alarm->enabled()) 745 if (alarm->enabled())
746 return true; 746 return true;
747 } 747 }
748 return false; 748 return false;
749} 749}
750#include <stdlib.h> 750#include <stdlib.h>
751Recurrence *Incidence::recurrence() 751Recurrence *Incidence::recurrence()
752{ 752{
753 if ( ! mRecurrence ) { 753 if ( ! mRecurrence ) {
754 mRecurrence = new Recurrence(this); 754 mRecurrence = new Recurrence(this);
755 qDebug("creating new recurence "); 755 mRecurrence->setRecurStart( dtStart() );
756 //qDebug("creating new recurence ");
756 //abort(); 757 //abort();
757 } 758 }
758 return mRecurrence; 759 return mRecurrence;
759} 760}
760void Incidence::setRecurrence( Recurrence * r) 761void Incidence::setRecurrence( Recurrence * r)
761{ 762{
762 if ( mRecurrence ) 763 if ( mRecurrence )
763 delete mRecurrence; 764 delete mRecurrence;
764 mRecurrence = r; 765 mRecurrence = r;
765} 766}
766 767
767void Incidence::setLocation(const QString &location) 768void Incidence::setLocation(const QString &location)
768{ 769{
769 if (mReadOnly) return; 770 if (mReadOnly) return;
770 mLocation = location; 771 mLocation = location;
771 updated(); 772 updated();
772} 773}
773 774
774QString Incidence::location() const 775QString Incidence::location() const
775{ 776{
776 return mLocation; 777 return mLocation;
777} 778}
778QString Incidence::recurrenceText() const 779QString Incidence::recurrenceText() const
779{ 780{
780 if ( mRecurrence ) return mRecurrence->recurrenceText(); 781 if ( mRecurrence ) return mRecurrence->recurrenceText();
781 return i18n("No"); 782 return i18n("No");
782} 783}
783 784
784ushort Incidence::doesRecur() const 785ushort Incidence::doesRecur() const
785{ 786{
786 if ( mRecurrence ) return mRecurrence->doesRecur(); 787 if ( mRecurrence ) return mRecurrence->doesRecur();
787 else return Recurrence::rNone; 788 else return Recurrence::rNone;
788} 789}
789 790
790QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 791QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
791{ 792{
792 QDateTime incidenceStart = dt; 793 QDateTime incidenceStart = dt;
793 *ok = false; 794 *ok = false;
794 if ( doesRecur() ) { 795 if ( doesRecur() ) {
795 bool last; 796 bool last;
796 mRecurrence->getPreviousDateTime( incidenceStart , &last ); 797 mRecurrence->getPreviousDateTime( incidenceStart , &last );
797 int count = 0; 798 int count = 0;
798 if ( !last ) { 799 if ( !last ) {
799 while ( !last ) { 800 while ( !last ) {
800 ++count; 801 ++count;
801 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last ); 802 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last );
802 if ( recursOn( incidenceStart.date() ) ) { 803 if ( recursOn( incidenceStart.date() ) ) {
803 last = true; // exit while llop 804 last = true; // exit while llop
804 } else { 805 } else {
805 if ( last ) { // no alarm on last recurrence 806 if ( last ) { // no alarm on last recurrence
806 return QDateTime (); 807 return QDateTime ();
807 } 808 }
808 int year = incidenceStart.date().year(); 809 int year = incidenceStart.date().year();
809 // workaround for bug in recurrence 810 // workaround for bug in recurrence
810 if ( count == 100 || year < 1000 || year > 5000 ) { 811 if ( count == 100 || year < 1000 || year > 5000 ) {
811 return QDateTime (); 812 return QDateTime ();
812 } 813 }
813 incidenceStart = incidenceStart.addSecs( 1 ); 814 incidenceStart = incidenceStart.addSecs( 1 );
814 } 815 }
815 } 816 }
816 } else { 817 } else {
817 return QDateTime (); 818 return QDateTime ();
818 } 819 }
819 } else { 820 } else {
820 if ( hasStartDate () ) { 821 if ( hasStartDate () ) {
821 incidenceStart = dtStart(); 822 incidenceStart = dtStart();
822 } 823 }
823 if ( typeID() == todoID ) { 824 if ( typeID() == todoID ) {
824 if ( ((Todo*)this)->hasDueDate() ) 825 if ( ((Todo*)this)->hasDueDate() )
825 incidenceStart = ((Todo*)this)->dtDue(); 826 incidenceStart = ((Todo*)this)->dtDue();
826 } 827 }
827 } 828 }
828 if ( incidenceStart > dt ) 829 if ( incidenceStart > dt )
829 *ok = true; 830 *ok = true;
830 return incidenceStart; 831 return incidenceStart;
831} 832}
832QDateTime Incidence::dtStart() const 833QDateTime Incidence::dtStart() const
833{ 834{
834 if ( doesRecur() ) { 835 if ( doesRecur() ) {
835 if ( typeID() == todoID ) { 836 if ( typeID() == todoID ) {
836 ((Todo*)this)->checkSetCompletedFalse(); 837 ((Todo*)this)->checkSetCompletedFalse();
837 } 838 }
838 } 839 }
839 return mDtStart; 840 return mDtStart;
840} 841}