author | zautrix <zautrix> | 2005-04-18 10:41:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-18 10:41:31 (UTC) |
commit | 409e329447a7d00a93a56855fcddadbb0f793163 (patch) (unidiff) | |
tree | 1c92498d2dfb4c89358c64a6944aca1300a27d11 /libkcal | |
parent | 0ff0dca7ccb94ebb1381351e4e4081fe0bac500a (diff) | |
download | kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.zip kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.tar.gz kdepimpi-409e329447a7d00a93a56855fcddadbb0f793163.tar.bz2 |
morefixes
-rw-r--r-- | libkcal/incidence.cpp | 28 | ||||
-rw-r--r-- | libkcal/incidence.h | 3 |
2 files changed, 29 insertions, 2 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 9c35b1d..762103f 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -300,102 +300,128 @@ void Incidence::setRevision(int rev) | |||
300 | 300 | ||
301 | updated(); | 301 | updated(); |
302 | } | 302 | } |
303 | 303 | ||
304 | int Incidence::revision() const | 304 | int Incidence::revision() const |
305 | { | 305 | { |
306 | return mRevision; | 306 | return mRevision; |
307 | } | 307 | } |
308 | 308 | ||
309 | void Incidence::setDtStart(const QDateTime &dtStart) | 309 | void Incidence::setDtStart(const QDateTime &dtStart) |
310 | { | 310 | { |
311 | 311 | ||
312 | QDateTime dt = getEvenTime(dtStart); | 312 | QDateTime dt = getEvenTime(dtStart); |
313 | recurrence()->setRecurStart( dt); | 313 | recurrence()->setRecurStart( dt); |
314 | IncidenceBase::setDtStart( dt ); | 314 | IncidenceBase::setDtStart( dt ); |
315 | } | 315 | } |
316 | 316 | ||
317 | void Incidence::setDescription(const QString &description) | 317 | void Incidence::setDescription(const QString &description) |
318 | { | 318 | { |
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::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
349 | { | ||
350 | if (mReadOnly) return; | ||
351 | int i; | ||
352 | for( i = 0; i < categories.count(); ++i ) { | ||
353 | if ( !mCategories.contains (categories[i])) | ||
354 | mCategories.append( categories[i] ); | ||
355 | } | ||
356 | checkCategories(); | ||
357 | updated(); | ||
358 | if ( addToRelations ) { | ||
359 | Incidence * inc; | ||
360 | QPtrList<Incidence> Relations = relations(); | ||
361 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
362 | inc->addCategories( categories, true ); | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | |||
367 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | ||
349 | { | 368 | { |
350 | if (mReadOnly) return; | 369 | if (mReadOnly) return; |
351 | mCategories = categories; | 370 | mCategories = categories; |
352 | checkCategories(); | 371 | checkCategories(); |
353 | updated(); | 372 | updated(); |
373 | if ( setForRelations ) { | ||
374 | Incidence * inc; | ||
375 | QPtrList<Incidence> Relations = relations(); | ||
376 | for (inc=Relations.first();inc;inc=Relations.next()) { | ||
377 | inc->setCategories( categories, true ); | ||
378 | } | ||
379 | } | ||
354 | } | 380 | } |
355 | 381 | ||
356 | // TODO: remove setCategories(QString) function | 382 | // TODO: remove setCategories(QString) function |
357 | void Incidence::setCategories(const QString &catStr) | 383 | void Incidence::setCategories(const QString &catStr) |
358 | { | 384 | { |
359 | if (mReadOnly) return; | 385 | if (mReadOnly) return; |
360 | mCategories.clear(); | 386 | mCategories.clear(); |
361 | 387 | ||
362 | if (catStr.isEmpty()) return; | 388 | if (catStr.isEmpty()) return; |
363 | 389 | ||
364 | mCategories = QStringList::split(",",catStr); | 390 | mCategories = QStringList::split(",",catStr); |
365 | 391 | ||
366 | QStringList::Iterator it; | 392 | QStringList::Iterator it; |
367 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 393 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
368 | *it = (*it).stripWhiteSpace(); | 394 | *it = (*it).stripWhiteSpace(); |
369 | } | 395 | } |
370 | checkCategories(); | 396 | checkCategories(); |
371 | updated(); | 397 | updated(); |
372 | } | 398 | } |
373 | 399 | ||
374 | QStringList Incidence::categories() const | 400 | QStringList Incidence::categories() const |
375 | { | 401 | { |
376 | return mCategories; | 402 | return mCategories; |
377 | } | 403 | } |
378 | 404 | ||
379 | QString Incidence::categoriesStr() | 405 | QString Incidence::categoriesStr() |
380 | { | 406 | { |
381 | return mCategories.join(","); | 407 | return mCategories.join(","); |
382 | } | 408 | } |
383 | QString Incidence::categoriesStrWithSpace() | 409 | QString Incidence::categoriesStrWithSpace() |
384 | { | 410 | { |
385 | return mCategories.join(", "); | 411 | return mCategories.join(", "); |
386 | } | 412 | } |
387 | 413 | ||
388 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 414 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
389 | { | 415 | { |
390 | if (mReadOnly) return; | 416 | if (mReadOnly) return; |
391 | mRelatedToUid = relatedToUid; | 417 | mRelatedToUid = relatedToUid; |
392 | } | 418 | } |
393 | 419 | ||
394 | QString Incidence::relatedToUid() const | 420 | QString Incidence::relatedToUid() const |
395 | { | 421 | { |
396 | return mRelatedToUid; | 422 | return mRelatedToUid; |
397 | } | 423 | } |
398 | 424 | ||
399 | void Incidence::setRelatedTo(Incidence *relatedTo) | 425 | void Incidence::setRelatedTo(Incidence *relatedTo) |
400 | { | 426 | { |
401 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 427 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 327e7dd..ebd50d0 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -106,97 +106,98 @@ class Incidence : public IncidenceBase | |||
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, bool setForRelations = false); |
155 | void addCategories(const QStringList &categories, bool addToRelations = false); | ||
155 | /** set event's categories based on a comma delimited string */ | 156 | /** set event's categories based on a comma delimited string */ |
156 | void setCategories(const QString &catStr); | 157 | void setCategories(const QString &catStr); |
157 | /** return categories in a list */ | 158 | /** return categories in a list */ |
158 | QStringList categories() const; | 159 | QStringList categories() const; |
159 | /** return categories as a comma separated string */ | 160 | /** return categories as a comma separated string */ |
160 | QString categoriesStr(); | 161 | QString categoriesStr(); |
161 | QString categoriesStrWithSpace(); | 162 | QString categoriesStrWithSpace(); |
162 | 163 | ||
163 | /** 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 |
164 | * only be used when constructing a calendar before the related Event | 165 | * only be used when constructing a calendar before the related Event |
165 | * exists. */ | 166 | * exists. */ |
166 | void setRelatedToUid(const QString &); | 167 | void setRelatedToUid(const QString &); |
167 | /** what event does this one relate to? This function should | 168 | /** what event does this one relate to? This function should |
168 | * only be used when constructing a calendar before the related Event | 169 | * only be used when constructing a calendar before the related Event |
169 | * exists. */ | 170 | * exists. */ |
170 | QString relatedToUid() const; | 171 | QString relatedToUid() const; |
171 | /** point at some other event to which the event relates */ | 172 | /** point at some other event to which the event relates */ |
172 | void setRelatedTo(Incidence *relatedTo); | 173 | void setRelatedTo(Incidence *relatedTo); |
173 | /** what event does this one relate to? */ | 174 | /** what event does this one relate to? */ |
174 | Incidence *relatedTo() const; | 175 | Incidence *relatedTo() const; |
175 | /** All events that are related to this event */ | 176 | /** All events that are related to this event */ |
176 | QPtrList<Incidence> relations() const; | 177 | QPtrList<Incidence> relations() const; |
177 | /** Add an event which is related to this event */ | 178 | /** Add an event which is related to this event */ |
178 | void addRelation(Incidence *); | 179 | void addRelation(Incidence *); |
179 | /** Remove event that is related to this event */ | 180 | /** Remove event that is related to this event */ |
180 | void removeRelation(Incidence *); | 181 | void removeRelation(Incidence *); |
181 | 182 | ||
182 | /** returns the list of dates which are exceptions to the recurrence rule */ | 183 | /** returns the list of dates which are exceptions to the recurrence rule */ |
183 | DateList exDates() const; | 184 | DateList exDates() const; |
184 | /** sets the list of dates which are exceptions to the recurrence rule */ | 185 | /** sets the list of dates which are exceptions to the recurrence rule */ |
185 | void setExDates(const DateList &_exDates); | 186 | void setExDates(const DateList &_exDates); |
186 | void setExDates(const char *dates); | 187 | void setExDates(const char *dates); |
187 | /** Add a date to the list of exceptions of the recurrence rule. */ | 188 | /** Add a date to the list of exceptions of the recurrence rule. */ |
188 | void addExDate(const QDate &date); | 189 | void addExDate(const QDate &date); |
189 | 190 | ||
190 | /** returns true if there is an exception for this date in the recurrence | 191 | /** returns true if there is an exception for this date in the recurrence |
191 | rule set, or false otherwise. */ | 192 | rule set, or false otherwise. */ |
192 | bool isException(const QDate &qd) const; | 193 | bool isException(const QDate &qd) const; |
193 | 194 | ||
194 | /** add attachment to this event */ | 195 | /** add attachment to this event */ |
195 | void addAttachment(Attachment *attachment); | 196 | void addAttachment(Attachment *attachment); |
196 | /** remove and delete a specific attachment */ | 197 | /** remove and delete a specific attachment */ |
197 | void deleteAttachment(Attachment *attachment); | 198 | void deleteAttachment(Attachment *attachment); |
198 | /** remove and delete all attachments with this mime type */ | 199 | /** remove and delete all attachments with this mime type */ |
199 | void deleteAttachments(const QString& mime); | 200 | void deleteAttachments(const QString& mime); |
200 | /** return list of all associated attachments */ | 201 | /** return list of all associated attachments */ |
201 | QPtrList<Attachment> attachments() const; | 202 | QPtrList<Attachment> attachments() const; |
202 | /** find a list of attachments with this mime type */ | 203 | /** find a list of attachments with this mime type */ |