forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user