-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 @@ -340,22 +340,48 @@ QString Incidence::summary() const } void Incidence::checkCategories() { mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); } -void Incidence::setCategories(const QStringList &categories) +void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false +{ + if (mReadOnly) return; + int i; + for( i = 0; i < categories.count(); ++i ) { + if ( !mCategories.contains (categories[i])) + mCategories.append( categories[i] ); + } + checkCategories(); + updated(); + if ( addToRelations ) { + Incidence * inc; + QPtrList<Incidence> Relations = relations(); + for (inc=Relations.first();inc;inc=Relations.next()) { + inc->addCategories( categories, true ); + } + } +} + +void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false { if (mReadOnly) return; mCategories = categories; checkCategories(); updated(); + if ( setForRelations ) { + Incidence * inc; + QPtrList<Incidence> Relations = relations(); + for (inc=Relations.first();inc;inc=Relations.next()) { + inc->setCategories( categories, true ); + } + } } // TODO: remove setCategories(QString) function void Incidence::setCategories(const QString &catStr) { if (mReadOnly) return; mCategories.clear(); |