aboutsummaryrefslogtreecommitdiff
path: root/src/core/kconfiggroup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/kconfiggroup.cpp')
-rw-r--r--src/core/kconfiggroup.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/kconfiggroup.cpp b/src/core/kconfiggroup.cpp
index a15c45eb..be1f2b0e 100644
--- a/src/core/kconfiggroup.cpp
+++ b/src/core/kconfiggroup.cpp
@@ -1257,3 +1257,29 @@ void KConfigGroup::reparent(KConfigBase *parent, WriteConfigFlags pFlags)
oldGroup.copyTo(this, pFlags);
oldGroup.deleteGroup(); // so that the entries with the old group name are deleted on sync
}
+
+void KConfigGroup::moveValuesTo(const QList<const char *> &keys, KConfigGroup &other, WriteConfigFlags pFlags)
+{
+ Q_ASSERT(isValid());
+ Q_ASSERT(other.isValid());
+
+ for (const auto key : keys) {
+ const QByteArray groupName = name().toLocal8Bit();
+ const auto entry = config()->d_ptr->lookupInternalEntry(groupName, key, KEntryMap::SearchLocalized);
+
+ // Only write the entry if it is not null, if it is a global enry there is no point in moving it
+ if (!entry.mValue.isNull() && !entry.bGlobal) {
+ deleteEntry(key, pFlags);
+ KEntryMap::EntryOptions options = KEntryMap::EntryOption::EntryDirty;
+ if (entry.bDeleted) {
+ options |= KEntryMap::EntryDeleted;
+ }
+
+ if (entry.bExpand) {
+ options |= KEntryMap::EntryExpansion;
+ }
+
+ other.config()->d_ptr->setEntryData(other.name().toLocal8Bit(), key, entry.mValue, options);
+ }
+ }
+}