From 2e070a13072e076c2f148f04745d9ad20f747e0f Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 4 Aug 2008 07:59:32 +0000 Subject: [PATCH] track group names as well svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=841830 --- configxml.cpp | 9 ++++++++- configxml.h | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/configxml.cpp b/configxml.cpp index eb302dd68..5e2d2700e 100644 --- a/configxml.cpp +++ b/configxml.cpp @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -193,7 +194,7 @@ class ConfigXmlPrivate QList sizes; QList ulonglongs; QList urllists; - QMap keysToNames; + QHash keysToNames; }; class ConfigXmlHandler : public QXmlDefaultHandler @@ -257,6 +258,7 @@ bool ConfigXmlHandler::startElement(const QString &namespaceURI, const QString & QString name = attrs.localName(i).toLower(); if (name == "name") { kDebug() << "set group to " << attrs.value(i); + d->keysToNames.insert(attrs.value(i), QString()); m_config->setCurrentGroup(attrs.value(i)); } } @@ -535,4 +537,9 @@ KConfigSkeletonItem* ConfigXml::findItem(const QString &group, const QString &ke return KConfigSkeleton::findItem(d->keysToNames[group + key]); } +bool ConfigXml::hasGroup(const QString &group) const +{ + return d->keysToNames.contains(group); +} + } // Plasma namespace diff --git a/configxml.h b/configxml.h index 077395f88..97d2078d4 100644 --- a/configxml.h +++ b/configxml.h @@ -108,6 +108,14 @@ public: KConfigSkeletonItem* findItem(const QString &group, const QString &key); + /** + * Check to see if a group exists + * + * @param group the name of the group to check for + * @return true if the group exists, or false if it does not + */ + bool hasGroup(const QString &group) const; + private: ConfigXmlPrivate * const d; };