summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
Unidiff
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/incidence.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 7dd9bd2..8fcdc69 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -21,16 +21,18 @@
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidence.h" 27#include "incidence.h"
28#include "todo.h" 28#include "todo.h"
29//Added by qt3to4:
30#include <Q3PtrList>
29 31
30using namespace KCal; 32using namespace KCal;
31 33
32Incidence::Incidence() : 34Incidence::Incidence() :
33 IncidenceBase(), 35 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 36 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 37{
36 mRecurrence = 0;//new Recurrence(this); 38 mRecurrence = 0;//new Recurrence(this);
@@ -54,31 +56,31 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
54 mDescription = i.mDescription; 56 mDescription = i.mDescription;
55 mSummary = i.mSummary; 57 mSummary = i.mSummary;
56 mCategories = i.mCategories; 58 mCategories = i.mCategories;
57// Incidence *mRelatedTo; Incidence *mRelatedTo; 59// Incidence *mRelatedTo; Incidence *mRelatedTo;
58 mRelatedTo = 0; 60 mRelatedTo = 0;
59 mRelatedToUid = i.mRelatedToUid; 61 mRelatedToUid = i.mRelatedToUid;
60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 62// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
61 mExDates = i.mExDates; 63 mExDates = i.mExDates;
62 QPtrListIterator<Attachment> itat( i.mAttachments ); 64 Q3PtrListIterator<Attachment> itat( i.mAttachments );
63 Attachment *at; 65 Attachment *at;
64 while( (at = itat.current()) ) { 66 while( (at = itat.current()) ) {
65 Attachment *a = new Attachment( *at ); 67 Attachment *a = new Attachment( *at );
66 mAttachments.append( a ); 68 mAttachments.append( a );
67 ++itat; 69 ++itat;
68 } 70 }
69 mAttachments.setAutoDelete( true ); 71 mAttachments.setAutoDelete( true );
70 mResources = i.mResources; 72 mResources = i.mResources;
71 mSecrecy = i.mSecrecy; 73 mSecrecy = i.mSecrecy;
72 mPriority = i.mPriority; 74 mPriority = i.mPriority;
73 mLocation = i.mLocation; 75 mLocation = i.mLocation;
74 mCancelled = i.mCancelled; 76 mCancelled = i.mCancelled;
75 mHasStartDate = i.mHasStartDate; 77 mHasStartDate = i.mHasStartDate;
76 QPtrListIterator<Alarm> it( i.mAlarms ); 78 Q3PtrListIterator<Alarm> it( i.mAlarms );
77 const Alarm *a; 79 const Alarm *a;
78 while( (a = it.current()) ) { 80 while( (a = it.current()) ) {
79 Alarm *b = new Alarm( *a ); 81 Alarm *b = new Alarm( *a );
80 b->setParent( this ); 82 b->setParent( this );
81 mAlarms.append( b ); 83 mAlarms.append( b );
82 84
83 ++it; 85 ++it;
84 } 86 }
@@ -93,17 +95,17 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
93 mBirthday = i.mBirthday; 95 mBirthday = i.mBirthday;
94 mAnniversary = i.mAnniversary; 96 mAnniversary = i.mAnniversary;
95} 97}
96 98
97Incidence::~Incidence() 99Incidence::~Incidence()
98{ 100{
99 101
100 Incidence *ev; 102 Incidence *ev;
101 QPtrList<Incidence> Relations = relations(); 103 Q3PtrList<Incidence> Relations = relations();
102 for (ev=Relations.first();ev;ev=Relations.next()) { 104 for (ev=Relations.first();ev;ev=Relations.next()) {
103 if (ev->relatedTo() == this) ev->setRelatedTo(0); 105 if (ev->relatedTo() == this) ev->setRelatedTo(0);
104 } 106 }
105 if (relatedTo()) relatedTo()->removeRelation(this); 107 if (relatedTo()) relatedTo()->removeRelation(this);
106 if ( mRecurrence ) 108 if ( mRecurrence )
107 delete mRecurrence; 109 delete mRecurrence;
108 110
109} 111}
@@ -211,18 +213,18 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
211 if ( i1.alarms().count() > 0 ) { 213 if ( i1.alarms().count() > 0 ) {
212 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 214 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
213 { 215 {
214 qDebug("alarm not equal "); 216 qDebug("alarm not equal ");
215 return false; 217 return false;
216 } 218 }
217 } 219 }
218#if 0 220#if 0
219 QPtrListIterator<Alarm> a1( i1.alarms() ); 221 Q3PtrListIterator<Alarm> a1( i1.alarms() );
220 QPtrListIterator<Alarm> a2( i2.alarms() ); 222 Q3PtrListIterator<Alarm> a2( i2.alarms() );
221 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 223 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
222 if( *a1.current() == *a2.current() ) { 224 if( *a1.current() == *a2.current() ) {
223 continue; 225 continue;
224 } 226 }
225 else { 227 else {
226 return false; 228 return false;
227 } 229 }
228 } 230 }
@@ -317,17 +319,17 @@ void Incidence::recreate()
317 setIDStr( ":" ); 319 setIDStr( ":" );
318 setLastModified(QDateTime::currentDateTime()); 320 setLastModified(QDateTime::currentDateTime());
319} 321}
320void Incidence::cloneRelations( Incidence * newInc ) 322void Incidence::cloneRelations( Incidence * newInc )
321{ 323{
322 // newInc is already a clone of this incidence 324 // newInc is already a clone of this incidence
323 Incidence * inc; 325 Incidence * inc;
324 Incidence * cloneInc; 326 Incidence * cloneInc;
325 QPtrList<Incidence> Relations = relations(); 327 Q3PtrList<Incidence> Relations = relations();
326 for (inc=Relations.first();inc;inc=Relations.next()) { 328 for (inc=Relations.first();inc;inc=Relations.next()) {
327 cloneInc = inc->clone(); 329 cloneInc = inc->clone();
328 cloneInc->recreate(); 330 cloneInc->recreate();
329 cloneInc->setRelatedTo( newInc ); 331 cloneInc->setRelatedTo( newInc );
330 inc->cloneRelations( cloneInc ); 332 inc->cloneRelations( cloneInc );
331 } 333 }
332} 334}
333void Incidence::setReadOnly( bool readOnly ) 335void Incidence::setReadOnly( bool readOnly )
@@ -351,17 +353,17 @@ QString Incidence::lastModifiedSubSortKey() const
351QDateTime Incidence::lastModifiedSub() 353QDateTime Incidence::lastModifiedSub()
352{ 354{
353 if ( !mRelations.count() ) 355 if ( !mRelations.count() )
354 return lastModified(); 356 return lastModified();
355 if ( mLastModifiedSub.isValid() ) 357 if ( mLastModifiedSub.isValid() )
356 return mLastModifiedSub; 358 return mLastModifiedSub;
357 mLastModifiedSub = lastModified(); 359 mLastModifiedSub = lastModified();
358 Incidence * inc; 360 Incidence * inc;
359 QPtrList<Incidence> Relations = relations(); 361 Q3PtrList<Incidence> Relations = relations();
360 for (inc=Relations.first();inc;inc=Relations.next()) { 362 for (inc=Relations.first();inc;inc=Relations.next()) {
361 if ( inc->lastModifiedSub() > mLastModifiedSub ) 363 if ( inc->lastModifiedSub() > mLastModifiedSub )
362 mLastModifiedSub = inc->lastModifiedSub(); 364 mLastModifiedSub = inc->lastModifiedSub();
363 } 365 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", 366 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(), 367 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(), 368 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(), 369 mLastModifiedSub.date().day(),
@@ -442,32 +444,32 @@ void Incidence::addCategories(const QStringList &categories, bool addToRelations
442 for( i = 0; i < categories.count(); ++i ) { 444 for( i = 0; i < categories.count(); ++i ) {
443 if ( !mCategories.contains (categories[i])) 445 if ( !mCategories.contains (categories[i]))
444 mCategories.append( categories[i] ); 446 mCategories.append( categories[i] );
445 } 447 }
446 checkCategories(); 448 checkCategories();
447 updated(); 449 updated();
448 if ( addToRelations ) { 450 if ( addToRelations ) {
449 Incidence * inc; 451 Incidence * inc;
450 QPtrList<Incidence> Relations = relations(); 452 Q3PtrList<Incidence> Relations = relations();
451 for (inc=Relations.first();inc;inc=Relations.next()) { 453 for (inc=Relations.first();inc;inc=Relations.next()) {
452 inc->addCategories( categories, true ); 454 inc->addCategories( categories, true );
453 } 455 }
454 } 456 }
455} 457}
456 458
457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 459void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
458{ 460{
459 if (mReadOnly) return; 461 if (mReadOnly) return;
460 mCategories = categories; 462 mCategories = categories;
461 checkCategories(); 463 checkCategories();
462 updated(); 464 updated();
463 if ( setForRelations ) { 465 if ( setForRelations ) {
464 Incidence * inc; 466 Incidence * inc;
465 QPtrList<Incidence> Relations = relations(); 467 Q3PtrList<Incidence> Relations = relations();
466 for (inc=Relations.first();inc;inc=Relations.next()) { 468 for (inc=Relations.first();inc;inc=Relations.next()) {
467 inc->setCategories( categories, true ); 469 inc->setCategories( categories, true );
468 } 470 }
469 } 471 }
470} 472}
471 473
472// TODO: remove setCategories(QString) function 474// TODO: remove setCategories(QString) function
473void Incidence::setCategories(const QString &catStr) 475void Incidence::setCategories(const QString &catStr)
@@ -545,25 +547,25 @@ void Incidence::setRelatedTo(Incidence *relatedTo)
545 } 547 }
546} 548}
547 549
548Incidence *Incidence::relatedTo() const 550Incidence *Incidence::relatedTo() const
549{ 551{
550 return mRelatedTo; 552 return mRelatedTo;
551} 553}
552 554
553QPtrList<Incidence> Incidence::relations() const 555Q3PtrList<Incidence> Incidence::relations() const
554{ 556{
555 return mRelations; 557 return mRelations;
556} 558}
557 559
558void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 560void Incidence::addRelationsToList(Q3PtrList<Incidence> *rel)
559{ 561{
560 Incidence* inc; 562 Incidence* inc;
561 QPtrList<Incidence> Relations = relations(); 563 Q3PtrList<Incidence> Relations = relations();
562 for (inc=Relations.first();inc;inc=Relations.next()) { 564 for (inc=Relations.first();inc;inc=Relations.next()) {
563 inc->addRelationsToList( rel ); 565 inc->addRelationsToList( rel );
564 } 566 }
565 if ( rel->findRef( this ) == -1 ) 567 if ( rel->findRef( this ) == -1 )
566 rel->append( this ); 568 rel->append( this );
567} 569}
568 570
569void Incidence::addRelation(Incidence *event) 571void Incidence::addRelation(Incidence *event)
@@ -642,25 +644,25 @@ void Incidence::deleteAttachments(const QString& mime)
642 while (at) { 644 while (at) {
643 if (at->mimeType() == mime) 645 if (at->mimeType() == mime)
644 mAttachments.remove(); 646 mAttachments.remove();
645 else 647 else
646 at = mAttachments.next(); 648 at = mAttachments.next();
647 } 649 }
648} 650}
649 651
650QPtrList<Attachment> Incidence::attachments() const 652Q3PtrList<Attachment> Incidence::attachments() const
651{ 653{
652 return mAttachments; 654 return mAttachments;
653} 655}
654 656
655QPtrList<Attachment> Incidence::attachments(const QString& mime) const 657Q3PtrList<Attachment> Incidence::attachments(const QString& mime) const
656{ 658{
657 QPtrList<Attachment> attachments; 659 Q3PtrList<Attachment> attachments;
658 QPtrListIterator<Attachment> it( mAttachments ); 660 Q3PtrListIterator<Attachment> it( mAttachments );
659 Attachment *at; 661 Attachment *at;
660 while ( (at = it.current()) ) { 662 while ( (at = it.current()) ) {
661 if (at->mimeType() == mime) 663 if (at->mimeType() == mime)
662 attachments.append(at); 664 attachments.append(at);
663 ++it; 665 ++it;
664 } 666 }
665 667
666 return attachments; 668 return attachments;
@@ -732,17 +734,17 @@ QStringList Incidence::secrecyList()
732 list << secrecyName(SecrecyPublic); 734 list << secrecyName(SecrecyPublic);
733 list << secrecyName(SecrecyPrivate); 735 list << secrecyName(SecrecyPrivate);
734 list << secrecyName(SecrecyConfidential); 736 list << secrecyName(SecrecyConfidential);
735 737
736 return list; 738 return list;
737} 739}
738 740
739 741
740QPtrList<Alarm> Incidence::alarms() const 742Q3PtrList<Alarm> Incidence::alarms() const
741{ 743{
742 return mAlarms; 744 return mAlarms;
743} 745}
744 746
745Alarm* Incidence::newAlarm() 747Alarm* Incidence::newAlarm()
746{ 748{
747 Alarm* alarm = new Alarm(this); 749 Alarm* alarm = new Alarm(this);
748 mAlarms.append(alarm); 750 mAlarms.append(alarm);
@@ -766,17 +768,17 @@ void Incidence::clearAlarms()
766{ 768{
767 mAlarms.clear(); 769 mAlarms.clear();
768 updated(); 770 updated();
769} 771}
770 772
771bool Incidence::isAlarmEnabled() const 773bool Incidence::isAlarmEnabled() const
772{ 774{
773 Alarm* alarm; 775 Alarm* alarm;
774 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 776 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
775 if (alarm->enabled()) 777 if (alarm->enabled())
776 return true; 778 return true;
777 } 779 }
778 return false; 780 return false;
779} 781}
780#include <stdlib.h> 782#include <stdlib.h>
781Recurrence *Incidence::recurrence() 783Recurrence *Incidence::recurrence()
782{ 784{