-rw-r--r-- | libkcal/incidence.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 9c35b1d..762103f 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -332,38 +332,64 @@ void Incidence::setSummary(const QString &summary) | |||
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 | } |