[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdecore/config
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2008-04-21 13:35:12
Message-ID: 1208784912.141497.31012.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 799401 by aseigo:
monday's api fixes time! =)
add WriteConfigFlags to copyTo and reparent as the rest of API does. these methods \
were added post-4.0, so now is the time to fix them.
been running with this for a month now and was reviewed on k-c-d
M +20 -3 kconfig.cpp
M +2 -1 kconfig_p.h
M +5 -5 kconfiggroup.cpp
M +2 -2 kconfiggroup.h
--- trunk/KDE/kdelibs/kdecore/config/kconfig.cpp #799400:799401
@@ -115,12 +115,17 @@
}
void KConfigPrivate::copyGroup(const QByteArray& source, const QByteArray& \
destination,
- KConfigGroup *otherGroup) const
+ KConfigGroup *otherGroup, \
KConfigBase::WriteConfigFlags flags) const {
KEntryMap& otherMap = otherGroup->config()->d_ptr->entryMap;
const int len = source.length();
const bool sameName = (destination == source);
+ // we keep this bool outside the foreach loop so that if
+ // the group is empty, we don't end up marking the other config
+ // as dirty erroneously
+ bool dirtied = false;
+
foreach (const KEntryKey& key, entryMap.keys()) {
const QByteArray& group = key.mGroup;
@@ -133,14 +138,26 @@
KEntryKey newKey = key;
+ if (flags & KConfigBase::Localized) {
+ newKey.bLocal = true;
+ }
+
if (!sameName)
newKey.mGroup.replace(0, len, destination);
KEntry entry = entryMap[key];
- entry.bDirty = true;
+ dirtied = entry.bDirty = flags & KConfigBase::Persistent;
+
+ if (flags & KConfigBase::Global) {
+ entry.bGlobal = true;
+ }
+
otherMap[newKey] = entry;
}
- otherGroup->config()->d_ptr->bDirty = true;
+
+ if (dirtied) {
+ otherGroup->config()->d_ptr->bDirty = true;
+ }
}
KConfig::KConfig( const QString& file, OpenFlags mode,
--- trunk/KDE/kdelibs/kdecore/config/kconfig_p.h #799400:799401
@@ -59,7 +59,8 @@
QStringList groupList(const QByteArray& group) const;
// copies the entries from @p source to @p otherGroup changing all occurrences
// of @p source with @p destination
- void copyGroup(const QByteArray& source, const QByteArray& destination, \
KConfigGroup *otherGroup) const; + void copyGroup(const QByteArray& source, const \
QByteArray& destination, + KConfigGroup *otherGroup, \
KConfigBase::WriteConfigFlags flags) const;
protected:
KSharedPtr<KConfigBackend> mBackend;
--- trunk/KDE/kdelibs/kdecore/config/kconfiggroup.cpp #799400:799401
@@ -1288,22 +1288,22 @@
return config()->isGroupImmutable(d->fullName(b));
}
-void KConfigGroup::copyTo(KConfigBase* other) const
+void KConfigGroup::copyTo(KConfigBase* other, WriteConfigFlags pFlags) const
{
Q_ASSERT_X(isValid(), "KConfigGroup::copyTo", "accessing an invalid group");
Q_ASSERT(other != 0);
if (KConfigGroup *otherGroup = dynamic_cast<KConfigGroup*>(other)) {
- config()->d_func()->copyGroup(d->fullName(), otherGroup->d->fullName(), \
otherGroup); + config()->d_func()->copyGroup(d->fullName(), \
otherGroup->d->fullName(), otherGroup, pFlags); } else if (KConfig* otherConfig = \
dynamic_cast<KConfig*>(other)) { KConfigGroup newGroup = \
otherConfig->group(d->fullName());
- otherConfig->d_func()->copyGroup(d->fullName(), d->fullName(), &newGroup);
+ otherConfig->d_func()->copyGroup(d->fullName(), d->fullName(), &newGroup, \
pFlags); } else {
Q_ASSERT_X(false, "KConfigGroup::copyTo", "unknown type of KConfigBase");
}
}
-void KConfigGroup::reparent(KConfigBase* parent)
+void KConfigGroup::reparent(KConfigBase* parent, WriteConfigFlags pFlags)
{
Q_ASSERT_X(isValid(), "KConfigGroup::reparent", "accessing an invalid group");
Q_ASSERT_X(!d->bConst, "KConfigGroup::reparent", "reparenting a read-only \
group"); @@ -1313,6 +1313,6 @@
KConfigGroup oldGroup(*this);
d = KConfigGroupPrivate::create(parent, d->mName, false, false);
- oldGroup.copyTo(this);
+ oldGroup.copyTo(this, pFlags);
oldGroup.deleteGroup(); // so that the entries with the old group name are \
deleted on sync }
--- trunk/KDE/kdelibs/kdecore/config/kconfiggroup.h #799400:799401
@@ -135,7 +135,7 @@
*
* @since 4.1
*/
- void copyTo(KConfigBase *other) const;
+ void copyTo(KConfigBase *other, WriteConfigFlags pFlags = Normal) const;
/**
* Changes the group that this group belongs to.
@@ -145,7 +145,7 @@
*
* @since 4.1
*/
- void reparent(KConfigBase* parent);
+ void reparent(KConfigBase* parent, WriteConfigFlags pFlags = Normal);
/**
* Returns the group that this group belongs to, can be invalid if this is a \
top-level group.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic