-rw-r--r-- | libkcal/incidence.cpp | 11 | ||||
-rw-r--r-- | libkcal/incidence.h | 2 |
2 files changed, 12 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index f446197..4382416 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -389,128 +389,139 @@ void Incidence::setCategories(const QString &catStr) | |||
389 | 389 | ||
390 | mCategories = QStringList::split(",",catStr); | 390 | mCategories = QStringList::split(",",catStr); |
391 | 391 | ||
392 | QStringList::Iterator it; | 392 | QStringList::Iterator it; |
393 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 393 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
394 | *it = (*it).stripWhiteSpace(); | 394 | *it = (*it).stripWhiteSpace(); |
395 | } | 395 | } |
396 | checkCategories(); | 396 | checkCategories(); |
397 | updated(); | 397 | updated(); |
398 | } | 398 | } |
399 | 399 | ||
400 | QStringList Incidence::categories() const | 400 | QStringList Incidence::categories() const |
401 | { | 401 | { |
402 | return mCategories; | 402 | return mCategories; |
403 | } | 403 | } |
404 | 404 | ||
405 | QString Incidence::categoriesStr() | 405 | QString Incidence::categoriesStr() |
406 | { | 406 | { |
407 | return mCategories.join(","); | 407 | return mCategories.join(","); |
408 | } | 408 | } |
409 | QString Incidence::categoriesStrWithSpace() | 409 | QString Incidence::categoriesStrWithSpace() |
410 | { | 410 | { |
411 | return mCategories.join(", "); | 411 | return mCategories.join(", "); |
412 | } | 412 | } |
413 | 413 | ||
414 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 414 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
415 | { | 415 | { |
416 | if (mReadOnly) return; | 416 | if (mReadOnly) return; |
417 | mRelatedToUid = relatedToUid; | 417 | mRelatedToUid = relatedToUid; |
418 | } | 418 | } |
419 | 419 | ||
420 | QString Incidence::relatedToUid() const | 420 | QString Incidence::relatedToUid() const |
421 | { | 421 | { |
422 | return mRelatedToUid; | 422 | return mRelatedToUid; |
423 | } | 423 | } |
424 | 424 | ||
425 | void Incidence::setRelatedTo(Incidence *relatedTo) | 425 | void Incidence::setRelatedTo(Incidence *relatedTo) |
426 | { | 426 | { |
427 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 427 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
428 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 428 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
429 | if (mReadOnly || mRelatedTo == relatedTo) return; | 429 | if (mReadOnly || mRelatedTo == relatedTo) return; |
430 | if(mRelatedTo) { | 430 | if(mRelatedTo) { |
431 | // updated(); | 431 | // updated(); |
432 | mRelatedTo->removeRelation(this); | 432 | mRelatedTo->removeRelation(this); |
433 | } | 433 | } |
434 | mRelatedTo = relatedTo; | 434 | mRelatedTo = relatedTo; |
435 | if (mRelatedTo) { | 435 | if (mRelatedTo) { |
436 | mRelatedTo->addRelation(this); | 436 | mRelatedTo->addRelation(this); |
437 | mRelatedToUid = mRelatedTo->uid(); | 437 | mRelatedToUid = mRelatedTo->uid(); |
438 | } else { | 438 | } else { |
439 | mRelatedToUid = ""; | 439 | mRelatedToUid = ""; |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | Incidence *Incidence::relatedTo() const | 443 | Incidence *Incidence::relatedTo() const |
444 | { | 444 | { |
445 | return mRelatedTo; | 445 | return mRelatedTo; |
446 | } | 446 | } |
447 | 447 | ||
448 | QPtrList<Incidence> Incidence::relations() const | 448 | QPtrList<Incidence> Incidence::relations() const |
449 | { | 449 | { |
450 | return mRelations; | 450 | return mRelations; |
451 | } | 451 | } |
452 | 452 | ||
453 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | ||
454 | { | ||
455 | Incidence* inc; | ||
456 | QPtrList<Incidence> Relations = relations(); | ||
457 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
458 | inc->addRelationsToList( rel ); | ||
459 | } | ||
460 | if ( rel->findRef( this ) == -1 ) | ||
461 | rel->append( this ); | ||
462 | } | ||
463 | |||
453 | void Incidence::addRelation(Incidence *event) | 464 | void Incidence::addRelation(Incidence *event) |
454 | { | 465 | { |
455 | if( mRelations.findRef( event ) == -1 ) { | 466 | if( mRelations.findRef( event ) == -1 ) { |
456 | mRelations.append(event); | 467 | mRelations.append(event); |
457 | //updated(); | 468 | //updated(); |
458 | } | 469 | } |
459 | } | 470 | } |
460 | 471 | ||
461 | void Incidence::removeRelation(Incidence *event) | 472 | void Incidence::removeRelation(Incidence *event) |
462 | { | 473 | { |
463 | 474 | ||
464 | mRelations.removeRef(event); | 475 | mRelations.removeRef(event); |
465 | 476 | ||
466 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 477 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
467 | } | 478 | } |
468 | 479 | ||
469 | bool Incidence::recursOn(const QDate &qd) const | 480 | bool Incidence::recursOn(const QDate &qd) const |
470 | { | 481 | { |
471 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 482 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
472 | else return false; | 483 | else return false; |
473 | } | 484 | } |
474 | 485 | ||
475 | void Incidence::setExDates(const DateList &exDates) | 486 | void Incidence::setExDates(const DateList &exDates) |
476 | { | 487 | { |
477 | if (mReadOnly) return; | 488 | if (mReadOnly) return; |
478 | mExDates = exDates; | 489 | mExDates = exDates; |
479 | 490 | ||
480 | recurrence()->setRecurExDatesCount(mExDates.count()); | 491 | recurrence()->setRecurExDatesCount(mExDates.count()); |
481 | 492 | ||
482 | updated(); | 493 | updated(); |
483 | } | 494 | } |
484 | 495 | ||
485 | void Incidence::addExDate(const QDate &date) | 496 | void Incidence::addExDate(const QDate &date) |
486 | { | 497 | { |
487 | if (mReadOnly) return; | 498 | if (mReadOnly) return; |
488 | mExDates.append(date); | 499 | mExDates.append(date); |
489 | 500 | ||
490 | recurrence()->setRecurExDatesCount(mExDates.count()); | 501 | recurrence()->setRecurExDatesCount(mExDates.count()); |
491 | 502 | ||
492 | updated(); | 503 | updated(); |
493 | } | 504 | } |
494 | 505 | ||
495 | DateList Incidence::exDates() const | 506 | DateList Incidence::exDates() const |
496 | { | 507 | { |
497 | return mExDates; | 508 | return mExDates; |
498 | } | 509 | } |
499 | 510 | ||
500 | bool Incidence::isException(const QDate &date) const | 511 | bool Incidence::isException(const QDate &date) const |
501 | { | 512 | { |
502 | DateList::ConstIterator it; | 513 | DateList::ConstIterator it; |
503 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 514 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
504 | if ( (*it) == date ) { | 515 | if ( (*it) == date ) { |
505 | return true; | 516 | return true; |
506 | } | 517 | } |
507 | } | 518 | } |
508 | 519 | ||
509 | return false; | 520 | return false; |
510 | } | 521 | } |
511 | 522 | ||
512 | void Incidence::addAttachment(Attachment *attachment) | 523 | void Incidence::addAttachment(Attachment *attachment) |
513 | { | 524 | { |
514 | if (mReadOnly || !attachment) return; | 525 | if (mReadOnly || !attachment) return; |
515 | mAttachments.append(attachment); | 526 | mAttachments.append(attachment); |
516 | updated(); | 527 | updated(); |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index aa51e84..fc97ce9 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -52,129 +52,129 @@ class Incidence : public IncidenceBase | |||
52 | types of calendar components, without changing the calendar component classes. | 52 | types of calendar components, without changing the calendar component classes. |
53 | */ | 53 | */ |
54 | class Visitor | 54 | class Visitor |
55 | { | 55 | { |
56 | public: | 56 | public: |
57 | /** Destruct Incidence::Visitor */ | 57 | /** Destruct Incidence::Visitor */ |
58 | virtual ~Visitor() {} | 58 | virtual ~Visitor() {} |
59 | 59 | ||
60 | /** | 60 | /** |
61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 61 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
62 | on an Event object. | 62 | on an Event object. |
63 | */ | 63 | */ |
64 | virtual bool visit(Event *) { return false; } | 64 | virtual bool visit(Event *) { return false; } |
65 | /** | 65 | /** |
66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 66 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
67 | on an Todo object. | 67 | on an Todo object. |
68 | */ | 68 | */ |
69 | virtual bool visit(Todo *) { return false; } | 69 | virtual bool visit(Todo *) { return false; } |
70 | /** | 70 | /** |
71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions | 71 | Reimplement this function in your concrete subclass of IncidenceVisitor to perform actions |
72 | on an Journal object. | 72 | on an Journal object. |
73 | */ | 73 | */ |
74 | virtual bool visit(Journal *) { return false; } | 74 | virtual bool visit(Journal *) { return false; } |
75 | 75 | ||
76 | protected: | 76 | protected: |
77 | /** Constructor is protected to prevent direct creation of visitor base class. */ | 77 | /** Constructor is protected to prevent direct creation of visitor base class. */ |
78 | Visitor() {} | 78 | Visitor() {} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /** | 81 | /** |
82 | This class implements a visitor for adding an Incidence to a resource | 82 | This class implements a visitor for adding an Incidence to a resource |
83 | supporting addEvent(), addTodo() and addJournal() calls. | 83 | supporting addEvent(), addTodo() and addJournal() calls. |
84 | */ | 84 | */ |
85 | template<class T> | 85 | template<class T> |
86 | class AddVisitor : public Visitor | 86 | class AddVisitor : public Visitor |
87 | { | 87 | { |
88 | public: | 88 | public: |
89 | AddVisitor( T *r ) : mResource( r ) {} | 89 | AddVisitor( T *r ) : mResource( r ) {} |
90 | bool visit( Event *e ) { return mResource->addEvent( e ); } | 90 | bool visit( Event *e ) { return mResource->addEvent( e ); } |
91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } | 91 | bool visit( Todo *t ) { return mResource->addTodo( t ); } |
92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } | 92 | bool visit( Journal *j ) { return mResource->addJournal( j ); } |
93 | 93 | ||
94 | private: | 94 | private: |
95 | T *mResource; | 95 | T *mResource; |
96 | }; | 96 | }; |
97 | 97 | ||
98 | /** enumeration for describing an event's secrecy. */ | 98 | /** enumeration for describing an event's secrecy. */ |
99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; | 99 | enum { SecrecyPublic = 0, SecrecyPrivate = 1, SecrecyConfidential = 2 }; |
100 | typedef ListBase<Incidence> List; | 100 | typedef ListBase<Incidence> List; |
101 | Incidence(); | 101 | Incidence(); |
102 | Incidence(const Incidence &); | 102 | Incidence(const Incidence &); |
103 | ~Incidence(); | 103 | ~Incidence(); |
104 | 104 | ||
105 | /** | 105 | /** |
106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to | 106 | Accept IncidenceVisitor. A class taking part in the visitor mechanism has to |
107 | provide this implementation: | 107 | provide this implementation: |
108 | <pre> | 108 | <pre> |
109 | bool accept(Visitor &v) { return v.visit(this); } | 109 | bool accept(Visitor &v) { return v.visit(this); } |
110 | </pre> | 110 | </pre> |
111 | */ | 111 | */ |
112 | virtual bool accept(Visitor &) { return false; } | 112 | virtual bool accept(Visitor &) { return false; } |
113 | 113 | ||
114 | virtual Incidence *clone() = 0; | 114 | virtual Incidence *clone() = 0; |
115 | virtual void cloneRelations( Incidence * ); | 115 | virtual void cloneRelations( Incidence * ); |
116 | 116 | void addRelationsToList(QPtrList<Incidence> *rel); | |
117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; | 117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; |
118 | void setReadOnly( bool ); | 118 | void setReadOnly( bool ); |
119 | 119 | ||
120 | /** | 120 | /** |
121 | Recreate event. The event is made a new unique event, but already stored | 121 | Recreate event. The event is made a new unique event, but already stored |
122 | event information is preserved. Sets uniquie id, creation date, last | 122 | event information is preserved. Sets uniquie id, creation date, last |
123 | modification date and revision number. | 123 | modification date and revision number. |
124 | */ | 124 | */ |
125 | void recreate(); | 125 | void recreate(); |
126 | Incidence* recreateCloneException(QDate); | 126 | Incidence* recreateCloneException(QDate); |
127 | 127 | ||
128 | /** set creation date */ | 128 | /** set creation date */ |
129 | void setCreated(QDateTime); | 129 | void setCreated(QDateTime); |
130 | /** return time and date of creation. */ | 130 | /** return time and date of creation. */ |
131 | QDateTime created() const; | 131 | QDateTime created() const; |
132 | 132 | ||
133 | /** set the number of revisions this event has seen */ | 133 | /** set the number of revisions this event has seen */ |
134 | void setRevision(int rev); | 134 | void setRevision(int rev); |
135 | /** return the number of revisions this event has seen */ | 135 | /** return the number of revisions this event has seen */ |
136 | int revision() const; | 136 | int revision() const; |
137 | 137 | ||
138 | /** Set starting date/time. */ | 138 | /** Set starting date/time. */ |
139 | virtual void setDtStart(const QDateTime &dtStart); | 139 | virtual void setDtStart(const QDateTime &dtStart); |
140 | /** Return the incidence's ending date/time as a QDateTime. */ | 140 | /** Return the incidence's ending date/time as a QDateTime. */ |
141 | virtual QDateTime dtEnd() const { return QDateTime(); } | 141 | virtual QDateTime dtEnd() const { return QDateTime(); } |
142 | 142 | ||
143 | /** sets the event's lengthy description. */ | 143 | /** sets the event's lengthy description. */ |
144 | void setDescription(const QString &description); | 144 | void setDescription(const QString &description); |
145 | /** returns a reference to the event's description. */ | 145 | /** returns a reference to the event's description. */ |
146 | QString description() const; | 146 | QString description() const; |
147 | 147 | ||
148 | /** sets the event's short summary. */ | 148 | /** sets the event's short summary. */ |
149 | void setSummary(const QString &summary); | 149 | void setSummary(const QString &summary); |
150 | /** returns a reference to the event's summary. */ | 150 | /** returns a reference to the event's summary. */ |
151 | QString summary() const; | 151 | QString summary() const; |
152 | 152 | ||
153 | /** set event's applicable categories */ | 153 | /** set event's applicable categories */ |
154 | void setCategories(const QStringList &categories, bool setForRelations = false); | 154 | void setCategories(const QStringList &categories, bool setForRelations = false); |
155 | void addCategories(const QStringList &categories, bool addToRelations = false); | 155 | void addCategories(const QStringList &categories, bool addToRelations = false); |
156 | /** set event's categories based on a comma delimited string */ | 156 | /** set event's categories based on a comma delimited string */ |
157 | void setCategories(const QString &catStr); | 157 | void setCategories(const QString &catStr); |
158 | /** return categories in a list */ | 158 | /** return categories in a list */ |
159 | QStringList categories() const; | 159 | QStringList categories() const; |
160 | /** return categories as a comma separated string */ | 160 | /** return categories as a comma separated string */ |
161 | QString categoriesStr(); | 161 | QString categoriesStr(); |
162 | QString categoriesStrWithSpace(); | 162 | QString categoriesStrWithSpace(); |
163 | 163 | ||
164 | /** point at some other event to which the event relates. This function should | 164 | /** point at some other event to which the event relates. This function should |
165 | * only be used when constructing a calendar before the related Event | 165 | * only be used when constructing a calendar before the related Event |
166 | * exists. */ | 166 | * exists. */ |
167 | void setRelatedToUid(const QString &); | 167 | void setRelatedToUid(const QString &); |
168 | /** what event does this one relate to? This function should | 168 | /** what event does this one relate to? This function should |
169 | * only be used when constructing a calendar before the related Event | 169 | * only be used when constructing a calendar before the related Event |
170 | * exists. */ | 170 | * exists. */ |
171 | QString relatedToUid() const; | 171 | QString relatedToUid() const; |
172 | /** point at some other event to which the event relates */ | 172 | /** point at some other event to which the event relates */ |
173 | void setRelatedTo(Incidence *relatedTo); | 173 | void setRelatedTo(Incidence *relatedTo); |
174 | /** what event does this one relate to? */ | 174 | /** what event does this one relate to? */ |
175 | Incidence *relatedTo() const; | 175 | Incidence *relatedTo() const; |
176 | /** All events that are related to this event */ | 176 | /** All events that are related to this event */ |
177 | QPtrList<Incidence> relations() const; | 177 | QPtrList<Incidence> relations() const; |
178 | /** Add an event which is related to this event */ | 178 | /** Add an event which is related to this event */ |
179 | void addRelation(Incidence *); | 179 | void addRelation(Incidence *); |
180 | /** Remove event that is related to this event */ | 180 | /** Remove event that is related to this event */ |