Utils: Merge settingsutils.h into Store setup

Change-Id: I4f87400d3ff50869798a363f0d15aa77af0edf5c
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2023-09-11 15:30:07 +02:00
parent 7268f036de
commit d6dba7dc9f
16 changed files with 47 additions and 86 deletions

View File

@@ -5,6 +5,7 @@
#include "algorithm.h"
#include "qtcassert.h"
#include "qtcsettings.h"
#include <QJsonDocument>
#include <QJsonParseError>
@@ -133,4 +134,23 @@ QByteArray jsonFromStore(const Store &store)
return doc.toJson();
}
Store storeFromSettings(const Key &groupKey, QtcSettings *s)
{
Store store;
s->beginGroup(groupKey);
const KeyList keys = keysFromStrings(s->allKeys());
for (const Key &key : keys)
store.insert(key, s->value(key));
s->endGroup();
return store;
}
void storeToSettings(const Key &groupKey, QtcSettings *s, const Store &store)
{
s->beginGroup(groupKey);
for (auto it = store.constBegin(), end = store.constEnd(); it != end; ++it)
s->setValue(it.key(), it.value());
s->endGroup();
}
} // Utils