[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/kdelibs4_kconfig/kdecore/kconfig
From: Thomas Braxton <brax108 () cox ! net>
Date: 2006-07-26 3:08:26
Message-ID: 1153883306.487910.910.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 566423 by braxton:
implement hasGroup/hasKey/hasDefault with new KEntryMap::hasEntry()
M +14 -29 kconfig.cpp
M +3 -0 kconfig.h
--- branches/work/kdelibs4_kconfig/kdecore/kconfig/kconfig.cpp #566422:566423
@@ -694,42 +694,27 @@
bool KConfig::hasGroup(const char* aGroup) const
{
- KEntryKey groupKey(aGroup);
-
- KEntryMapConstIterator it = entryMap().find(groupKey);
- const KEntryMapConstIterator end = entryMap().end();
-
- if (it == end)
- return false;
-
- ++it;
- for (; it != end; ++it) {
- if (it.key().mKey.isEmpty())
- break;
- else if (!it.key().bDefault && !it->bDeleted)
- return true;
- }
-
- return false;
+ return entryMap().hasEntry(aGroup);
}
bool KConfig::hasKey(const char* aKey) const
{
- KEntryKey key(d->group, aKey);
- key.bDefault = readDefaults();
+ KEntryMap::SearchFlags flags=0;
+ if ( readDefaults() )
+ flags |= KEntryMap::SearchDefaults;
+ if (d->bLocaleInitialized && !locale().isEmpty())
+ flags |= KEntryMap::SearchLocalized;
- const KEntryMapConstIterator end = entryMap().end();
+ return entryMap().hasEntry(d->group, aKey, flags);
+}
- if (!locale().isNull()) { // try the localized key first
- key.bLocal = true;
- const KEntryMapConstIterator it = entryMap().find(key);
- if (it != end && !it->mValue.isNull())
- return true;
- key.bLocal = false;
- }
+bool KConfig::hasDefault(const char* aKey) const
+{
+ KEntryMap::SearchFlags flags = KEntryMap::SearchDefaults;
+ if (d->bLocaleInitialized && !locale().isEmpty())
+ flags |= KEntryMap::SearchLocalized;
- // try the non-localized version
- return entryMap().contains(key);
+ return entryMap().hasEntry(d->group, aKey, flags);
}
--- branches/work/kdelibs4_kconfig/kdecore/kconfig/kconfig.h #566422:566423
@@ -159,6 +159,7 @@
bool hasGroup(const char* aGroup) const;
bool hasKey(const char* aKey) const;
+ bool hasDefault(const char* aKey) const;
void setGroup(const char* aGroup);
QByteArray group() const;
@@ -197,6 +198,8 @@
{ return hasGroup(aGroup.toUtf8().constData()); }
inline bool hasKey(const QString& aKey) const
{ return hasKey(aKey.toUtf8().constData()); }
+ inline bool hasDefault(const QString& aKey) const
+ { return hasDefault(aKey.toUtf8().constData());}
protected:
friend class KConfigGroup;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic