forked from qt-creator/qt-creator
Utils etc: More use of Key and Store
Change-Id: Idd2d70617f775d783aee93a2fe82544ad335a739 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -217,7 +217,7 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r)
|
|||||||
const QStringView name = r.name();
|
const QStringView name = r.name();
|
||||||
const Element e = element(name);
|
const Element e = element(name);
|
||||||
if (e == VariableElement) {
|
if (e == VariableElement) {
|
||||||
m_currentVariableName = r.readElementText();
|
m_currentVariableName = keyFromString(r.readElementText());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ParseContext::isValueElement(e))
|
if (!ParseContext::isValueElement(e))
|
||||||
@@ -225,7 +225,7 @@ bool ParseContext::handleStartElement(QXmlStreamReader &r)
|
|||||||
|
|
||||||
const QXmlStreamAttributes attributes = r.attributes();
|
const QXmlStreamAttributes attributes = r.attributes();
|
||||||
const Key key = attributes.hasAttribute(keyAttribute) ?
|
const Key key = attributes.hasAttribute(keyAttribute) ?
|
||||||
attributes.value(keyAttribute).toString() : Key();
|
keyFromString(attributes.value(keyAttribute).toString()) : Key();
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case SimpleValueElement: {
|
case SimpleValueElement: {
|
||||||
// This reads away the end element, so, handle end element right here.
|
// This reads away the end element, so, handle end element right here.
|
||||||
|
@@ -388,7 +388,7 @@ Store VersionUpgrader::renameKeys(const QList<Change> &changes, Store map) const
|
|||||||
while (i != map.end()) {
|
while (i != map.end()) {
|
||||||
QVariant v = i.value();
|
QVariant v = i.value();
|
||||||
if (v.type() == QVariant::Map)
|
if (v.type() == QVariant::Map)
|
||||||
i.value() = renameKeys(changes, v.value<Store>());
|
i.value() = QVariant::fromValue(renameKeys(changes, v.value<Store>()));
|
||||||
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -648,7 +648,7 @@ MergingSettingsAccessor::mergeSettings(const SettingsAccessor::RestoreData &main
|
|||||||
/*!
|
/*!
|
||||||
* Returns true for housekeeping related keys.
|
* Returns true for housekeeping related keys.
|
||||||
*/
|
*/
|
||||||
bool MergingSettingsAccessor::isHouseKeepingKey(const QString &key)
|
bool MergingSettingsAccessor::isHouseKeepingKey(const Key &key)
|
||||||
{
|
{
|
||||||
return key == VERSION_KEY || key == ORIGINAL_VERSION_KEY || key == SETTINGS_ID_KEY;
|
return key == VERSION_KEY || key == ORIGINAL_VERSION_KEY || key == SETTINGS_ID_KEY;
|
||||||
}
|
}
|
||||||
@@ -697,7 +697,7 @@ void setSettingsIdInMap(Store &data, const QByteArray &id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static QVariant mergeQVariantMapsRecursion(const Store &mainTree, const Store &secondaryTree,
|
static QVariant mergeQVariantMapsRecursion(const Store &mainTree, const Store &secondaryTree,
|
||||||
const QString &keyPrefix,
|
const Key &keyPrefix,
|
||||||
const Store &mainSubtree, const Store &secondarySubtree,
|
const Store &mainSubtree, const Store &secondarySubtree,
|
||||||
const SettingsMergeFunction &merge)
|
const SettingsMergeFunction &merge)
|
||||||
{
|
{
|
||||||
@@ -718,10 +718,11 @@ static QVariant mergeQVariantMapsRecursion(const Store &mainTree, const Store &s
|
|||||||
QPair<Key, QVariant> kv = mergeResult.value();
|
QPair<Key, QVariant> kv = mergeResult.value();
|
||||||
|
|
||||||
if (kv.second.type() == QVariant::Map) {
|
if (kv.second.type() == QVariant::Map) {
|
||||||
const QString newKeyPrefix = keyPrefix + kv.first + '/';
|
const Key newKeyPrefix = keyPrefix + kv.first + '/';
|
||||||
kv.second = mergeQVariantMapsRecursion(mainTree, secondaryTree, newKeyPrefix,
|
kv.second = mergeQVariantMapsRecursion(mainTree, secondaryTree, newKeyPrefix,
|
||||||
kv.second.toMap(), secondarySubtree.value(kv.first)
|
kv.second.value<Store>(),
|
||||||
.toMap(), merge);
|
secondarySubtree.value(kv.first).value<Store>(),
|
||||||
|
merge);
|
||||||
}
|
}
|
||||||
if (!kv.second.isNull())
|
if (!kv.second.isNull())
|
||||||
result.insert(kv.first, kv.second);
|
result.insert(kv.first, kv.second);
|
||||||
@@ -733,7 +734,7 @@ static QVariant mergeQVariantMapsRecursion(const Store &mainTree, const Store &s
|
|||||||
QVariant mergeQVariantMaps(const Store &mainTree, const Store &secondaryTree,
|
QVariant mergeQVariantMaps(const Store &mainTree, const Store &secondaryTree,
|
||||||
const SettingsMergeFunction &merge)
|
const SettingsMergeFunction &merge)
|
||||||
{
|
{
|
||||||
return mergeQVariantMapsRecursion(mainTree, secondaryTree, QString(),
|
return mergeQVariantMapsRecursion(mainTree, secondaryTree, Key(),
|
||||||
mainTree, secondaryTree, merge);
|
mainTree, secondaryTree, merge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ QTCREATOR_UTILS_EXPORT void setOriginalVersionInMap(Store &data, int version);
|
|||||||
QTCREATOR_UTILS_EXPORT void setSettingsIdInMap(Store &data, const QByteArray &id);
|
QTCREATOR_UTILS_EXPORT void setSettingsIdInMap(Store &data, const QByteArray &id);
|
||||||
|
|
||||||
class PersistentSettingsWriter;
|
class PersistentSettingsWriter;
|
||||||
using SettingsMergeResult = std::optional<QPair<QString, QVariant>>;
|
using SettingsMergeResult = std::optional<QPair<Utils::Key, QVariant>>;
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
// SettingsAccessor:
|
// SettingsAccessor:
|
||||||
@@ -206,7 +206,7 @@ public:
|
|||||||
virtual Store upgrade(const Store &data) = 0;
|
virtual Store upgrade(const Store &data) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using Change = QPair<QLatin1String, QLatin1String>;
|
using Change = QPair<Key, Key>;
|
||||||
Store renameKeys(const QList<Change> &changes, Store map) const;
|
Store renameKeys(const QList<Change> &changes, Store map) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -271,7 +271,7 @@ protected:
|
|||||||
|
|
||||||
virtual SettingsMergeResult merge(const SettingsMergeData &global,
|
virtual SettingsMergeResult merge(const SettingsMergeData &global,
|
||||||
const SettingsMergeData &local) const = 0;
|
const SettingsMergeData &local) const = 0;
|
||||||
static bool isHouseKeepingKey(const QString &key);
|
static bool isHouseKeepingKey(const Key &key);
|
||||||
|
|
||||||
virtual Store postprocessMerge(const Store &main, const Store &secondary,
|
virtual Store postprocessMerge(const Store &main, const Store &secondary,
|
||||||
const Store &result) const;
|
const Store &result) const;
|
||||||
|
@@ -19,7 +19,7 @@ void fromSettings(const Key &postFix,
|
|||||||
{
|
{
|
||||||
Store map;
|
Store map;
|
||||||
s->beginGroup(category + postFix);
|
s->beginGroup(category + postFix);
|
||||||
const KeyList keys = s->allKeys();
|
const KeyList keys = keyListFromStringList(s->allKeys());
|
||||||
for (const Key &key : keys)
|
for (const Key &key : keys)
|
||||||
map.insert(key, s->value(key));
|
map.insert(key, s->value(key));
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
|
@@ -3,7 +3,17 @@
|
|||||||
|
|
||||||
#include "store.h"
|
#include "store.h"
|
||||||
|
|
||||||
|
#include "algorithm.h"
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
|
KeyList keyListFromStringList(const QStringList &list)
|
||||||
|
{
|
||||||
|
#ifdef QTC_USE_STORE
|
||||||
|
return transform(list, [](const QString &str) { return str.toUtf8(); });
|
||||||
|
#else
|
||||||
|
return list;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -11,6 +11,13 @@
|
|||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
using KeyList = QList<Key>;
|
using KeyList = QList<Key>;
|
||||||
|
|
||||||
|
#ifdef QTC_USE_STORE
|
||||||
using Store = QMap<Key, QVariant>;
|
using Store = QMap<Key, QVariant>;
|
||||||
|
#else
|
||||||
|
using Store = QVariantMap;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QTCREATOR_UTILS_EXPORT KeyList keyListFromStringList(const QStringList &list);
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -3,10 +3,27 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "utils_global.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
|
|
||||||
|
// Opt-in to new classes during the transition phase.
|
||||||
|
// #define QTC_USE_STORE
|
||||||
|
|
||||||
|
#ifdef QTC_USE_STORE
|
||||||
|
|
||||||
|
using Key = QByteArray;
|
||||||
|
|
||||||
|
inline Key keyFromString(const QString &str) { return str.toUtf8(); }
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
using Key = QString;
|
using Key = QString;
|
||||||
|
|
||||||
|
inline Key keyFromString(const QString &str) { return str; }
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
@@ -156,7 +156,7 @@ bool SessionManager::isDefaultSession(const QString &session)
|
|||||||
void SessionManager::saveActiveMode(Id mode)
|
void SessionManager::saveActiveMode(Id mode)
|
||||||
{
|
{
|
||||||
if (mode != Core::Constants::MODE_WELCOME)
|
if (mode != Core::Constants::MODE_WELCOME)
|
||||||
setValue(QLatin1String("ActiveMode"), mode.toString());
|
setValue("ActiveMode", mode.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SessionManager::isLoadingSession()
|
bool SessionManager::isLoadingSession()
|
||||||
@@ -169,25 +169,25 @@ bool SessionManager::isLoadingSession()
|
|||||||
within the session file.
|
within the session file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void SessionManager::setValue(const QString &name, const QVariant &value)
|
void SessionManager::setValue(const Key &name, const QVariant &value)
|
||||||
{
|
{
|
||||||
if (sb_d->m_values.value(name) == value)
|
if (sb_d->m_values.value(name) == value)
|
||||||
return;
|
return;
|
||||||
sb_d->m_values.insert(name, value);
|
sb_d->m_values.insert(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SessionManager::value(const QString &name)
|
QVariant SessionManager::value(const Key &name)
|
||||||
{
|
{
|
||||||
auto it = sb_d->m_values.constFind(name);
|
auto it = sb_d->m_values.constFind(name);
|
||||||
return (it == sb_d->m_values.constEnd()) ? QVariant() : *it;
|
return (it == sb_d->m_values.constEnd()) ? QVariant() : *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManager::setSessionValue(const QString &name, const QVariant &value)
|
void SessionManager::setSessionValue(const Key &name, const QVariant &value)
|
||||||
{
|
{
|
||||||
sb_d->m_sessionValues.insert(name, value);
|
sb_d->m_sessionValues.insert(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant SessionManager::sessionValue(const QString &name, const QVariant &defaultValue)
|
QVariant SessionManager::sessionValue(const Key &name, const QVariant &defaultValue)
|
||||||
{
|
{
|
||||||
auto it = sb_d->m_sessionValues.constFind(name);
|
auto it = sb_d->m_sessionValues.constFind(name);
|
||||||
return (it == sb_d->m_sessionValues.constEnd()) ? defaultValue : *it;
|
return (it == sb_d->m_sessionValues.constEnd()) ? defaultValue : *it;
|
||||||
@@ -488,16 +488,16 @@ void SessionManagerPrivate::updateSessionMenu()
|
|||||||
|
|
||||||
void SessionManagerPrivate::restoreValues(const PersistentSettingsReader &reader)
|
void SessionManagerPrivate::restoreValues(const PersistentSettingsReader &reader)
|
||||||
{
|
{
|
||||||
const QStringList keys = reader.restoreValue(QLatin1String("valueKeys")).toStringList();
|
const KeyList keys = keyListFromStringList(reader.restoreValue("valueKeys").toStringList());
|
||||||
for (const QString &key : keys) {
|
for (const Key &key : keys) {
|
||||||
QVariant value = reader.restoreValue(QLatin1String("value-") + key);
|
QVariant value = reader.restoreValue("value-" + key);
|
||||||
m_values.insert(key, value);
|
m_values.insert(key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionManagerPrivate::restoreSessionValues(const PersistentSettingsReader &reader)
|
void SessionManagerPrivate::restoreSessionValues(const PersistentSettingsReader &reader)
|
||||||
{
|
{
|
||||||
const QVariantMap values = reader.restoreValues();
|
const Store values = reader.restoreValues();
|
||||||
// restore toplevel items that are not restored by restoreValues
|
// restore toplevel items that are not restored by restoreValues
|
||||||
const auto end = values.constEnd();
|
const auto end = values.constEnd();
|
||||||
for (auto it = values.constBegin(); it != end; ++it) {
|
for (auto it = values.constBegin(); it != end; ++it) {
|
||||||
@@ -680,7 +680,7 @@ bool SessionManager::saveSession()
|
|||||||
emit SessionManager::instance()->aboutToSaveSession();
|
emit SessionManager::instance()->aboutToSaveSession();
|
||||||
|
|
||||||
const FilePath filePath = SessionManager::sessionNameToFileName(sb_d->m_sessionName);
|
const FilePath filePath = SessionManager::sessionNameToFileName(sb_d->m_sessionName);
|
||||||
QVariantMap data;
|
Store data;
|
||||||
|
|
||||||
// See the explanation at loadSession() for how we handle the implicit default session.
|
// See the explanation at loadSession() for how we handle the implicit default session.
|
||||||
if (SessionManager::isDefaultVirgin()) {
|
if (SessionManager::isDefaultVirgin()) {
|
||||||
@@ -712,12 +712,12 @@ bool SessionManager::saveSession()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto end = sb_d->m_values.constEnd();
|
const auto end = sb_d->m_values.constEnd();
|
||||||
QStringList keys;
|
KeyList keys;
|
||||||
for (auto it = sb_d->m_values.constBegin(); it != end; ++it) {
|
for (auto it = sb_d->m_values.constBegin(); it != end; ++it) {
|
||||||
data.insert("value-" + it.key(), it.value());
|
data.insert("value-" + it.key(), it.value());
|
||||||
keys << it.key();
|
keys << it.key();
|
||||||
}
|
}
|
||||||
data.insert("valueKeys", keys);
|
data.insert("valueKeys", QVariant::fromValue(keys));
|
||||||
|
|
||||||
if (!sb_d->m_writer || sb_d->m_writer->fileName() != filePath) {
|
if (!sb_d->m_writer || sb_d->m_writer->fileName() != filePath) {
|
||||||
delete sb_d->m_writer;
|
delete sb_d->m_writer;
|
||||||
|
@@ -50,13 +50,13 @@ public:
|
|||||||
// Let other plugins store persistent values within the session file
|
// Let other plugins store persistent values within the session file
|
||||||
// These are settings that are also saved and loaded at startup, and are taken over
|
// These are settings that are also saved and loaded at startup, and are taken over
|
||||||
// to the default session when switching from implicit to explicit default session
|
// to the default session when switching from implicit to explicit default session
|
||||||
static void setValue(const QString &name, const QVariant &value);
|
static void setValue(const Utils::Key &name, const QVariant &value);
|
||||||
static QVariant value(const QString &name);
|
static QVariant value(const Utils::Key &name);
|
||||||
|
|
||||||
// These are settings that are specific to a session and are not loaded
|
// These are settings that are specific to a session and are not loaded
|
||||||
// at startup and also not taken over to the default session when switching from implicit
|
// at startup and also not taken over to the default session when switching from implicit
|
||||||
static void setSessionValue(const QString &name, const QVariant &value);
|
static void setSessionValue(const Utils::Key &name, const QVariant &value);
|
||||||
static QVariant sessionValue(const QString &name, const QVariant &defaultValue = {});
|
static QVariant sessionValue(const Utils::Key &name, const QVariant &defaultValue = {});
|
||||||
|
|
||||||
static bool isLoadingSession();
|
static bool isLoadingSession();
|
||||||
static void markSessionFileDirty();
|
static void markSessionFileDirty();
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include <utils/persistentsettings.h>
|
#include <utils/persistentsettings.h>
|
||||||
|
#include <utils/store.h>
|
||||||
|
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
|
|
||||||
@@ -43,8 +44,8 @@ public:
|
|||||||
mutable QHash<QString, QDateTime> m_sessionDateTimes;
|
mutable QHash<QString, QDateTime> m_sessionDateTimes;
|
||||||
QHash<QString, QDateTime> m_lastActiveTimes;
|
QHash<QString, QDateTime> m_lastActiveTimes;
|
||||||
|
|
||||||
QMap<QString, QVariant> m_values;
|
QMap<Utils::Key, QVariant> m_values;
|
||||||
QMap<QString, QVariant> m_sessionValues;
|
QMap<Utils::Key, QVariant> m_sessionValues;
|
||||||
QFutureInterface<void> m_future;
|
QFutureInterface<void> m_future;
|
||||||
PersistentSettingsWriter *m_writer = nullptr;
|
PersistentSettingsWriter *m_writer = nullptr;
|
||||||
|
|
||||||
|
@@ -265,7 +265,7 @@ QString FakeVimSettings::trySetValue(const QString &name, const QString &value)
|
|||||||
|
|
||||||
void FakeVimSettings::setup(FvBaseAspect *aspect,
|
void FakeVimSettings::setup(FvBaseAspect *aspect,
|
||||||
const QVariant &value,
|
const QVariant &value,
|
||||||
const QString &settingsKey,
|
const Key &settingsKey,
|
||||||
const QString &shortName,
|
const QString &shortName,
|
||||||
const QString &labelText)
|
const QString &labelText)
|
||||||
{
|
{
|
||||||
@@ -282,7 +282,7 @@ void FakeVimSettings::setup(FvBaseAspect *aspect,
|
|||||||
Q_UNUSED(labelText)
|
Q_UNUSED(labelText)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const QString longName = settingsKey.toLower();
|
const Key longName = settingsKey.toLower();
|
||||||
if (!longName.isEmpty()) {
|
if (!longName.isEmpty()) {
|
||||||
m_nameToAspect[longName] = aspect;
|
m_nameToAspect[longName] = aspect;
|
||||||
m_aspectToName[aspect] = longName;
|
m_aspectToName[aspect] = longName;
|
||||||
|
@@ -3,13 +3,15 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef FAKEVIM_STANDALONE
|
#ifdef FAKEVIM_STANDALONE
|
||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <utils/store.h>
|
||||||
|
|
||||||
|
namespace Utils { class FilePath {}; }
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
namespace Utils { class FilePath {}; }
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -32,8 +34,11 @@ public:
|
|||||||
virtual void setDefaultVariantValue(const QVariant &) {}
|
virtual void setDefaultVariantValue(const QVariant &) {}
|
||||||
virtual QVariant variantValue() const { return {}; }
|
virtual QVariant variantValue() const { return {}; }
|
||||||
virtual QVariant defaultVariantValue() const { return {}; }
|
virtual QVariant defaultVariantValue() const { return {}; }
|
||||||
|
#ifdef QTC_USE_STORE
|
||||||
|
void setSettingsKey(const QString &group, const QByteArray &key);
|
||||||
|
#else
|
||||||
void setSettingsKey(const QString &group, const QString &key);
|
void setSettingsKey(const QString &group, const QString &key);
|
||||||
|
#endif
|
||||||
QString settingsKey() const;
|
QString settingsKey() const;
|
||||||
void setCheckable(bool) {}
|
void setCheckable(bool) {}
|
||||||
void setDisplayName(const QString &) {}
|
void setDisplayName(const QString &) {}
|
||||||
@@ -155,12 +160,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void setup(FvBaseAspect *aspect, const QVariant &value,
|
void setup(FvBaseAspect *aspect, const QVariant &value,
|
||||||
const QString &settingsKey,
|
const Utils::Key &settingsKey,
|
||||||
const QString &shortName,
|
const QString &shortName,
|
||||||
const QString &label);
|
const QString &label);
|
||||||
|
|
||||||
QHash<QString, FvBaseAspect *> m_nameToAspect;
|
QHash<Utils::Key, FvBaseAspect *> m_nameToAspect;
|
||||||
QHash<FvBaseAspect *, QString> m_aspectToName;
|
QHash<FvBaseAspect *, Utils::Key> m_aspectToName;
|
||||||
};
|
};
|
||||||
|
|
||||||
FakeVimSettings &settings();
|
FakeVimSettings &settings();
|
||||||
|
@@ -72,7 +72,7 @@ BuildDirectoryAspect::~BuildDirectoryAspect()
|
|||||||
void BuildDirectoryAspect::allowInSourceBuilds(const FilePath &sourceDir)
|
void BuildDirectoryAspect::allowInSourceBuilds(const FilePath &sourceDir)
|
||||||
{
|
{
|
||||||
d->sourceDir = sourceDir;
|
d->sourceDir = sourceDir;
|
||||||
makeCheckable(CheckBoxPlacement::Top, Tr::tr("Shadow build:"), QString());
|
makeCheckable(CheckBoxPlacement::Top, Tr::tr("Shadow build:"), Key());
|
||||||
setChecked(d->sourceDir != expandedValue());
|
setChecked(d->sourceDir != expandedValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,17 +52,17 @@ Store BuildStepList::toMap() const
|
|||||||
const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
const char CONFIGURATION_ID_KEY[] = "ProjectExplorer.ProjectConfiguration.Id";
|
||||||
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
const char DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DisplayName";
|
||||||
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
|
const char DEFAULT_DISPLAY_NAME_KEY[] = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName";
|
||||||
map.insert(QLatin1String(CONFIGURATION_ID_KEY), m_id.toSetting());
|
map.insert(CONFIGURATION_ID_KEY, m_id.toSetting());
|
||||||
map.insert(QLatin1String(DISPLAY_NAME_KEY), displayName());
|
map.insert(DISPLAY_NAME_KEY, displayName());
|
||||||
map.insert(QLatin1String(DEFAULT_DISPLAY_NAME_KEY), displayName());
|
map.insert(DEFAULT_DISPLAY_NAME_KEY, displayName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save build steps
|
// Save build steps
|
||||||
map.insert(QString::fromLatin1(STEPS_COUNT_KEY), m_steps.count());
|
map.insert(STEPS_COUNT_KEY, m_steps.count());
|
||||||
for (int i = 0; i < m_steps.count(); ++i) {
|
for (int i = 0; i < m_steps.count(); ++i) {
|
||||||
Store data;
|
Store data;
|
||||||
m_steps.at(i)->toMap(data);
|
m_steps.at(i)->toMap(data);
|
||||||
map.insert(QString::fromLatin1(STEPS_PREFIX) + QString::number(i), data);
|
map.insert(STEPS_PREFIX + Key::number(i), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
@@ -109,9 +109,9 @@ bool BuildStepList::fromMap(const Store &map)
|
|||||||
|
|
||||||
const QList<BuildStepFactory *> factories = BuildStepFactory::allBuildStepFactories();
|
const QList<BuildStepFactory *> factories = BuildStepFactory::allBuildStepFactories();
|
||||||
|
|
||||||
int maxSteps = map.value(QString::fromLatin1(STEPS_COUNT_KEY), 0).toInt();
|
int maxSteps = map.value(STEPS_COUNT_KEY, 0).toInt();
|
||||||
for (int i = 0; i < maxSteps; ++i) {
|
for (int i = 0; i < maxSteps; ++i) {
|
||||||
Store bsData(map.value(QString::fromLatin1(STEPS_PREFIX) + QString::number(i)).toMap());
|
Store bsData(map.value(STEPS_PREFIX + Key::number(i)).toMap());
|
||||||
if (bsData.isEmpty()) {
|
if (bsData.isEmpty()) {
|
||||||
qWarning() << "No step data found for" << i << "(continuing).";
|
qWarning() << "No step data found for" << i << "(continuing).";
|
||||||
continue;
|
continue;
|
||||||
|
@@ -225,7 +225,7 @@ QWidget *CustomWizardFieldPage::registerPathChooser(const QString &fieldName,
|
|||||||
pathChooser->setExpectedKind(PathChooser::Command);
|
pathChooser->setExpectedKind(PathChooser::Command);
|
||||||
else if (expectedKind == QLatin1String("any"))
|
else if (expectedKind == QLatin1String("any"))
|
||||||
pathChooser->setExpectedKind(PathChooser::Any);
|
pathChooser->setExpectedKind(PathChooser::Any);
|
||||||
pathChooser->setHistoryCompleter(QString::fromLatin1("PE.Custom.") + m_parameters->id.toString() + QLatin1Char('.') + field.name);
|
pathChooser->setHistoryCompleter("PE.Custom." + m_parameters->id.name() + '.' + field.name);
|
||||||
|
|
||||||
registerField(fieldName, pathChooser, "path", SIGNAL(rawPathChanged(QString)));
|
registerField(fieldName, pathChooser, "path", SIGNAL(rawPathChanged(QString)));
|
||||||
// Connect to completeChanged() for derived classes that reimplement isComplete()
|
// Connect to completeChanged() for derived classes that reimplement isComplete()
|
||||||
@@ -407,7 +407,7 @@ CustomWizardPage::CustomWizardPage(const QSharedPointer<CustomWizardContext> &ct
|
|||||||
CustomWizardFieldPage(ctx, parameters, parent),
|
CustomWizardFieldPage(ctx, parameters, parent),
|
||||||
m_pathChooser(new PathChooser)
|
m_pathChooser(new PathChooser)
|
||||||
{
|
{
|
||||||
m_pathChooser->setHistoryCompleter(QLatin1String("PE.ProjectDir.History"));
|
m_pathChooser->setHistoryCompleter("PE.ProjectDir.History");
|
||||||
addRow(Tr::tr("Path:"), m_pathChooser);
|
addRow(Tr::tr("Path:"), m_pathChooser);
|
||||||
connect(m_pathChooser, &PathChooser::validChanged, this, &QWizardPage::completeChanged);
|
connect(m_pathChooser, &PathChooser::validChanged, this, &QWizardPage::completeChanged);
|
||||||
}
|
}
|
||||||
|
@@ -33,6 +33,8 @@
|
|||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace SerialTerminal {
|
namespace SerialTerminal {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -277,7 +279,7 @@ void SerialOutputPane::createNewOutputWindow(SerialControl *rc)
|
|||||||
static int counter = 0;
|
static int counter = 0;
|
||||||
Utils::Id contextId = Utils::Id(Constants::C_SERIAL_OUTPUT).withSuffix(counter++);
|
Utils::Id contextId = Utils::Id(Constants::C_SERIAL_OUTPUT).withSuffix(counter++);
|
||||||
Core::Context context(contextId);
|
Core::Context context(contextId);
|
||||||
auto ow = new Core::OutputWindow(context, QString(), m_tabWidget);
|
auto ow = new Core::OutputWindow(context, Key(), m_tabWidget);
|
||||||
using TextEditor::TextEditorSettings;
|
using TextEditor::TextEditorSettings;
|
||||||
auto fontSettingsChanged = [ow] {
|
auto fontSettingsChanged = [ow] {
|
||||||
ow->setBaseFont(TextEditorSettings::fontSettings().font());
|
ow->setBaseFont(TextEditorSettings::fontSettings().font());
|
||||||
|
@@ -204,10 +204,10 @@ ICodeStylePreferences *CodeStylePool::loadCodeStyle(const FilePath &fileName)
|
|||||||
ICodeStylePreferences *codeStyle = nullptr;
|
ICodeStylePreferences *codeStyle = nullptr;
|
||||||
PersistentSettingsReader reader;
|
PersistentSettingsReader reader;
|
||||||
reader.load(fileName);
|
reader.load(fileName);
|
||||||
QVariantMap m = reader.restoreValues();
|
Store m = reader.restoreValues();
|
||||||
if (m.contains(QLatin1String(codeStyleDataKey))) {
|
if (m.contains(codeStyleDataKey)) {
|
||||||
const QByteArray id = fileName.completeBaseName().toUtf8();
|
const QByteArray id = fileName.completeBaseName().toUtf8();
|
||||||
const QString displayName = reader.restoreValue(QLatin1String(displayNameKey)).toString();
|
const QString displayName = reader.restoreValue(displayNameKey).toString();
|
||||||
const Store map = reader.restoreValue(codeStyleDataKey).value<Store>();
|
const Store map = reader.restoreValue(codeStyleDataKey).value<Store>();
|
||||||
if (d->m_factory) {
|
if (d->m_factory) {
|
||||||
codeStyle = d->m_factory->createCodeStyle();
|
codeStyle = d->m_factory->createCodeStyle();
|
||||||
|
@@ -19,9 +19,9 @@ private slots:
|
|||||||
void tst_readwrite();
|
void tst_readwrite();
|
||||||
};
|
};
|
||||||
|
|
||||||
static const QVariantMap generateData()
|
static const Store generateData()
|
||||||
{
|
{
|
||||||
QVariantMap result;
|
Store result;
|
||||||
QByteArray barr("I am a byte array.");
|
QByteArray barr("I am a byte array.");
|
||||||
QString str("I am a string.");
|
QString str("I am a string.");
|
||||||
QColor color("#8b00d1");
|
QColor color("#8b00d1");
|
||||||
@@ -44,7 +44,7 @@ void PersistentSettingsTest::tst_readwrite()
|
|||||||
qDebug() << "using" << fi.absoluteFilePath();
|
qDebug() << "using" << fi.absoluteFilePath();
|
||||||
const FilePath filePath = FilePath::fromFileInfo(fi);
|
const FilePath filePath = FilePath::fromFileInfo(fi);
|
||||||
PersistentSettingsWriter writer(filePath, "Narf");
|
PersistentSettingsWriter writer(filePath, "Narf");
|
||||||
const QVariantMap originalData = generateData();
|
const Store originalData = generateData();
|
||||||
QString error;
|
QString error;
|
||||||
bool success = writer.save(originalData, &error);
|
bool success = writer.save(originalData, &error);
|
||||||
QVERIFY2(success, error.toLocal8Bit());
|
QVERIFY2(success, error.toLocal8Bit());
|
||||||
@@ -54,7 +54,7 @@ void PersistentSettingsTest::tst_readwrite()
|
|||||||
success = reader.load(filePath);
|
success = reader.load(filePath);
|
||||||
QVERIFY(success);
|
QVERIFY(success);
|
||||||
|
|
||||||
const QVariantMap restored = reader.restoreValues();
|
const Store restored = reader.restoreValues();
|
||||||
QCOMPARE(restored.size(), originalData.size());
|
QCOMPARE(restored.size(), originalData.size());
|
||||||
auto restoredEnd = restored.end();
|
auto restoredEnd = restored.end();
|
||||||
for (auto it = originalData.cbegin(), end = originalData.cend(); it != end; ++it) {
|
for (auto it = originalData.cbegin(), end = originalData.cend(); it != end; ++it) {
|
||||||
|
@@ -13,9 +13,9 @@ using namespace Utils;
|
|||||||
const char TESTACCESSOR_APPLICATION_DN[] = "SettingsAccessor Test (Basic)";
|
const char TESTACCESSOR_APPLICATION_DN[] = "SettingsAccessor Test (Basic)";
|
||||||
const char TESTACCESSOR_DEFAULT_ID[] = "testId";
|
const char TESTACCESSOR_DEFAULT_ID[] = "testId";
|
||||||
|
|
||||||
QVariantMap generateExtraData()
|
Store generateExtraData()
|
||||||
{
|
{
|
||||||
QVariantMap extra;
|
Store extra;
|
||||||
extra.insert("Foo", "Bar");
|
extra.insert("Foo", "Bar");
|
||||||
extra.insert("Int", 42);
|
extra.insert("Int", 42);
|
||||||
return extra;
|
return extra;
|
||||||
@@ -28,14 +28,14 @@ QVariantMap generateExtraData()
|
|||||||
class TestVersionUpgrader : public Utils::VersionUpgrader
|
class TestVersionUpgrader : public Utils::VersionUpgrader
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestVersionUpgrader(int version) :
|
TestVersionUpgrader(int version)
|
||||||
Utils::VersionUpgrader(version, QString("v") + QString::number(version))
|
: VersionUpgrader(version, "v" + QString::number(version))
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QVariantMap upgrade(const QVariantMap &data) final
|
Store upgrade(const Store &data) final
|
||||||
{
|
{
|
||||||
QVariantMap result = data;
|
Store result = data;
|
||||||
result.insert(QString("VERSION_") + QString::number(version()), version());
|
result.insert("VERSION_" + Key::number(version()), version());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -52,10 +52,10 @@ public:
|
|||||||
|
|
||||||
using Utils::MergingSettingsAccessor::addVersionUpgrader;
|
using Utils::MergingSettingsAccessor::addVersionUpgrader;
|
||||||
|
|
||||||
QHash<Utils::FilePath, QVariantMap> files() const { return m_files; }
|
QHash<Utils::FilePath, Store> files() const { return m_files; }
|
||||||
void addFile(const Utils::FilePath &path, const QVariantMap &data) const { m_files.insert(path, data); }
|
void addFile(const Utils::FilePath &path, const Store &data) const { m_files.insert(path, data); }
|
||||||
Utils::FilePaths fileNames() const { return m_files.keys(); }
|
Utils::FilePaths fileNames() const { return m_files.keys(); }
|
||||||
QVariantMap fileContents(const Utils::FilePath &path) const { return m_files.value(path); }
|
Store fileContents(const Utils::FilePath &path) const { return m_files.value(path); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RestoreData readFile(const Utils::FilePath &path) const override
|
RestoreData readFile(const Utils::FilePath &path) const override
|
||||||
@@ -71,7 +71,7 @@ protected:
|
|||||||
{
|
{
|
||||||
Q_UNUSED(global)
|
Q_UNUSED(global)
|
||||||
|
|
||||||
const QString key = local.key;
|
const Key key = local.key;
|
||||||
const QVariant main = local.main.value(key);
|
const QVariant main = local.main.value(key);
|
||||||
const QVariant secondary = local.secondary.value(key);
|
const QVariant secondary = local.secondary.value(key);
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ protected:
|
|||||||
return qMakePair(key, secondary);
|
return qMakePair(key, secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Issue> writeFile(const Utils::FilePath &path, const QVariantMap &data) const override
|
std::optional<Issue> writeFile(const Utils::FilePath &path, const Store &data) const override
|
||||||
{
|
{
|
||||||
if (data.isEmpty()) {
|
if (data.isEmpty()) {
|
||||||
return Issue("Failed to Write File", "There was nothing to write.",
|
return Issue("Failed to Write File", "There was nothing to write.",
|
||||||
@@ -97,7 +97,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QHash<Utils::FilePath, QVariantMap> m_files;
|
mutable QHash<Utils::FilePath, Store> m_files;
|
||||||
};
|
};
|
||||||
|
|
||||||
// --------------------------------------------------------------------
|
// --------------------------------------------------------------------
|
||||||
@@ -200,10 +200,9 @@ private slots:
|
|||||||
void loadSettings_pickBest();
|
void loadSettings_pickBest();
|
||||||
};
|
};
|
||||||
|
|
||||||
static QVariantMap versionedMap(int version, const QByteArray &id = QByteArray(),
|
static Store versionedMap(int version, const QByteArray &id = {}, const Store &extra = {})
|
||||||
const QVariantMap &extra = QVariantMap())
|
|
||||||
{
|
{
|
||||||
QVariantMap result;
|
Store result;
|
||||||
result.insert("Version", version);
|
result.insert("Version", version);
|
||||||
if (!id.isEmpty())
|
if (!id.isEmpty())
|
||||||
result.insert("EnvironmentId", id);
|
result.insert("EnvironmentId", id);
|
||||||
@@ -213,13 +212,13 @@ static QVariantMap versionedMap(int version, const QByteArray &id = QByteArray()
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Utils::SettingsAccessor::RestoreData restoreData(const Utils::FilePath &path,
|
static Utils::SettingsAccessor::RestoreData restoreData(const Utils::FilePath &path,
|
||||||
const QVariantMap &data)
|
const Store &data)
|
||||||
{
|
{
|
||||||
return Utils::SettingsAccessor::RestoreData(path, data);
|
return Utils::SettingsAccessor::RestoreData(path, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static Utils::SettingsAccessor::RestoreData restoreData(const QByteArray &path,
|
//static Utils::SettingsAccessor::RestoreData restoreData(const QByteArray &path,
|
||||||
// const QVariantMap &data)
|
// const Store &data)
|
||||||
//{
|
//{
|
||||||
// return restoreData(Utils::FilePath::fromUtf8(path), data);
|
// return restoreData(Utils::FilePath::fromUtf8(path), data);
|
||||||
//}
|
//}
|
||||||
@@ -366,7 +365,7 @@ void tst_SettingsAccessor::RestoreDataCompare_emptyMap()
|
|||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
|
|
||||||
Utils::SettingsAccessor::RestoreData a = restoreData("/foo/bar", QVariantMap());
|
Utils::SettingsAccessor::RestoreData a = restoreData("/foo/bar", Store());
|
||||||
Utils::SettingsAccessor::RestoreData b = restoreData("/foo/baz", versionedMap(7, TESTACCESSOR_DEFAULT_ID));
|
Utils::SettingsAccessor::RestoreData b = restoreData("/foo/baz", versionedMap(7, TESTACCESSOR_DEFAULT_ID));
|
||||||
|
|
||||||
QCOMPARE(accessor.strategy()->compare(a, b), 1);
|
QCOMPARE(accessor.strategy()->compare(a, b), 1);
|
||||||
@@ -377,8 +376,8 @@ void tst_SettingsAccessor::RestoreDataCompare_twoEmptyMaps()
|
|||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
|
|
||||||
Utils::SettingsAccessor::RestoreData a = restoreData("/foo/bar", QVariantMap());
|
Utils::SettingsAccessor::RestoreData a = restoreData("/foo/bar", Store());
|
||||||
Utils::SettingsAccessor::RestoreData b = restoreData("/foo/baz", QVariantMap());
|
Utils::SettingsAccessor::RestoreData b = restoreData("/foo/baz", Store());
|
||||||
|
|
||||||
QCOMPARE(accessor.strategy()->compare(a, b), 0);
|
QCOMPARE(accessor.strategy()->compare(a, b), 0);
|
||||||
QCOMPARE(accessor.strategy()->compare(b, a), 0);
|
QCOMPARE(accessor.strategy()->compare(b, a), 0);
|
||||||
@@ -544,7 +543,7 @@ void tst_SettingsAccessor::upgradeSettings_partialUpdate()
|
|||||||
void tst_SettingsAccessor::upgradeSettings_targetVersionTooOld()
|
void tst_SettingsAccessor::upgradeSettings_targetVersionTooOld()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap extra = generateExtraData();
|
const Store extra = generateExtraData();
|
||||||
const int startVersion = 6;
|
const int startVersion = 6;
|
||||||
const Utils::SettingsAccessor::RestoreData input
|
const Utils::SettingsAccessor::RestoreData input
|
||||||
= restoreData(accessor.baseFilePath(),
|
= restoreData(accessor.baseFilePath(),
|
||||||
@@ -560,7 +559,7 @@ void tst_SettingsAccessor::upgradeSettings_targetVersionTooOld()
|
|||||||
void tst_SettingsAccessor::upgradeSettings_targetVersionTooNew()
|
void tst_SettingsAccessor::upgradeSettings_targetVersionTooNew()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap extra = generateExtraData();
|
const Store extra = generateExtraData();
|
||||||
const int startVersion = 6;
|
const int startVersion = 6;
|
||||||
const Utils::SettingsAccessor::RestoreData input
|
const Utils::SettingsAccessor::RestoreData input
|
||||||
= restoreData(accessor.baseFilePath(),
|
= restoreData(accessor.baseFilePath(),
|
||||||
@@ -578,7 +577,7 @@ void tst_SettingsAccessor::upgradeSettings_targetVersionTooNew()
|
|||||||
void tst_SettingsAccessor::findIssues_ok()
|
void tst_SettingsAccessor::findIssues_ok()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap data = versionedMap(6, TESTACCESSOR_DEFAULT_ID);
|
const Store data = versionedMap(6, TESTACCESSOR_DEFAULT_ID);
|
||||||
const Utils::FilePath path = "/foo/baz.user";
|
const Utils::FilePath path = "/foo/baz.user";
|
||||||
|
|
||||||
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
||||||
@@ -589,7 +588,7 @@ void tst_SettingsAccessor::findIssues_ok()
|
|||||||
void tst_SettingsAccessor::findIssues_emptyData()
|
void tst_SettingsAccessor::findIssues_emptyData()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap data;
|
const Store data;
|
||||||
const Utils::FilePath path = "/foo/bar.user";
|
const Utils::FilePath path = "/foo/bar.user";
|
||||||
|
|
||||||
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
||||||
@@ -600,7 +599,7 @@ void tst_SettingsAccessor::findIssues_emptyData()
|
|||||||
void tst_SettingsAccessor::findIssues_tooNew()
|
void tst_SettingsAccessor::findIssues_tooNew()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap data = versionedMap(42, TESTACCESSOR_DEFAULT_ID);
|
const Store data = versionedMap(42, TESTACCESSOR_DEFAULT_ID);
|
||||||
const Utils::FilePath path = "/foo/bar.user";
|
const Utils::FilePath path = "/foo/bar.user";
|
||||||
|
|
||||||
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
||||||
@@ -611,7 +610,7 @@ void tst_SettingsAccessor::findIssues_tooNew()
|
|||||||
void tst_SettingsAccessor::findIssues_tooOld()
|
void tst_SettingsAccessor::findIssues_tooOld()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap data = versionedMap(2, TESTACCESSOR_DEFAULT_ID);
|
const Store data = versionedMap(2, TESTACCESSOR_DEFAULT_ID);
|
||||||
const Utils::FilePath path = "/foo/bar.user";
|
const Utils::FilePath path = "/foo/bar.user";
|
||||||
|
|
||||||
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
||||||
@@ -622,7 +621,7 @@ void tst_SettingsAccessor::findIssues_tooOld()
|
|||||||
void tst_SettingsAccessor::findIssues_wrongId()
|
void tst_SettingsAccessor::findIssues_wrongId()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap data = versionedMap(6, "foo");
|
const Store data = versionedMap(6, "foo");
|
||||||
const Utils::FilePath path = "/foo/bar.user";
|
const Utils::FilePath path = "/foo/bar.user";
|
||||||
|
|
||||||
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
||||||
@@ -633,7 +632,7 @@ void tst_SettingsAccessor::findIssues_wrongId()
|
|||||||
void tst_SettingsAccessor::findIssues_nonDefaultPath()
|
void tst_SettingsAccessor::findIssues_nonDefaultPath()
|
||||||
{
|
{
|
||||||
const TestSettingsAccessor accessor;
|
const TestSettingsAccessor accessor;
|
||||||
const QVariantMap data = versionedMap(6, TESTACCESSOR_DEFAULT_ID);
|
const Store data = versionedMap(6, TESTACCESSOR_DEFAULT_ID);
|
||||||
const Utils::FilePath path = "/foo/bar.user.foobar";
|
const Utils::FilePath path = "/foo/bar.user.foobar";
|
||||||
|
|
||||||
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
const std::optional<Utils::SettingsAccessor::Issue> info = accessor.findIssues(data, path);
|
||||||
@@ -646,12 +645,12 @@ void tst_SettingsAccessor::saveSettings()
|
|||||||
{
|
{
|
||||||
const FilePath baseFile = "/tmp/foo/saveSettings";
|
const FilePath baseFile = "/tmp/foo/saveSettings";
|
||||||
const TestSettingsAccessor accessor(baseFile);
|
const TestSettingsAccessor accessor(baseFile);
|
||||||
const QVariantMap data = versionedMap(6, TESTACCESSOR_DEFAULT_ID);
|
const Store data = versionedMap(6, TESTACCESSOR_DEFAULT_ID);
|
||||||
|
|
||||||
QVERIFY(accessor.saveSettings(data, nullptr));
|
QVERIFY(accessor.saveSettings(data, nullptr));
|
||||||
|
|
||||||
QCOMPARE(accessor.files().count(), 1);
|
QCOMPARE(accessor.files().count(), 1);
|
||||||
const QVariantMap read = accessor.fileContents(baseFile);
|
const Store read = accessor.fileContents(baseFile);
|
||||||
|
|
||||||
QVERIFY(!read.isEmpty());
|
QVERIFY(!read.isEmpty());
|
||||||
for (auto it = read.cbegin(); it != read.cend(); ++it) {
|
for (auto it = read.cbegin(); it != read.cend(); ++it) {
|
||||||
@@ -667,13 +666,13 @@ void tst_SettingsAccessor::saveSettings()
|
|||||||
|
|
||||||
void tst_SettingsAccessor::loadSettings()
|
void tst_SettingsAccessor::loadSettings()
|
||||||
{
|
{
|
||||||
const QVariantMap data = versionedMap(6, "loadSettings", generateExtraData());
|
const Store data = versionedMap(6, "loadSettings", generateExtraData());
|
||||||
const FilePath path = "/tmp/foo/loadSettings";
|
const FilePath path = "/tmp/foo/loadSettings";
|
||||||
const TestSettingsAccessor accessor(path, "loadSettings");
|
const TestSettingsAccessor accessor(path, "loadSettings");
|
||||||
accessor.addFile(path, data);
|
accessor.addFile(path, data);
|
||||||
QCOMPARE(accessor.files().count(), 1); // Catch changes early:-)
|
QCOMPARE(accessor.files().count(), 1); // Catch changes early:-)
|
||||||
|
|
||||||
const QVariantMap read = accessor.restoreSettings(nullptr);
|
const Store read = accessor.restoreSettings(nullptr);
|
||||||
QCOMPARE(accessor.files().count(), 1); // no files were created
|
QCOMPARE(accessor.files().count(), 1); // no files were created
|
||||||
|
|
||||||
QVERIFY(!read.isEmpty());
|
QVERIFY(!read.isEmpty());
|
||||||
@@ -700,7 +699,7 @@ void tst_SettingsAccessor::loadSettings_pickBest()
|
|||||||
const TestSettingsAccessor accessor(path, "loadSettings");
|
const TestSettingsAccessor accessor(path, "loadSettings");
|
||||||
|
|
||||||
accessor.addFile(path, versionedMap(10, "loadSettings", generateExtraData())); // too new
|
accessor.addFile(path, versionedMap(10, "loadSettings", generateExtraData())); // too new
|
||||||
const QVariantMap data = versionedMap(7, "loadSettings", generateExtraData());
|
const Store data = versionedMap(7, "loadSettings", generateExtraData());
|
||||||
accessor.addFile("/tmp/foo/loadSettings.foo", data); // pick this!
|
accessor.addFile("/tmp/foo/loadSettings.foo", data); // pick this!
|
||||||
accessor.addFile("/tmp/foo/loadSettings.foo1",
|
accessor.addFile("/tmp/foo/loadSettings.foo1",
|
||||||
versionedMap(8, "fooSettings", generateExtraData())); // wrong environment
|
versionedMap(8, "fooSettings", generateExtraData())); // wrong environment
|
||||||
@@ -710,7 +709,7 @@ void tst_SettingsAccessor::loadSettings_pickBest()
|
|||||||
versionedMap(1, "loadSettings", generateExtraData())); // much too old
|
versionedMap(1, "loadSettings", generateExtraData())); // much too old
|
||||||
QCOMPARE(accessor.files().count(), 5); // Catch changes early:-)
|
QCOMPARE(accessor.files().count(), 5); // Catch changes early:-)
|
||||||
|
|
||||||
const QVariantMap read = accessor.restoreSettings(nullptr);
|
const Store read = accessor.restoreSettings(nullptr);
|
||||||
QCOMPARE(accessor.files().count(), 5); // no new files
|
QCOMPARE(accessor.files().count(), 5); // no new files
|
||||||
|
|
||||||
QVERIFY(!read.isEmpty());
|
QVERIFY(!read.isEmpty());
|
||||||
|
Reference in New Issue
Block a user