-rw-r--r-- | libkcal/incidence.cpp | 4 | ||||
-rw-r--r-- | libkcal/incidence.h | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 78fa24f..9c35b1d 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -319,128 +319,132 @@ void Incidence::setDescription(const QString &description) | |||
319 | if (mReadOnly) return; | 319 | if (mReadOnly) return; |
320 | mDescription = description; | 320 | mDescription = description; |
321 | updated(); | 321 | updated(); |
322 | } | 322 | } |
323 | 323 | ||
324 | QString Incidence::description() const | 324 | QString Incidence::description() const |
325 | { | 325 | { |
326 | return mDescription; | 326 | return mDescription; |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | void Incidence::setSummary(const QString &summary) | 330 | void Incidence::setSummary(const QString &summary) |
331 | { | 331 | { |
332 | if (mReadOnly) return; | 332 | if (mReadOnly) return; |
333 | mSummary = summary; | 333 | mSummary = summary; |
334 | updated(); | 334 | updated(); |
335 | } | 335 | } |
336 | 336 | ||
337 | QString Incidence::summary() const | 337 | QString Incidence::summary() const |
338 | { | 338 | { |
339 | return mSummary; | 339 | return mSummary; |
340 | } | 340 | } |
341 | void Incidence::checkCategories() | 341 | void Incidence::checkCategories() |
342 | { | 342 | { |
343 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 343 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
344 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 344 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
345 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 345 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
346 | } | 346 | } |
347 | 347 | ||
348 | void Incidence::setCategories(const QStringList &categories) | 348 | void Incidence::setCategories(const QStringList &categories) |
349 | { | 349 | { |
350 | if (mReadOnly) return; | 350 | if (mReadOnly) return; |
351 | mCategories = categories; | 351 | mCategories = categories; |
352 | checkCategories(); | 352 | checkCategories(); |
353 | updated(); | 353 | updated(); |
354 | } | 354 | } |
355 | 355 | ||
356 | // TODO: remove setCategories(QString) function | 356 | // TODO: remove setCategories(QString) function |
357 | void Incidence::setCategories(const QString &catStr) | 357 | void Incidence::setCategories(const QString &catStr) |
358 | { | 358 | { |
359 | if (mReadOnly) return; | 359 | if (mReadOnly) return; |
360 | mCategories.clear(); | 360 | mCategories.clear(); |
361 | 361 | ||
362 | if (catStr.isEmpty()) return; | 362 | if (catStr.isEmpty()) return; |
363 | 363 | ||
364 | mCategories = QStringList::split(",",catStr); | 364 | mCategories = QStringList::split(",",catStr); |
365 | 365 | ||
366 | QStringList::Iterator it; | 366 | QStringList::Iterator it; |
367 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 367 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
368 | *it = (*it).stripWhiteSpace(); | 368 | *it = (*it).stripWhiteSpace(); |
369 | } | 369 | } |
370 | checkCategories(); | 370 | checkCategories(); |
371 | updated(); | 371 | updated(); |
372 | } | 372 | } |
373 | 373 | ||
374 | QStringList Incidence::categories() const | 374 | QStringList Incidence::categories() const |
375 | { | 375 | { |
376 | return mCategories; | 376 | return mCategories; |
377 | } | 377 | } |
378 | 378 | ||
379 | QString Incidence::categoriesStr() | 379 | QString Incidence::categoriesStr() |
380 | { | 380 | { |
381 | return mCategories.join(","); | 381 | return mCategories.join(","); |
382 | } | 382 | } |
383 | QString Incidence::categoriesStrWithSpace() | ||
384 | { | ||
385 | return mCategories.join(", "); | ||
386 | } | ||
383 | 387 | ||
384 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 388 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
385 | { | 389 | { |
386 | if (mReadOnly) return; | 390 | if (mReadOnly) return; |
387 | mRelatedToUid = relatedToUid; | 391 | mRelatedToUid = relatedToUid; |
388 | } | 392 | } |
389 | 393 | ||
390 | QString Incidence::relatedToUid() const | 394 | QString Incidence::relatedToUid() const |
391 | { | 395 | { |
392 | return mRelatedToUid; | 396 | return mRelatedToUid; |
393 | } | 397 | } |
394 | 398 | ||
395 | void Incidence::setRelatedTo(Incidence *relatedTo) | 399 | void Incidence::setRelatedTo(Incidence *relatedTo) |
396 | { | 400 | { |
397 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 401 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
398 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 402 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
399 | if (mReadOnly || mRelatedTo == relatedTo) return; | 403 | if (mReadOnly || mRelatedTo == relatedTo) return; |
400 | if(mRelatedTo) { | 404 | if(mRelatedTo) { |
401 | // updated(); | 405 | // updated(); |
402 | mRelatedTo->removeRelation(this); | 406 | mRelatedTo->removeRelation(this); |
403 | } | 407 | } |
404 | mRelatedTo = relatedTo; | 408 | mRelatedTo = relatedTo; |
405 | if (mRelatedTo) { | 409 | if (mRelatedTo) { |
406 | mRelatedTo->addRelation(this); | 410 | mRelatedTo->addRelation(this); |
407 | mRelatedToUid = mRelatedTo->uid(); | 411 | mRelatedToUid = mRelatedTo->uid(); |
408 | } else { | 412 | } else { |
409 | mRelatedToUid = ""; | 413 | mRelatedToUid = ""; |
410 | } | 414 | } |
411 | } | 415 | } |
412 | 416 | ||
413 | Incidence *Incidence::relatedTo() const | 417 | Incidence *Incidence::relatedTo() const |
414 | { | 418 | { |
415 | return mRelatedTo; | 419 | return mRelatedTo; |
416 | } | 420 | } |
417 | 421 | ||
418 | QPtrList<Incidence> Incidence::relations() const | 422 | QPtrList<Incidence> Incidence::relations() const |
419 | { | 423 | { |
420 | return mRelations; | 424 | return mRelations; |
421 | } | 425 | } |
422 | 426 | ||
423 | void Incidence::addRelation(Incidence *event) | 427 | void Incidence::addRelation(Incidence *event) |
424 | { | 428 | { |
425 | if( mRelations.findRef( event ) == -1 ) { | 429 | if( mRelations.findRef( event ) == -1 ) { |
426 | mRelations.append(event); | 430 | mRelations.append(event); |
427 | //updated(); | 431 | //updated(); |
428 | } | 432 | } |
429 | } | 433 | } |
430 | 434 | ||
431 | void Incidence::removeRelation(Incidence *event) | 435 | void Incidence::removeRelation(Incidence *event) |
432 | { | 436 | { |
433 | 437 | ||
434 | mRelations.removeRef(event); | 438 | mRelations.removeRef(event); |
435 | 439 | ||
436 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 440 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
437 | } | 441 | } |
438 | 442 | ||
439 | bool Incidence::recursOn(const QDate &qd) const | 443 | bool Incidence::recursOn(const QDate &qd) const |
440 | { | 444 | { |
441 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 445 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
442 | else return false; | 446 | else return false; |
443 | } | 447 | } |
444 | 448 | ||
445 | void Incidence::setExDates(const DateList &exDates) | 449 | void Incidence::setExDates(const DateList &exDates) |
446 | { | 450 | { |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 60070a2..327e7dd 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -97,128 +97,129 @@ class Incidence : public IncidenceBase | |||
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 | ||
117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; | 117 | virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) 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); | 154 | void setCategories(const QStringList &categories); |
155 | /** set event's categories based on a comma delimited string */ | 155 | /** set event's categories based on a comma delimited string */ |
156 | void setCategories(const QString &catStr); | 156 | void setCategories(const QString &catStr); |
157 | /** return categories in a list */ | 157 | /** return categories in a list */ |
158 | QStringList categories() const; | 158 | QStringList categories() const; |
159 | /** return categories as a comma separated string */ | 159 | /** return categories as a comma separated string */ |
160 | QString categoriesStr(); | 160 | QString categoriesStr(); |
161 | QString categoriesStrWithSpace(); | ||
161 | 162 | ||
162 | /** point at some other event to which the event relates. This function should | 163 | /** point at some other event to which the event relates. This function should |
163 | * only be used when constructing a calendar before the related Event | 164 | * only be used when constructing a calendar before the related Event |
164 | * exists. */ | 165 | * exists. */ |
165 | void setRelatedToUid(const QString &); | 166 | void setRelatedToUid(const QString &); |
166 | /** what event does this one relate to? This function should | 167 | /** what event does this one relate to? This function should |
167 | * only be used when constructing a calendar before the related Event | 168 | * only be used when constructing a calendar before the related Event |
168 | * exists. */ | 169 | * exists. */ |
169 | QString relatedToUid() const; | 170 | QString relatedToUid() const; |
170 | /** point at some other event to which the event relates */ | 171 | /** point at some other event to which the event relates */ |
171 | void setRelatedTo(Incidence *relatedTo); | 172 | void setRelatedTo(Incidence *relatedTo); |
172 | /** what event does this one relate to? */ | 173 | /** what event does this one relate to? */ |
173 | Incidence *relatedTo() const; | 174 | Incidence *relatedTo() const; |
174 | /** All events that are related to this event */ | 175 | /** All events that are related to this event */ |
175 | QPtrList<Incidence> relations() const; | 176 | QPtrList<Incidence> relations() const; |
176 | /** Add an event which is related to this event */ | 177 | /** Add an event which is related to this event */ |
177 | void addRelation(Incidence *); | 178 | void addRelation(Incidence *); |
178 | /** Remove event that is related to this event */ | 179 | /** Remove event that is related to this event */ |
179 | void removeRelation(Incidence *); | 180 | void removeRelation(Incidence *); |
180 | 181 | ||
181 | /** returns the list of dates which are exceptions to the recurrence rule */ | 182 | /** returns the list of dates which are exceptions to the recurrence rule */ |
182 | DateList exDates() const; | 183 | DateList exDates() const; |
183 | /** sets the list of dates which are exceptions to the recurrence rule */ | 184 | /** sets the list of dates which are exceptions to the recurrence rule */ |
184 | void setExDates(const DateList &_exDates); | 185 | void setExDates(const DateList &_exDates); |
185 | void setExDates(const char *dates); | 186 | void setExDates(const char *dates); |
186 | /** Add a date to the list of exceptions of the recurrence rule. */ | 187 | /** Add a date to the list of exceptions of the recurrence rule. */ |
187 | void addExDate(const QDate &date); | 188 | void addExDate(const QDate &date); |
188 | 189 | ||
189 | /** returns true if there is an exception for this date in the recurrence | 190 | /** returns true if there is an exception for this date in the recurrence |
190 | rule set, or false otherwise. */ | 191 | rule set, or false otherwise. */ |
191 | bool isException(const QDate &qd) const; | 192 | bool isException(const QDate &qd) const; |
192 | 193 | ||
193 | /** add attachment to this event */ | 194 | /** add attachment to this event */ |
194 | void addAttachment(Attachment *attachment); | 195 | void addAttachment(Attachment *attachment); |
195 | /** remove and delete a specific attachment */ | 196 | /** remove and delete a specific attachment */ |
196 | void deleteAttachment(Attachment *attachment); | 197 | void deleteAttachment(Attachment *attachment); |
197 | /** remove and delete all attachments with this mime type */ | 198 | /** remove and delete all attachments with this mime type */ |
198 | void deleteAttachments(const QString& mime); | 199 | void deleteAttachments(const QString& mime); |
199 | /** return list of all associated attachments */ | 200 | /** return list of all associated attachments */ |
200 | QPtrList<Attachment> attachments() const; | 201 | QPtrList<Attachment> attachments() const; |
201 | /** find a list of attachments with this mime type */ | 202 | /** find a list of attachments with this mime type */ |
202 | QPtrList<Attachment> attachments(const QString& mime) const; | 203 | QPtrList<Attachment> attachments(const QString& mime) const; |
203 | 204 | ||
204 | /** sets the event's status the value specified. See the enumeration | 205 | /** sets the event's status the value specified. See the enumeration |
205 | * above for possible values. */ | 206 | * above for possible values. */ |
206 | void setSecrecy(int); | 207 | void setSecrecy(int); |
207 | /** return the event's secrecy. */ | 208 | /** return the event's secrecy. */ |
208 | int secrecy() const; | 209 | int secrecy() const; |
209 | /** return the event's secrecy in string format. */ | 210 | /** return the event's secrecy in string format. */ |
210 | QString secrecyStr() const; | 211 | QString secrecyStr() const; |
211 | /** return list of all availbale secrecy classes */ | 212 | /** return list of all availbale secrecy classes */ |
212 | static QStringList secrecyList(); | 213 | static QStringList secrecyList(); |
213 | /** return human-readable name of secrecy class */ | 214 | /** return human-readable name of secrecy class */ |
214 | static QString secrecyName(int); | 215 | static QString secrecyName(int); |
215 | 216 | ||
216 | /** returns TRUE if the date specified is one on which the event will | 217 | /** returns TRUE if the date specified is one on which the event will |
217 | * recur. */ | 218 | * recur. */ |
218 | bool recursOn(const QDate &qd) const; | 219 | bool recursOn(const QDate &qd) const; |
219 | 220 | ||
220 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): | 221 | // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): |
221 | 222 | ||
222 | /** set resources used, such as Office, Car, etc. */ | 223 | /** set resources used, such as Office, Car, etc. */ |
223 | void setResources(const QStringList &resources); | 224 | void setResources(const QStringList &resources); |
224 | /** return list of current resources */ | 225 | /** return list of current resources */ |