Utils: Introduce variantFromStore and storeFromVariant

These are functional replacements for
  QVariant::fromValue(QVariantMap) (or QVariant::fromValue(Store)) and
  QVariant::toMap() (or QVariant::toValue<Store>())

We will have a few code paths in the end that need to explicitly
operarate on both QVariantMap and Store (e.g. actual reading/writing
to keep format compatibility etc), so these can't in the end be
simple to/fromValue(OneType) but need an internal 'if' or such.

Change-Id: I954f3cb24fa8fe123162b72bbd25d891dd19b768
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-08-28 10:55:31 +02:00
parent bb59dfd636
commit 23149b27ab
39 changed files with 149 additions and 136 deletions

View File

@@ -135,7 +135,7 @@ QVariant ParseValueStackEntry::value() const
case QVariant::Invalid: case QVariant::Invalid:
return QVariant(); return QVariant();
case QVariant::Map: case QVariant::Map:
return QVariant::fromValue(mapValue); return variantFromStore(mapValue);
case QVariant::List: case QVariant::List:
return QVariant(listValue); return QVariant(listValue);
default: default:
@@ -378,7 +378,7 @@ static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx,
w.writeAttribute(ctx.typeAttribute, QLatin1String(QVariant::typeToName(QVariant::Map))); w.writeAttribute(ctx.typeAttribute, QLatin1String(QVariant::typeToName(QVariant::Map)));
if (!key.isEmpty()) if (!key.isEmpty())
w.writeAttribute(ctx.keyAttribute, key); w.writeAttribute(ctx.keyAttribute, key);
const Store varMap = variant.value<Store>(); const Store varMap = storeFromVariant(variant);
const Store::const_iterator cend = varMap.constEnd(); const Store::const_iterator cend = varMap.constEnd();
for (Store::const_iterator i = varMap.constBegin(); i != cend; ++i) for (Store::const_iterator i = varMap.constBegin(); i != cend; ++i)
writeVariantValue(w, ctx, i.value(), i.key()); writeVariantValue(w, ctx, i.value(), i.key());

View File

@@ -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() = QVariant::fromValue(renameKeys(changes, v.value<Store>())); i.value() = variantFromStore(renameKeys(changes, storeFromVariant(v)));
++i; ++i;
} }
@@ -639,7 +639,7 @@ MergingSettingsAccessor::mergeSettings(const SettingsAccessor::RestoreData &main
= [this](const SettingsMergeData &global, const SettingsMergeData &local) { = [this](const SettingsMergeData &global, const SettingsMergeData &local) {
return merge(global, local); return merge(global, local);
}; };
const Store result = mergeQVariantMaps(main.data, secondary.data, mergeFunction).value<Store>(); const Store result = storeFromVariant(mergeQVariantMaps(main.data, secondary.data, mergeFunction));
// Update from the base version to Creator's version. // Update from the base version to Creator's version.
return RestoreData(main.path, postprocessMerge(main.data, secondary.data, result)); return RestoreData(main.path, postprocessMerge(main.data, secondary.data, result));
@@ -720,15 +720,15 @@ static QVariant mergeQVariantMapsRecursion(const Store &mainTree, const Store &s
if (kv.second.type() == QVariant::Map) { if (kv.second.type() == QVariant::Map) {
const Key newKeyPrefix = keyPrefix + kv.first + '/'; const Key newKeyPrefix = keyPrefix + kv.first + '/';
kv.second = mergeQVariantMapsRecursion(mainTree, secondaryTree, newKeyPrefix, kv.second = mergeQVariantMapsRecursion(mainTree, secondaryTree, newKeyPrefix,
kv.second.value<Store>(), storeFromVariant(kv.second),
secondarySubtree.value(kv.first).value<Store>(), storeFromVariant(secondarySubtree.value(kv.first)),
merge); merge);
} }
if (!kv.second.isNull()) if (!kv.second.isNull())
result.insert(kv.first, kv.second); result.insert(kv.first, kv.second);
} }
return QVariant::fromValue(result); return variantFromStore(result);
} }
QVariant mergeQVariantMaps(const Store &mainTree, const Store &secondaryTree, QVariant mergeQVariantMaps(const Store &mainTree, const Store &secondaryTree,

View File

@@ -17,4 +17,14 @@ QStringList stringsFromKeys(const KeyList &list)
return transform(list, &stringFromKey); return transform(list, &stringFromKey);
} }
QVariant variantFromStore(const Store &store)
{
return QVariant::fromValue(store);
}
Store storeFromVariant(const QVariant &value)
{
return value.value<Store>();
}
} // Utils } // Utils

View File

@@ -21,4 +21,7 @@ using Store = QVariantMap;
QTCREATOR_UTILS_EXPORT KeyList keysFromStrings(const QStringList &list); QTCREATOR_UTILS_EXPORT KeyList keysFromStrings(const QStringList &list);
QTCREATOR_UTILS_EXPORT QStringList stringsFromKeys(const KeyList &list); QTCREATOR_UTILS_EXPORT QStringList stringsFromKeys(const KeyList &list);
QTCREATOR_UTILS_EXPORT QVariant variantFromStore(const Store &store);
QTCREATOR_UTILS_EXPORT Store storeFromVariant(const QVariant &value);
} // Utils } // Utils

View File

@@ -94,7 +94,7 @@ void DebugServerProviderManager::restoreProviders()
if (!data.contains(key)) if (!data.contains(key))
break; break;
Store map = data.value(key).value<Store>(); Store map = storeFromVariant(data.value(key));
const KeyList keys = map.keys(); const KeyList keys = map.keys();
for (const Key &key : keys) { for (const Key &key : keys) {
const int lastDot = key.lastIndexOf('.'); const int lastDot = key.lastIndexOf('.');

View File

@@ -243,13 +243,13 @@ JLinkUvscServerProvider::JLinkUvscServerProvider()
void JLinkUvscServerProvider::toMap(Store &data) const void JLinkUvscServerProvider::toMap(Store &data) const
{ {
UvscServerProvider::toMap(data); UvscServerProvider::toMap(data);
data.insert(adapterOptionsKeyC, QVariant::fromValue(m_adapterOpts.toMap())); data.insert(adapterOptionsKeyC, variantFromStore(m_adapterOpts.toMap()));
} }
void JLinkUvscServerProvider::fromMap(const Store &data) void JLinkUvscServerProvider::fromMap(const Store &data)
{ {
UvscServerProvider::fromMap(data); UvscServerProvider::fromMap(data);
m_adapterOpts.fromMap(data.value(adapterOptionsKeyC).value<Store>()); m_adapterOpts.fromMap(storeFromVariant(data.value(adapterOptionsKeyC)));
} }
bool JLinkUvscServerProvider::operator==(const IDebugServerProvider &other) const bool JLinkUvscServerProvider::operator==(const IDebugServerProvider &other) const

View File

@@ -209,7 +209,7 @@ void StLinkUvscServerProvider::toMap(Store &data) const
void StLinkUvscServerProvider::fromMap(const Store &data) void StLinkUvscServerProvider::fromMap(const Store &data)
{ {
UvscServerProvider::fromMap(data); UvscServerProvider::fromMap(data);
m_adapterOpts.fromMap(data.value(adapterOptionsKeyC).value<Store>()); m_adapterOpts.fromMap(storeFromVariant(data.value(adapterOptionsKeyC)));
} }
bool StLinkUvscServerProvider::operator==(const IDebugServerProvider &other) const bool StLinkUvscServerProvider::operator==(const IDebugServerProvider &other) const

View File

@@ -151,8 +151,8 @@ void UvscServerProvider::toMap(Store &data) const
{ {
IDebugServerProvider::toMap(data); IDebugServerProvider::toMap(data);
data.insert(toolsIniKeyC, m_toolsIniFile.toSettings()); data.insert(toolsIniKeyC, m_toolsIniFile.toSettings());
data.insert(deviceSelectionKeyC, QVariant::fromValue(m_deviceSelection.toMap())); data.insert(deviceSelectionKeyC, variantFromStore(m_deviceSelection.toMap()));
data.insert(driverSelectionKeyC, QVariant::fromValue(m_driverSelection.toMap())); data.insert(driverSelectionKeyC, variantFromStore(m_driverSelection.toMap()));
} }
bool UvscServerProvider::isValid() const bool UvscServerProvider::isValid() const
@@ -223,8 +223,8 @@ void UvscServerProvider::fromMap(const Store &data)
{ {
IDebugServerProvider::fromMap(data); IDebugServerProvider::fromMap(data);
m_toolsIniFile = FilePath::fromSettings(data.value(toolsIniKeyC)); m_toolsIniFile = FilePath::fromSettings(data.value(toolsIniKeyC));
m_deviceSelection.fromMap(data.value(deviceSelectionKeyC).value<Store>()); m_deviceSelection.fromMap(storeFromVariant(data.value(deviceSelectionKeyC)));
m_driverSelection.fromMap(data.value(driverSelectionKeyC).value<Store>()); m_driverSelection.fromMap(storeFromVariant(data.value(driverSelectionKeyC)));
} }
FilePath UvscServerProvider::projectFilePath(DebuggerRunTool *runTool, QString &errorMessage) const FilePath UvscServerProvider::projectFilePath(DebuggerRunTool *runTool, QString &errorMessage) const

View File

@@ -83,7 +83,7 @@ Store DeviceSelection::toMap() const
m.insert(deviceMemoryIdKeyC, memory.id); m.insert(deviceMemoryIdKeyC, memory.id);
m.insert(deviceMemoryStartKeyC, memory.start); m.insert(deviceMemoryStartKeyC, memory.start);
m.insert(deviceMemorySizeKeyC, memory.size); m.insert(deviceMemorySizeKeyC, memory.size);
memoryList.push_back(QVariant::fromValue(m)); memoryList.push_back(variantFromStore(m));
} }
map.insert(deviceMemoryKeyC, memoryList); map.insert(deviceMemoryKeyC, memoryList);
// Device ALGORITHM. // Device ALGORITHM.
@@ -95,7 +95,7 @@ Store DeviceSelection::toMap() const
m.insert(deviceAlgorithmFlashSizeKeyC, algorithm.flashSize); m.insert(deviceAlgorithmFlashSizeKeyC, algorithm.flashSize);
m.insert(deviceAlgorithmRamStartKeyC, algorithm.ramStart); m.insert(deviceAlgorithmRamStartKeyC, algorithm.ramStart);
m.insert(deviceAlgorithmRamSizeKeyC, algorithm.ramSize); m.insert(deviceAlgorithmRamSizeKeyC, algorithm.ramSize);
algorithmList.push_back(QVariant::fromValue(m)); algorithmList.push_back(variantFromStore(m));
} }
map.insert(deviceAlgorithmKeyC, algorithmList); map.insert(deviceAlgorithmKeyC, algorithmList);
map.insert(deviceAlgorithmIndexKeyC, algorithmIndex); map.insert(deviceAlgorithmIndexKeyC, algorithmIndex);

View File

@@ -124,7 +124,7 @@ static Store convertToMapFromVersionBefore410(ProjectExplorer::Project *p)
void ClangToolsProjectSettings::load() void ClangToolsProjectSettings::load()
{ {
// Load map // Load map
Store map = m_project->namedSettings(SETTINGS_KEY_MAIN).value<Store>(); Store map = storeFromVariant(m_project->namedSettings(SETTINGS_KEY_MAIN));
bool write = false; bool write = false;
if (map.isEmpty()) { if (map.isEmpty()) {
@@ -148,7 +148,7 @@ void ClangToolsProjectSettings::load()
const QVariantList list = map.value(SETTINGS_KEY_SUPPRESSED_DIAGS).toList(); const QVariantList list = map.value(SETTINGS_KEY_SUPPRESSED_DIAGS).toList();
for (const QVariant &v : list) { for (const QVariant &v : list) {
const Store diag = v.value<Store>(); const Store diag = storeFromVariant(v);
const QString fp = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH).toString(); const QString fp = diag.value(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH).toString();
if (fp.isEmpty()) if (fp.isEmpty())
continue; continue;
@@ -190,13 +190,13 @@ void ClangToolsProjectSettings::store()
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH, diag.filePath.toString()); diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_FILEPATH, diag.filePath.toString());
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE, diag.description); diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_MESSAGE, diag.description);
diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER, diag.uniquifier); diagMap.insert(SETTINGS_KEY_SUPPRESSED_DIAGS_UNIQIFIER, diag.uniquifier);
list << QVariant::fromValue(diagMap); list << variantFromStore(diagMap);
} }
map.insert(SETTINGS_KEY_SUPPRESSED_DIAGS, list); map.insert(SETTINGS_KEY_SUPPRESSED_DIAGS, list);
m_runSettings.toMap(map, SETTINGS_PREFIX); m_runSettings.toMap(map, SETTINGS_PREFIX);
m_project->setNamedSettings(SETTINGS_KEY_MAIN, QVariant::fromValue(map)); m_project->setNamedSettings(SETTINGS_KEY_MAIN, variantFromStore(map));
} }
ClangToolsProjectSettings::ClangToolsProjectSettingsPtr ClangToolsProjectSettings::ClangToolsProjectSettingsPtr

View File

@@ -1433,7 +1433,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id)
setInitializer([this, target](const BuildInfo &info) { setInitializer([this, target](const BuildInfo &info) {
const Kit *k = target->kit(); const Kit *k = target->kit();
const QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(k); const QtSupport::QtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
const Store extraInfoMap = info.extraInfo.value<Store>(); const Store extraInfoMap = storeFromVariant(info.extraInfo);
const QString buildType = extraInfoMap.contains(CMAKE_BUILD_TYPE) const QString buildType = extraInfoMap.contains(CMAKE_BUILD_TYPE)
? extraInfoMap.value(CMAKE_BUILD_TYPE).toString() ? extraInfoMap.value(CMAKE_BUILD_TYPE).toString()
: info.typeName; : info.typeName;
@@ -1942,7 +1942,7 @@ BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(BuildType buildType)
Store extraInfo; Store extraInfo;
// enable QML debugging by default // enable QML debugging by default
extraInfo.insert(Constants::QML_DEBUG_SETTING, TriState::Enabled.toVariant()); extraInfo.insert(Constants::QML_DEBUG_SETTING, TriState::Enabled.toVariant());
info.extraInfo = QVariant::fromValue(extraInfo); info.extraInfo = variantFromStore(extraInfo);
break; break;
} }
case BuildTypeRelease: case BuildTypeRelease:
@@ -1969,7 +1969,7 @@ BuildInfo CMakeBuildConfigurationFactory::createBuildInfo(BuildType buildType)
extraInfo.insert(CMAKE_BUILD_TYPE, "RelWithDebInfo"); extraInfo.insert(CMAKE_BUILD_TYPE, "RelWithDebInfo");
// enable QML debugging by default // enable QML debugging by default
extraInfo.insert(Constants::QML_DEBUG_SETTING, TriState::Enabled.toVariant()); extraInfo.insert(Constants::QML_DEBUG_SETTING, TriState::Enabled.toVariant());
info.extraInfo = QVariant::fromValue(extraInfo); info.extraInfo = variantFromStore(extraInfo);
break; break;
} }
default: default:

View File

@@ -186,7 +186,7 @@ void CMakeToolSettingsAccessor::saveCMakeTools(const QList<CMakeTool *> &cmakeTo
Store tmp = item->toMap(); Store tmp = item->toMap();
if (tmp.isEmpty()) if (tmp.isEmpty())
continue; continue;
data.insert(CMAKE_TOOL_DATA_KEY + Key::number(count), QVariant::fromValue(tmp)); data.insert(CMAKE_TOOL_DATA_KEY + Key::number(count), variantFromStore(tmp));
++count; ++count;
} }
} }
@@ -206,7 +206,7 @@ CMakeToolSettingsAccessor::cmakeTools(const Store &data, bool fromSdk) const
if (!data.contains(key)) if (!data.contains(key))
continue; continue;
const Store dbMap = data.value(key).value<Store>(); const Store dbMap = storeFromVariant(data.value(key));
auto item = std::make_unique<CMakeTool>(dbMap, fromSdk); auto item = std::make_unique<CMakeTool>(dbMap, fromSdk);
const FilePath cmakeExecutable = item->cmakeExecutable(); const FilePath cmakeExecutable = item->cmakeExecutable();
if (item->isAutoDetected() && !cmakeExecutable.needsDevice() && !cmakeExecutable.isExecutableFile()) { if (item->isAutoDetected() && !cmakeExecutable.needsDevice() && !cmakeExecutable.isExecutableFile()) {

View File

@@ -233,7 +233,7 @@ CopilotProjectSettings::CopilotProjectSettings(ProjectExplorer::Project *project
initEnableAspect(enableCopilot); initEnableAspect(enableCopilot);
Store map = project->namedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID).value<Store>(); Store map = storeFromVariant(project->namedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID));
fromMap(map); fromMap(map);
connect(&enableCopilot, &BaseAspect::changed, this, [this, project] { save(project); }); connect(&enableCopilot, &BaseAspect::changed, this, [this, project] { save(project); });
@@ -256,7 +256,7 @@ void CopilotProjectSettings::save(ProjectExplorer::Project *project)
{ {
Store map; Store map;
toMap(map); toMap(map);
project->setNamedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID, QVariant::fromValue(map)); project->setNamedSettings(Constants::COPILOT_PROJECT_SETTINGS_ID, variantFromStore(map));
// This triggers a restart of the Copilot language server. // This triggers a restart of the Copilot language server.
settings().apply(); settings().apply();

View File

@@ -498,7 +498,7 @@ void ClangdProjectSettings::loadSettings()
{ {
if (!m_project) if (!m_project)
return; return;
const Store data = m_project->namedSettings(clangdSettingsKey()).value<Store>(); const Store data = storeFromVariant(m_project->namedSettings(clangdSettingsKey()));
m_useGlobalSettings = data.value(clangdUseGlobalSettingsKey(), true).toBool(); m_useGlobalSettings = data.value(clangdUseGlobalSettingsKey(), true).toBool();
m_blockIndexing = data.value(clangdblockIndexingSettingsKey(), false).toBool(); m_blockIndexing = data.value(clangdblockIndexingSettingsKey(), false).toBool();
if (!m_useGlobalSettings) if (!m_useGlobalSettings)
@@ -514,7 +514,7 @@ void ClangdProjectSettings::saveSettings()
data = m_customSettings.toMap(); data = m_customSettings.toMap();
data.insert(clangdUseGlobalSettingsKey(), m_useGlobalSettings); data.insert(clangdUseGlobalSettingsKey(), m_useGlobalSettings);
data.insert(clangdblockIndexingSettingsKey(), m_blockIndexing); data.insert(clangdblockIndexingSettingsKey(), m_blockIndexing);
m_project->setNamedSettings(clangdSettingsKey(), QVariant::fromValue(data)); m_project->setNamedSettings(clangdSettingsKey(), variantFromStore(data));
} }
Store ClangdSettings::Data::toMap() const Store ClangdSettings::Data::toMap() const

View File

@@ -767,7 +767,7 @@ void DebuggerItemModel::readDebuggers(const FilePath &fileName, bool isSystem)
const Key key = DEBUGGER_DATA_KEY + Key::number(i); const Key key = DEBUGGER_DATA_KEY + Key::number(i);
if (!data.contains(key)) if (!data.contains(key))
continue; continue;
const Store dbMap = data.value(key).value<Store>(); const Store dbMap = storeFromVariant(data.value(key));
DebuggerItem item(dbMap); DebuggerItem item(dbMap);
if (isSystem) { if (isSystem) {
item.setAutoDetected(true); item.setAutoDetected(true);
@@ -821,7 +821,7 @@ void DebuggerItemModel::saveDebuggers()
if (item.isValid() && item.engineType() != NoEngineType) { if (item.isValid() && item.engineType() != NoEngineType) {
Store tmp = item.toMap(); Store tmp = item.toMap();
if (!tmp.isEmpty()) { if (!tmp.isEmpty()) {
data.insert(DEBUGGER_DATA_KEY + Key::number(count), QVariant::fromValue(tmp)); data.insert(DEBUGGER_DATA_KEY + Key::number(count), variantFromStore(tmp));
++count; ++count;
} }
} }

View File

@@ -131,7 +131,7 @@ void IosDevice::fromMap(const Store &map)
IDevice::fromMap(map); IDevice::fromMap(map);
m_extraInfo.clear(); m_extraInfo.clear();
const Store vMap = map.value(Constants::EXTRA_INFO_KEY).value<Store>(); const Store vMap = storeFromVariant(map.value(Constants::EXTRA_INFO_KEY));
for (auto i = vMap.cbegin(), end = vMap.cend(); i != end; ++i) for (auto i = vMap.cbegin(), end = vMap.cend(); i != end; ++i)
m_extraInfo.insert(stringFromKey(i.key()), i.value().toString()); m_extraInfo.insert(stringFromKey(i.key()), i.value().toString());
} }
@@ -142,7 +142,7 @@ Store IosDevice::toMap() const
Store vMap; Store vMap;
for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i) for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i)
vMap.insert(keyFromString(i.key()), i.value()); vMap.insert(keyFromString(i.key()), i.value());
res.insert(Constants::EXTRA_INFO_KEY, QVariant::fromValue(vMap)); res.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap));
return res; return res;
} }

View File

@@ -210,7 +210,7 @@ void IosDeviceTypeAspect::fromMap(const Store &map)
{ {
bool deviceTypeIsInt; bool deviceTypeIsInt;
map.value(deviceTypeKey).toInt(&deviceTypeIsInt); map.value(deviceTypeKey).toInt(&deviceTypeIsInt);
if (deviceTypeIsInt || !m_deviceType.fromMap(map.value(deviceTypeKey).value<Store>())) if (deviceTypeIsInt || !m_deviceType.fromMap(storeFromVariant(map.value(deviceTypeKey))))
updateDeviceType(); updateDeviceType();
m_runConfiguration->update(); m_runConfiguration->update();

View File

@@ -612,7 +612,7 @@ QList<BaseSettings *> LanguageClientSettings::fromSettings(QSettings *settingsIn
for (auto varList : for (auto varList :
{settingsIn->value(clientsKey).toList(), settingsIn->value(typedClientsKey).toList()}) { {settingsIn->value(clientsKey).toList(), settingsIn->value(typedClientsKey).toList()}) {
for (const QVariant &var : varList) { for (const QVariant &var : varList) {
const Store map = var.value<Store>(); const Store map = storeFromVariant(var);
Id typeId = Id::fromSetting(map.value(typeIdKey)); Id typeId = Id::fromSetting(map.value(typeIdKey));
if (!typeId.isValid()) if (!typeId.isValid())
typeId = Constants::LANGUAGECLIENT_STDIO_SETTINGS_ID; typeId = Constants::LANGUAGECLIENT_STDIO_SETTINGS_ID;
@@ -659,7 +659,7 @@ void LanguageClientSettings::toSettings(QSettings *settings,
settings->beginGroup(settingsGroupKey); settings->beginGroup(settingsGroupKey);
auto transform = [](const QList<BaseSettings *> &settings) { auto transform = [](const QList<BaseSettings *> &settings) {
return Utils::transform(settings, [](const BaseSettings *setting) { return Utils::transform(settings, [](const BaseSettings *setting) {
return QVariant::fromValue(setting->toMap()); return variantFromStore(setting->toMap());
}); });
}; };
auto isStdioSetting = Utils::equal(&BaseSettings::m_settingsTypeId, auto isStdioSetting = Utils::equal(&BaseSettings::m_settingsTypeId,

View File

@@ -42,11 +42,11 @@ void ToolsSettingsAccessor::saveMesonTools(const std::vector<MesonTools::Tool_t>
for (const MesonTools::Tool_t &tool : tools) { for (const MesonTools::Tool_t &tool : tools) {
auto asMeson = std::dynamic_pointer_cast<MesonWrapper>(tool); auto asMeson = std::dynamic_pointer_cast<MesonWrapper>(tool);
if (asMeson) if (asMeson)
data.insert(entryName(entry_count), QVariant::fromValue(toVariantMap<MesonWrapper>(*asMeson))); data.insert(entryName(entry_count), variantFromStore(toVariantMap<MesonWrapper>(*asMeson)));
else { else {
auto asNinja = std::dynamic_pointer_cast<NinjaWrapper>(tool); auto asNinja = std::dynamic_pointer_cast<NinjaWrapper>(tool);
if (asNinja) if (asNinja)
data.insert(entryName(entry_count), QVariant::fromValue(toVariantMap<NinjaWrapper>(*asNinja))); data.insert(entryName(entry_count), variantFromStore(toVariantMap<NinjaWrapper>(*asNinja)));
} }
entry_count++; entry_count++;
} }
@@ -66,9 +66,9 @@ std::vector<MesonTools::Tool_t> ToolsSettingsAccessor::loadMesonTools(QWidget *p
const auto map = data[name].toMap(); const auto map = data[name].toMap();
auto type = map.value(ToolsSettings::TOOL_TYPE_KEY, ToolsSettings::TOOL_TYPE_MESON); auto type = map.value(ToolsSettings::TOOL_TYPE_KEY, ToolsSettings::TOOL_TYPE_MESON);
if (type == ToolsSettings::TOOL_TYPE_NINJA) if (type == ToolsSettings::TOOL_TYPE_NINJA)
result.emplace_back(fromVariantMap<NinjaWrapper *>(data[name].value<Store>())); result.emplace_back(fromVariantMap<NinjaWrapper *>(storeFromVariant(data[name])));
else else
result.emplace_back(fromVariantMap<MesonWrapper *>(data[name].value<Store>())); result.emplace_back(fromVariantMap<MesonWrapper *>(storeFromVariant(data[name])));
} }
} }
return result; return result;

View File

@@ -381,8 +381,8 @@ void BuildConfiguration::toMap(Store &map) const
EnvironmentItem::toStringList(d->m_userEnvironmentChanges)); EnvironmentItem::toStringList(d->m_userEnvironmentChanges));
map.insert(BUILD_STEP_LIST_COUNT, 2); map.insert(BUILD_STEP_LIST_COUNT, 2);
map.insert(BUILD_STEP_LIST_PREFIX + Key::number(0), QVariant::fromValue(d->m_buildSteps.toMap())); map.insert(BUILD_STEP_LIST_PREFIX + Key::number(0), variantFromStore(d->m_buildSteps.toMap()));
map.insert(BUILD_STEP_LIST_PREFIX + Key::number(1), QVariant::fromValue(d->m_cleanSteps.toMap())); map.insert(BUILD_STEP_LIST_PREFIX + Key::number(1), variantFromStore(d->m_cleanSteps.toMap()));
map.insert(PARSE_STD_OUT_KEY, d->m_parseStdOut); map.insert(PARSE_STD_OUT_KEY, d->m_parseStdOut);
map.insert(CUSTOM_PARSERS_KEY, transform(d->m_customParsers, &Id::toSetting)); map.insert(CUSTOM_PARSERS_KEY, transform(d->m_customParsers, &Id::toSetting));
@@ -401,7 +401,7 @@ void BuildConfiguration::fromMap(const Store &map)
int maxI = map.value(BUILD_STEP_LIST_COUNT, 0).toInt(); int maxI = map.value(BUILD_STEP_LIST_COUNT, 0).toInt();
for (int i = 0; i < maxI; ++i) { for (int i = 0; i < maxI; ++i) {
Store data = map.value(BUILD_STEP_LIST_PREFIX + Key::number(i)).value<Store>(); Store data = storeFromVariant(map.value(BUILD_STEP_LIST_PREFIX + Key::number(i)));
if (data.isEmpty()) { if (data.isEmpty()) {
qWarning() << "No data for build step list" << i << "found!"; qWarning() << "No data for build step list" << i << "found!";
continue; continue;

View File

@@ -62,7 +62,7 @@ Store BuildStepList::toMap() const
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(STEPS_PREFIX + Key::number(i), QVariant::fromValue(data)); map.insert(STEPS_PREFIX + Key::number(i), variantFromStore(data));
} }
return map; return map;
@@ -111,7 +111,7 @@ bool BuildStepList::fromMap(const Store &map)
int maxSteps = map.value(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(STEPS_PREFIX + Key::number(i)).value<Store>()); Store bsData = storeFromVariant(map.value(STEPS_PREFIX + Key::number(i)));
if (bsData.isEmpty()) { if (bsData.isEmpty()) {
qWarning() << "No step data found for" << i << "(continuing)."; qWarning() << "No step data found for" << i << "(continuing).";
continue; continue;

View File

@@ -144,8 +144,8 @@ Store CustomParserSettings::toMap() const
Store map; Store map;
map.insert(idKey, id.toSetting()); map.insert(idKey, id.toSetting());
map.insert(nameKey, displayName); map.insert(nameKey, displayName);
map.insert(errorKey, QVariant::fromValue(error.toMap())); map.insert(errorKey, variantFromStore(error.toMap()));
map.insert(warningKey, QVariant::fromValue(warning.toMap())); map.insert(warningKey, variantFromStore(warning.toMap()));
return map; return map;
} }
@@ -153,8 +153,8 @@ void CustomParserSettings::fromMap(const Store &map)
{ {
id = Id::fromSetting(map.value(idKey)); id = Id::fromSetting(map.value(idKey));
displayName = map.value(nameKey).toString(); displayName = map.value(nameKey).toString();
error.fromMap(map.value(errorKey).value<Store>()); error.fromMap(storeFromVariant(map.value(errorKey)));
warning.fromMap(map.value(warningKey).value<Store>()); warning.fromMap(storeFromVariant(map.value(warningKey)));
} }
CustomParsersAspect::CustomParsersAspect(Target *target) CustomParsersAspect::CustomParsersAspect(Target *target)

View File

@@ -54,14 +54,14 @@ void DeployConfiguration::toMap(Store &map) const
{ {
ProjectConfiguration::toMap(map); ProjectConfiguration::toMap(map);
map.insert(BUILD_STEP_LIST_COUNT, 1); map.insert(BUILD_STEP_LIST_COUNT, 1);
map.insert(Key(BUILD_STEP_LIST_PREFIX) + '0', QVariant::fromValue(m_stepList.toMap())); map.insert(Key(BUILD_STEP_LIST_PREFIX) + '0', variantFromStore(m_stepList.toMap()));
map.insert(USES_DEPLOYMENT_DATA, usesCustomDeploymentData()); map.insert(USES_DEPLOYMENT_DATA, usesCustomDeploymentData());
Store deployData; Store deployData;
for (int i = 0; i < m_customDeploymentData.fileCount(); ++i) { for (int i = 0; i < m_customDeploymentData.fileCount(); ++i) {
const DeployableFile &f = m_customDeploymentData.fileAt(i); const DeployableFile &f = m_customDeploymentData.fileAt(i);
deployData.insert(keyFromString(f.localFilePath().toString()), f.remoteDirectory()); deployData.insert(keyFromString(f.localFilePath().toString()), f.remoteDirectory());
} }
map.insert(DEPLOYMENT_DATA, QVariant::fromValue(deployData)); map.insert(DEPLOYMENT_DATA, variantFromStore(deployData));
} }
void DeployConfiguration::fromMap(const Store &map) void DeployConfiguration::fromMap(const Store &map)
@@ -75,7 +75,7 @@ void DeployConfiguration::fromMap(const Store &map)
reportError(); reportError();
return; return;
} }
Store data = map.value(Key(BUILD_STEP_LIST_PREFIX) + '0').value<Store>(); Store data = storeFromVariant(map.value(Key(BUILD_STEP_LIST_PREFIX) + '0'));
if (!data.isEmpty()) { if (!data.isEmpty()) {
m_stepList.clear(); m_stepList.clear();
if (!m_stepList.fromMap(data)) { if (!m_stepList.fromMap(data)) {
@@ -91,7 +91,7 @@ void DeployConfiguration::fromMap(const Store &map)
} }
m_usesCustomDeploymentData = map.value(USES_DEPLOYMENT_DATA, false).toBool(); m_usesCustomDeploymentData = map.value(USES_DEPLOYMENT_DATA, false).toBool();
const Store deployData = map.value(DEPLOYMENT_DATA).value<Store>(); const Store deployData = storeFromVariant(map.value(DEPLOYMENT_DATA));
for (auto it = deployData.begin(); it != deployData.end(); ++it) for (auto it = deployData.begin(); it != deployData.end(); ++it)
m_customDeploymentData.addFile(FilePath::fromString(stringFromKey(it.key())), it.value().toString()); m_customDeploymentData.addFile(FilePath::fromString(stringFromKey(it.key())), it.value().toString());
} }

View File

@@ -131,7 +131,7 @@ void DeviceManager::save()
if (d->clonedInstance == this || !d->writer) if (d->clonedInstance == this || !d->writer)
return; return;
Store data; Store data;
data.insert(DeviceManagerKey, QVariant::fromValue(toMap())); data.insert(DeviceManagerKey, variantFromStore(toMap()));
d->writer->save(data, Core::ICore::dialogParent()); d->writer->save(data, Core::ICore::dialogParent());
} }
@@ -157,11 +157,11 @@ void DeviceManager::load()
QHash<Id, Id> defaultDevices; QHash<Id, Id> defaultDevices;
QList<IDevice::Ptr> sdkDevices; QList<IDevice::Ptr> sdkDevices;
if (reader.load(systemSettingsFilePath("devices.xml"))) if (reader.load(systemSettingsFilePath("devices.xml")))
sdkDevices = fromMap(reader.restoreValues().value(DeviceManagerKey).value<Store>(), &defaultDevices); sdkDevices = fromMap(storeFromVariant(reader.restoreValues().value(DeviceManagerKey)), &defaultDevices);
// read devices file from user settings path // read devices file from user settings path
QList<IDevice::Ptr> userDevices; QList<IDevice::Ptr> userDevices;
if (reader.load(settingsFilePath("devices.xml"))) if (reader.load(settingsFilePath("devices.xml")))
userDevices = fromMap(reader.restoreValues().value(DeviceManagerKey).value<Store>(), &defaultDevices); userDevices = fromMap(storeFromVariant(reader.restoreValues().value(DeviceManagerKey)), &defaultDevices);
// Insert devices into the model. Prefer the higher device version when there are multiple // Insert devices into the model. Prefer the higher device version when there are multiple
// devices with the same id. // devices with the same id.
for (IDevice::ConstPtr device : std::as_const(userDevices)) { for (IDevice::ConstPtr device : std::as_const(userDevices)) {
@@ -209,13 +209,13 @@ QList<IDevice::Ptr> DeviceManager::fromMap(const Store &map, QHash<Id, Id> *defa
QList<IDevice::Ptr> devices; QList<IDevice::Ptr> devices;
if (defaultDevices) { if (defaultDevices) {
const Store defaultDevsMap = map.value(DefaultDevicesKey).value<Store>(); const Store defaultDevsMap = storeFromVariant(map.value(DefaultDevicesKey));
for (auto it = defaultDevsMap.constBegin(); it != defaultDevsMap.constEnd(); ++it) for (auto it = defaultDevsMap.constBegin(); it != defaultDevsMap.constEnd(); ++it)
defaultDevices->insert(Id::fromString(stringFromKey(it.key())), Id::fromSetting(it.value())); defaultDevices->insert(Id::fromString(stringFromKey(it.key())), Id::fromSetting(it.value()));
} }
const QVariantList deviceList = map.value(DeviceListKey).toList(); const QVariantList deviceList = map.value(DeviceListKey).toList();
for (const QVariant &v : deviceList) { for (const QVariant &v : deviceList) {
const Store map = v.value<Store>(); const Store map = storeFromVariant(v);
const IDeviceFactory * const factory = restoreFactory(map); const IDeviceFactory * const factory = restoreFactory(map);
if (!factory) if (!factory)
continue; continue;
@@ -234,10 +234,10 @@ Store DeviceManager::toMap() const
for (auto it = d->defaultDevices.constBegin(); it != d->defaultDevices.constEnd(); ++it) for (auto it = d->defaultDevices.constBegin(); it != d->defaultDevices.constEnd(); ++it)
defaultDeviceMap.insert(keyFromString(it.key().toString()), it.value().toSetting()); defaultDeviceMap.insert(keyFromString(it.key().toString()), it.value().toSetting());
map.insert(DefaultDevicesKey, QVariant::fromValue(defaultDeviceMap)); map.insert(DefaultDevicesKey, variantFromStore(defaultDeviceMap));
QVariantList deviceList; QVariantList deviceList;
for (const IDevice::Ptr &device : std::as_const(d->devices)) for (const IDevice::Ptr &device : std::as_const(d->devices))
deviceList << QVariant::fromValue(device->toMap()); deviceList << variantFromStore(device->toMap());
map.insert(DeviceListKey, deviceList); map.insert(DeviceListKey, deviceList);
return map; return map;
} }

View File

@@ -475,7 +475,7 @@ void IDevice::fromMap(const Store &map)
d->debugServerPath = FilePath::fromSettings(map.value(DebugServerKey)); d->debugServerPath = FilePath::fromSettings(map.value(DebugServerKey));
const FilePath qmlRunCmd = FilePath::fromSettings(map.value(QmlRuntimeKey)); const FilePath qmlRunCmd = FilePath::fromSettings(map.value(QmlRuntimeKey));
d->qmlRunCommand = qmlRunCmd; d->qmlRunCommand = qmlRunCmd;
d->extraData = map.value(ExtraDataKey).value<Store>(); d->extraData = storeFromVariant(map.value(ExtraDataKey));
} }
/*! /*!
@@ -509,7 +509,7 @@ Store IDevice::toMap() const
map.insert(DebugServerKey, d->debugServerPath.toSettings()); map.insert(DebugServerKey, d->debugServerPath.toSettings());
map.insert(QmlRuntimeKey, d->qmlRunCommand.toSettings()); map.insert(QmlRuntimeKey, d->qmlRunCommand.toSettings());
map.insert(ExtraDataKey, QVariant::fromValue(d->extraData)); map.insert(ExtraDataKey, variantFromStore(d->extraData));
return map; return map;
} }

View File

@@ -181,7 +181,7 @@ Store EditorConfiguration::toMap() const
{"language", QVariant::fromValue(itCodeStyle.key().toSetting())}, {"language", QVariant::fromValue(itCodeStyle.key().toSetting())},
{"value", QVariant::fromValue(itCodeStyle.value()->toMap())} {"value", QVariant::fromValue(itCodeStyle.value()->toMap())}
}; };
map.insert(kCodeStylePrefix + Key::number(i), QVariant::fromValue(settingsIdMap)); map.insert(kCodeStylePrefix + Key::number(i), variantFromStore(settingsIdMap));
i++; i++;
} }
@@ -204,13 +204,13 @@ void EditorConfiguration::fromMap(const Store &map)
const int codeStyleCount = map.value(kCodeStyleCount, 0).toInt(); const int codeStyleCount = map.value(kCodeStyleCount, 0).toInt();
for (int i = 0; i < codeStyleCount; ++i) { for (int i = 0; i < codeStyleCount; ++i) {
Store settingsIdMap = map.value(kCodeStylePrefix + Key::number(i)).value<Store>(); Store settingsIdMap = storeFromVariant(map.value(kCodeStylePrefix + Key::number(i)));
if (settingsIdMap.isEmpty()) { if (settingsIdMap.isEmpty()) {
qWarning() << "No data for code style settings list" << i << "found!"; qWarning() << "No data for code style settings list" << i << "found!";
continue; continue;
} }
Id languageId = Id::fromSetting(settingsIdMap.value("language")); Id languageId = Id::fromSetting(settingsIdMap.value("language"));
Store value = settingsIdMap.value("value").value<Store>(); Store value = storeFromVariant(settingsIdMap.value("value"));
ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId); ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId);
if (preferences) if (preferences)
preferences->fromMap(value); preferences->fromMap(value);

View File

@@ -52,7 +52,7 @@ public:
void ExtraAbi::load() void ExtraAbi::load()
{ {
AbiFlavorAccessor accessor; AbiFlavorAccessor accessor;
const Store data = accessor.restoreSettings(Core::ICore::dialogParent()).value("Flavors").value<Store>(); const Store data = storeFromVariant(accessor.restoreSettings(Core::ICore::dialogParent()).value("Flavors"));
for (auto it = data.constBegin(); it != data.constEnd(); ++it) { for (auto it = data.constBegin(); it != data.constEnd(); ++it) {
const Key flavor = it.key(); const Key flavor = it.key();
if (flavor.isEmpty()) if (flavor.isEmpty())

View File

@@ -146,7 +146,7 @@ Kit::Kit(const Store &data)
if (it != data.constEnd()) if (it != data.constEnd())
d->m_irrelevantAspects = transform<QSet<Id>>(it.value().toList(), &Id::fromSetting); d->m_irrelevantAspects = transform<QSet<Id>>(it.value().toList(), &Id::fromSetting);
Store extra = data.value(DATA_KEY).value<Store>(); Store extra = storeFromVariant(data.value(DATA_KEY));
d->m_data.clear(); // remove default values d->m_data.clear(); // remove default values
const Store::ConstIterator cend = extra.constEnd(); const Store::ConstIterator cend = extra.constEnd();
for (Store::ConstIterator it = extra.constBegin(); it != cend; ++it) for (Store::ConstIterator it = extra.constBegin(); it != cend; ++it)
@@ -518,7 +518,7 @@ Store Kit::toMap() const
const IdVariantConstIt cend = d->m_data.constEnd(); const IdVariantConstIt cend = d->m_data.constEnd();
for (IdVariantConstIt it = d->m_data.constBegin(); it != cend; ++it) for (IdVariantConstIt it = d->m_data.constBegin(); it != cend; ++it)
extra.insert(keyFromString(QString::fromLatin1(it.key().name().constData())), it.value()); extra.insert(keyFromString(QString::fromLatin1(it.key().name().constData())), it.value());
data.insert(DATA_KEY, QVariant::fromValue(extra)); data.insert(DATA_KEY, variantFromStore(extra));
return data; return data;
} }

View File

@@ -448,7 +448,7 @@ void KitManager::saveKits()
Store tmp = k->toMap(); Store tmp = k->toMap();
if (tmp.isEmpty()) if (tmp.isEmpty())
continue; continue;
data.insert(KIT_DATA_KEY + Key::number(count), QVariant::fromValue(tmp)); data.insert(KIT_DATA_KEY + Key::number(count), variantFromStore(tmp));
++count; ++count;
} }
data.insert(KIT_COUNT_KEY, count); data.insert(KIT_COUNT_KEY, count);
@@ -518,7 +518,7 @@ static KitList restoreKitsHelper(const FilePath &fileName)
if (!data.contains(key)) if (!data.contains(key))
break; break;
const Store stMap = data.value(key).value<Store>(); const Store stMap = storeFromVariant(data.value(key));
auto k = std::make_unique<Kit>(stMap); auto k = std::make_unique<Kit>(stMap);
if (k->id().isValid()) { if (k->id().isValid()) {

View File

@@ -698,11 +698,11 @@ void Project::toMap(Store &map) const
map.insert(ACTIVE_TARGET_KEY, ts.indexOf(d->m_activeTarget)); map.insert(ACTIVE_TARGET_KEY, ts.indexOf(d->m_activeTarget));
map.insert(TARGET_COUNT_KEY, ts.size()); map.insert(TARGET_COUNT_KEY, ts.size());
for (int i = 0; i < ts.size(); ++i) for (int i = 0; i < ts.size(); ++i)
map.insert(TARGET_KEY_PREFIX + Key::number(i), QVariant::fromValue(ts.at(i)->toMap())); map.insert(TARGET_KEY_PREFIX + Key::number(i), variantFromStore(ts.at(i)->toMap()));
map.insert(EDITOR_SETTINGS_KEY, QVariant::fromValue(d->m_editorConfiguration.toMap())); map.insert(EDITOR_SETTINGS_KEY, variantFromStore(d->m_editorConfiguration.toMap()));
if (!d->m_pluginSettings.isEmpty()) if (!d->m_pluginSettings.isEmpty())
map.insert(PLUGIN_SETTINGS_KEY, QVariant::fromValue(d->m_pluginSettings)); map.insert(PLUGIN_SETTINGS_KEY, variantFromStore(d->m_pluginSettings));
} }
/*! /*!
@@ -768,12 +768,12 @@ Project::RestoreResult Project::fromMap(const Store &map, QString *errorMessage)
{ {
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
if (map.contains(EDITOR_SETTINGS_KEY)) { if (map.contains(EDITOR_SETTINGS_KEY)) {
Store values(map.value(EDITOR_SETTINGS_KEY).value<Store>()); Store values = storeFromVariant(map.value(EDITOR_SETTINGS_KEY));
d->m_editorConfiguration.fromMap(values); d->m_editorConfiguration.fromMap(values);
} }
if (map.contains(PLUGIN_SETTINGS_KEY)) if (map.contains(PLUGIN_SETTINGS_KEY))
d->m_pluginSettings = map.value(PLUGIN_SETTINGS_KEY).value<Store>(); d->m_pluginSettings = storeFromVariant(map.value(PLUGIN_SETTINGS_KEY));
bool ok; bool ok;
int maxI(map.value(TARGET_COUNT_KEY, 0).toInt(&ok)); int maxI(map.value(TARGET_COUNT_KEY, 0).toInt(&ok));
@@ -805,7 +805,7 @@ void Project::createTargetFromMap(const Store &map, int index)
if (!map.contains(key)) if (!map.contains(key))
return; return;
const Store targetMap = map.value(key).value<Store>(); const Store targetMap = storeFromVariant(map.value(key));
Id id = idFromMap(targetMap); Id id = idFromMap(targetMap);
if (target(id)) { if (target(id)) {

View File

@@ -57,7 +57,7 @@ void ProjectCommentsSettings::loadSettings()
if (!entry.isValid()) if (!entry.isValid())
return; return;
const Store data = entry.value<Store>(); const Store data = storeFromVariant(entry);
m_useGlobalSettings = data.value(kUseGlobalKey, true).toBool(); m_useGlobalSettings = data.value(kUseGlobalKey, true).toBool();
m_customSettings.enableDoxygen = data.value(CommentsSettings::enableDoxygenSettingsKey(), m_customSettings.enableDoxygen = data.value(CommentsSettings::enableDoxygenSettingsKey(),
m_customSettings.enableDoxygen).toBool(); m_customSettings.enableDoxygen).toBool();
@@ -87,7 +87,7 @@ void ProjectCommentsSettings::saveSettings()
data.insert(CommentsSettings::generateBriefSettingsKey(), m_customSettings.generateBrief); data.insert(CommentsSettings::generateBriefSettingsKey(), m_customSettings.generateBrief);
data.insert(CommentsSettings::leadingAsterisksSettingsKey(), m_customSettings.leadingAsterisks); data.insert(CommentsSettings::leadingAsterisksSettingsKey(), m_customSettings.leadingAsterisks);
data.insert(CommentsSettings::commandPrefixKey(), int(m_customSettings.commandPrefix)); data.insert(CommentsSettings::commandPrefixKey(), int(m_customSettings.commandPrefix));
m_project->setNamedSettings(CommentsSettings::mainSettingsKey(), QVariant::fromValue(data)); m_project->setNamedSettings(CommentsSettings::mainSettingsKey(), variantFromStore(data));
} }
class ProjectCommentsSettingsWidget::Private class ProjectCommentsSettingsWidget::Private

View File

@@ -1702,8 +1702,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
const int customParserCount = s->value(Constants::CUSTOM_PARSER_COUNT_KEY).toInt(); const int customParserCount = s->value(Constants::CUSTOM_PARSER_COUNT_KEY).toInt();
for (int i = 0; i < customParserCount; ++i) { for (int i = 0; i < customParserCount; ++i) {
CustomParserSettings settings; CustomParserSettings settings;
settings.fromMap(s->value(Constants::CUSTOM_PARSER_PREFIX_KEY settings.fromMap(storeFromVariant(
+ Key::number(i)).value<Store>()); s->value(Constants::CUSTOM_PARSER_PREFIX_KEY + Key::number(i))));
dd->m_customParsers << settings; dd->m_customParsers << settings;
} }
@@ -2279,7 +2279,7 @@ void ProjectExplorerPluginPrivate::savePersistentSettings()
s->setValueWithDefault(Constants::CUSTOM_PARSER_COUNT_KEY, int(dd->m_customParsers.count()), 0); s->setValueWithDefault(Constants::CUSTOM_PARSER_COUNT_KEY, int(dd->m_customParsers.count()), 0);
for (int i = 0; i < dd->m_customParsers.count(); ++i) { for (int i = 0; i < dd->m_customParsers.count(); ++i) {
s->setValue(Constants::CUSTOM_PARSER_PREFIX_KEY + Key::number(i), s->setValue(Constants::CUSTOM_PARSER_PREFIX_KEY + Key::number(i),
QVariant::fromValue(dd->m_customParsers.at(i).toMap())); variantFromStore(dd->m_customParsers.at(i).toMap()));
} }
} }

View File

@@ -605,7 +605,7 @@ Store Target::toMap() const
for (int i = 0; i < bcs.size(); ++i) { for (int i = 0; i < bcs.size(); ++i) {
Store data; Store data;
bcs.at(i)->toMap(data); bcs.at(i)->toMap(data);
map.insert(BC_KEY_PREFIX + Key::number(i), QVariant::fromValue(data)); map.insert(BC_KEY_PREFIX + Key::number(i), variantFromStore(data));
} }
const QList<DeployConfiguration *> dcs = deployConfigurations(); const QList<DeployConfiguration *> dcs = deployConfigurations();
@@ -614,7 +614,7 @@ Store Target::toMap() const
for (int i = 0; i < dcs.size(); ++i) { for (int i = 0; i < dcs.size(); ++i) {
Store data; Store data;
dcs.at(i)->toMap(data); dcs.at(i)->toMap(data);
map.insert(DC_KEY_PREFIX + Key::number(i), QVariant::fromValue(data)); map.insert(DC_KEY_PREFIX + Key::number(i), variantFromStore(data));
} }
const QList<RunConfiguration *> rcs = runConfigurations(); const QList<RunConfiguration *> rcs = runConfigurations();
@@ -623,11 +623,11 @@ Store Target::toMap() const
for (int i = 0; i < rcs.size(); ++i) { for (int i = 0; i < rcs.size(); ++i) {
Store data; Store data;
rcs.at(i)->toMap(data); rcs.at(i)->toMap(data);
map.insert(RC_KEY_PREFIX + Key::number(i), QVariant::fromValue(data)); map.insert(RC_KEY_PREFIX + Key::number(i), variantFromStore(data));
} }
if (!d->m_pluginSettings.isEmpty()) if (!d->m_pluginSettings.isEmpty())
map.insert(PLUGIN_SETTINGS_KEY, QVariant::fromValue(d->m_pluginSettings)); map.insert(PLUGIN_SETTINGS_KEY, variantFromStore(d->m_pluginSettings));
return map; return map;
} }
@@ -903,7 +903,7 @@ bool Target::fromMap(const Store &map)
const Key key = BC_KEY_PREFIX + Key::number(i); const Key key = BC_KEY_PREFIX + Key::number(i);
if (!map.contains(key)) if (!map.contains(key))
return false; return false;
const Store valueMap = map.value(key).value<Store>(); const Store valueMap = storeFromVariant(map.value(key));
BuildConfiguration *bc = BuildConfigurationFactory::restore(this, valueMap); BuildConfiguration *bc = BuildConfigurationFactory::restore(this, valueMap);
if (!bc) { if (!bc) {
qWarning("No factory found to restore build configuration!"); qWarning("No factory found to restore build configuration!");
@@ -930,7 +930,7 @@ bool Target::fromMap(const Store &map)
const Key key = DC_KEY_PREFIX + Key::number(i); const Key key = DC_KEY_PREFIX + Key::number(i);
if (!map.contains(key)) if (!map.contains(key))
return false; return false;
Store valueMap = map.value(key).value<Store>(); Store valueMap = storeFromVariant(map.value(key));
DeployConfiguration *dc = DeployConfigurationFactory::restore(this, valueMap); DeployConfiguration *dc = DeployConfigurationFactory::restore(this, valueMap);
if (!dc) { if (!dc) {
Utils::Id id = idFromMap(valueMap); Utils::Id id = idFromMap(valueMap);
@@ -959,7 +959,7 @@ bool Target::fromMap(const Store &map)
return false; return false;
// Ignore missing RCs: We will just populate them using the default ones. // Ignore missing RCs: We will just populate them using the default ones.
Store valueMap = map.value(key).value<Store>(); Store valueMap = storeFromVariant(map.value(key));
RunConfiguration *rc = RunConfigurationFactory::restore(this, valueMap); RunConfiguration *rc = RunConfigurationFactory::restore(this, valueMap);
if (!rc) if (!rc)
continue; continue;
@@ -973,7 +973,7 @@ bool Target::fromMap(const Store &map)
} }
if (map.contains(PLUGIN_SETTINGS_KEY)) if (map.contains(PLUGIN_SETTINGS_KEY))
d->m_pluginSettings = map.value(PLUGIN_SETTINGS_KEY).value<Store>(); d->m_pluginSettings = storeFromVariant(map.value(PLUGIN_SETTINGS_KEY));
return true; return true;
} }

View File

@@ -738,14 +738,14 @@ bool BadToolchains::isBadToolchain(const FilePath &toolchain) const
QVariant BadToolchains::toVariant() const QVariant BadToolchains::toVariant() const
{ {
return Utils::transform<QVariantList>(toolchains, [](const BadToolchain &bdc) { return Utils::transform<QVariantList>(toolchains, [](const BadToolchain &bdc) {
return QVariant::fromValue(bdc.toMap()); return variantFromStore(bdc.toMap());
}); });
} }
BadToolchains BadToolchains::fromVariant(const QVariant &v) BadToolchains BadToolchains::fromVariant(const QVariant &v)
{ {
return Utils::transform<QList<BadToolchain>>(v.toList(), return Utils::transform<QList<BadToolchain>>(v.toList(),
[](const QVariant &e) { return BadToolchain::fromMap(e.value<Store>()); }); [](const QVariant &e) { return BadToolchain::fromMap(storeFromVariant(e)); });
} }
} // namespace ProjectExplorer } // namespace ProjectExplorer

View File

@@ -224,7 +224,7 @@ void ToolChainSettingsAccessor::saveToolChains(const Toolchains &toolchains, QWi
tc->toMap(tmp); tc->toMap(tmp);
if (tmp.isEmpty()) if (tmp.isEmpty())
continue; continue;
data.insert(TOOLCHAIN_DATA_KEY + Key::number(count), QVariant::fromValue(tmp)); data.insert(TOOLCHAIN_DATA_KEY + Key::number(count), variantFromStore(tmp));
++count; ++count;
} }
data.insert(TOOLCHAIN_COUNT_KEY, count); data.insert(TOOLCHAIN_COUNT_KEY, count);
@@ -245,7 +245,7 @@ Toolchains ToolChainSettingsAccessor::toolChains(const Store &data) const
if (!data.contains(key)) if (!data.contains(key))
break; break;
const Store tcMap = data.value(key).value<Store>(); const Store tcMap = storeFromVariant(data.value(key));
bool restored = false; bool restored = false;
const Utils::Id tcType = ToolChainFactory::typeIdFromMap(tcMap); const Utils::Id tcType = ToolChainFactory::typeIdFromMap(tcMap);

View File

@@ -405,7 +405,7 @@ Store UserFileAccessor::postprocessMerge(const Store &main,
const Store &secondary, const Store &secondary,
const Store &result) const const Store &result) const
{ {
project()->setProperty(SHARED_SETTINGS, QVariant::fromValue(secondary)); project()->setProperty(SHARED_SETTINGS, variantFromStore(secondary));
return MergingSettingsAccessor::postprocessMerge(main, secondary, result); return MergingSettingsAccessor::postprocessMerge(main, secondary, result);
} }
@@ -429,12 +429,12 @@ Store UserFileAccessor::preprocessReadSettings(const Store &data) const
Store UserFileAccessor::prepareToWriteSettings(const Store &data) const Store UserFileAccessor::prepareToWriteSettings(const Store &data) const
{ {
const Store tmp = MergingSettingsAccessor::prepareToWriteSettings(data); const Store tmp = MergingSettingsAccessor::prepareToWriteSettings(data);
const Store shared = retrieveSharedSettings().value<Store>(); const Store shared = storeFromVariant(retrieveSharedSettings());
Store result; Store result;
if (!shared.isEmpty()) { if (!shared.isEmpty()) {
KeyList stickyKeys; KeyList stickyKeys;
SettingsMergeFunction merge = userStickyTrackerFunction(stickyKeys); SettingsMergeFunction merge = userStickyTrackerFunction(stickyKeys);
result = mergeQVariantMaps(tmp, shared, merge).value<Store>(); result = storeFromVariant(mergeQVariantMaps(tmp, shared, merge));
result.insert(USER_STICKY_KEYS_KEY, stringsFromKeys(stickyKeys)); result.insert(USER_STICKY_KEYS_KEY, stringsFromKeys(stickyKeys));
} else { } else {
result = tmp; result = tmp;
@@ -454,7 +454,7 @@ Store UserFileVersion14Upgrader::upgrade(const Store &map)
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
if (it.value().typeId() == QVariant::Map) if (it.value().typeId() == QVariant::Map)
result.insert(it.key(), QVariant::fromValue(upgrade(it.value().value<Store>()))); result.insert(it.key(), variantFromStore(upgrade(storeFromVariant(it.value()))));
else if (it.key() == "AutotoolsProjectManager.AutotoolsBuildConfiguration.BuildDirectory" else if (it.key() == "AutotoolsProjectManager.AutotoolsBuildConfiguration.BuildDirectory"
|| it.key() == "CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory" || it.key() == "CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory"
|| it.key() == "GenericProjectManager.GenericBuildConfiguration.BuildDirectory" || it.key() == "GenericProjectManager.GenericBuildConfiguration.BuildDirectory"
@@ -490,11 +490,11 @@ UserFileVersion16Upgrader::OldStepMaps UserFileVersion16Upgrader::extractStepMap
result.defaultDisplayName = deployMap.value("ProjectExplorer.ProjectConfiguration.DefaultDisplayName").toString(); result.defaultDisplayName = deployMap.value("ProjectExplorer.ProjectConfiguration.DefaultDisplayName").toString();
result.displayName = deployMap.value("ProjectExplorer.ProjectConfiguration.DisplayName").toString(); result.displayName = deployMap.value("ProjectExplorer.ProjectConfiguration.DisplayName").toString();
const Key stepListKey = "ProjectExplorer.BuildConfiguration.BuildStepList.0"; const Key stepListKey = "ProjectExplorer.BuildConfiguration.BuildStepList.0";
Store stepListMap = deployMap.value(stepListKey).value<Store>(); Store stepListMap = storeFromVariant(deployMap.value(stepListKey));
int stepCount = stepListMap.value("ProjectExplorer.BuildStepList.StepsCount", 0).toInt(); int stepCount = stepListMap.value("ProjectExplorer.BuildStepList.StepsCount", 0).toInt();
Key stepKey = "ProjectExplorer.BuildStepList.Step."; Key stepKey = "ProjectExplorer.BuildStepList.Step.";
for (int i = 0; i < stepCount; ++i) { for (int i = 0; i < stepCount; ++i) {
Store stepMap = stepListMap.value(stepKey + Key::number(i)).value<Store>(); Store stepMap = storeFromVariant(stepListMap.value(stepKey + Key::number(i)));
const QString id = stepMap.value("ProjectExplorer.ProjectConfiguration.Id").toString(); const QString id = stepMap.value("ProjectExplorer.ProjectConfiguration.Id").toString();
if (id == "Qt4ProjectManager.AndroidDeployQtStep") if (id == "Qt4ProjectManager.AndroidDeployQtStep")
result.androidDeployQt = stepMap; result.androidDeployQt = stepMap;
@@ -510,16 +510,16 @@ UserFileVersion16Upgrader::OldStepMaps UserFileVersion16Upgrader::extractStepMap
Store UserFileVersion16Upgrader::removeAndroidPackageStep(Store deployMap) Store UserFileVersion16Upgrader::removeAndroidPackageStep(Store deployMap)
{ {
const Key stepListKey = "ProjectExplorer.BuildConfiguration.BuildStepList.0"; const Key stepListKey = "ProjectExplorer.BuildConfiguration.BuildStepList.0";
Store stepListMap = deployMap.value(stepListKey).value<Store>(); Store stepListMap = storeFromVariant(deployMap.value(stepListKey));
const Key stepCountKey = "ProjectExplorer.BuildStepList.StepsCount"; const Key stepCountKey = "ProjectExplorer.BuildStepList.StepsCount";
int stepCount = stepListMap.value(stepCountKey, 0).toInt(); int stepCount = stepListMap.value(stepCountKey, 0).toInt();
Key stepKey = "ProjectExplorer.BuildStepList.Step."; Key stepKey = "ProjectExplorer.BuildStepList.Step.";
int targetPosition = 0; int targetPosition = 0;
for (int sourcePosition = 0; sourcePosition < stepCount; ++sourcePosition) { for (int sourcePosition = 0; sourcePosition < stepCount; ++sourcePosition) {
Store stepMap = stepListMap.value(stepKey + Key::number(sourcePosition)).value<Store>(); Store stepMap = storeFromVariant(stepListMap.value(stepKey + Key::number(sourcePosition)));
if (stepMap.value("ProjectExplorer.ProjectConfiguration.Id").toString() if (stepMap.value("ProjectExplorer.ProjectConfiguration.Id").toString()
!= "Qt4ProjectManager.AndroidPackageInstallationStep") { != "Qt4ProjectManager.AndroidPackageInstallationStep") {
stepListMap.insert(stepKey + Key::number(targetPosition), QVariant::fromValue(stepMap)); stepListMap.insert(stepKey + Key::number(targetPosition), variantFromStore(stepMap));
++targetPosition; ++targetPosition;
} }
} }
@@ -529,7 +529,7 @@ Store UserFileVersion16Upgrader::removeAndroidPackageStep(Store deployMap)
for (int i = targetPosition; i < stepCount; ++i) for (int i = targetPosition; i < stepCount; ++i)
stepListMap.remove(stepKey + Key::number(i)); stepListMap.remove(stepKey + Key::number(i));
deployMap.insert(stepListKey, QVariant::fromValue(stepListMap)); deployMap.insert(stepListKey, variantFromStore(stepListMap));
return deployMap; return deployMap;
} }
@@ -598,10 +598,10 @@ Store UserFileVersion16Upgrader::insertSteps(Store buildConfigurationMap,
androidBuildApkStep.insert(VerboseOutputKey, verbose); androidBuildApkStep.insert(VerboseOutputKey, verbose);
const Key buildStepKey = "ProjectExplorer.BuildStepList.Step."; const Key buildStepKey = "ProjectExplorer.BuildStepList.Step.";
buildStepListMap.insert(buildStepKey + Key::number(stepCount), QVariant::fromValue(androidPackageInstallStep)); buildStepListMap.insert(buildStepKey + Key::number(stepCount), variantFromStore(androidPackageInstallStep));
buildStepListMap.insert(buildStepKey + Key::number(stepCount + 1), QVariant::fromValue(androidBuildApkStep)); buildStepListMap.insert(buildStepKey + Key::number(stepCount + 1), variantFromStore(androidBuildApkStep));
buildConfigurationMap.insert(bslKey + Key::number(bslNumber), QVariant::fromValue(buildStepListMap)); buildConfigurationMap.insert(bslKey + Key::number(bslNumber), variantFromStore(buildStepListMap));
} }
if (policy == RenameBuildConfiguration) { if (policy == RenameBuildConfiguration) {
@@ -638,7 +638,7 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data)
for (int i = 0; i < targetCount; ++i) { for (int i = 0; i < targetCount; ++i) {
Key targetKey = "ProjectExplorer.Project.Target." + Key::number(i); Key targetKey = "ProjectExplorer.Project.Target." + Key::number(i);
Store targetMap = data.value(targetKey).value<Store>(); Store targetMap = storeFromVariant(data.value(targetKey));
const Key dcCountKey = "ProjectExplorer.Target.DeployConfigurationCount"; const Key dcCountKey = "ProjectExplorer.Target.DeployConfigurationCount";
int deployconfigurationCount = targetMap.value(dcCountKey).toInt(); int deployconfigurationCount = targetMap.value(dcCountKey).toInt();
@@ -651,7 +651,7 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data)
Key deployKey = "ProjectExplorer.Target.DeployConfiguration."; Key deployKey = "ProjectExplorer.Target.DeployConfiguration.";
for (int j = 0; j < deployconfigurationCount; ++j) { for (int j = 0; j < deployconfigurationCount; ++j) {
Store deployConfigurationMap Store deployConfigurationMap
= targetMap.value(deployKey + Key::number(j)).value<Store>(); = storeFromVariant(targetMap.value(deployKey + Key::number(j)));
OldStepMaps oldStep = extractStepMaps(deployConfigurationMap); OldStepMaps oldStep = extractStepMaps(deployConfigurationMap);
if (!oldStep.isEmpty()) { if (!oldStep.isEmpty()) {
oldSteps.append(oldStep); oldSteps.append(oldStep);
@@ -672,7 +672,7 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data)
Key bcKey = "ProjectExplorer.Target.BuildConfiguration."; Key bcKey = "ProjectExplorer.Target.BuildConfiguration.";
for (int j = 0; j < buildConfigurationCount; ++j) { for (int j = 0; j < buildConfigurationCount; ++j) {
Store oldBuildConfigurationMap = targetMap.value(bcKey + Key::number(j)).value<Store>(); Store oldBuildConfigurationMap = storeFromVariant(targetMap.value(bcKey + Key::number(j)));
oldBuildConfigurations.append(oldBuildConfigurationMap); oldBuildConfigurations.append(oldBuildConfigurationMap);
} }
@@ -691,8 +691,8 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data)
targetMap.insert(bcCountKey, newBuildConfigurations.size()); targetMap.insert(bcCountKey, newBuildConfigurations.size());
for (int j = 0; j < newBuildConfigurations.size(); ++j) for (int j = 0; j < newBuildConfigurations.size(); ++j)
targetMap.insert(bcKey + Key::number(j), QVariant::fromValue(newBuildConfigurations.at(j))); targetMap.insert(bcKey + Key::number(j), variantFromStore(newBuildConfigurations.at(j)));
result.insert(targetKey, QVariant::fromValue(targetMap)); result.insert(targetKey, variantFromStore(targetMap));
} }
return result; return result;
@@ -703,7 +703,7 @@ Store UserFileVersion17Upgrader::upgrade(const Store &map)
m_sticky = map.value(USER_STICKY_KEYS_KEY).toList(); m_sticky = map.value(USER_STICKY_KEYS_KEY).toList();
if (m_sticky.isEmpty()) if (m_sticky.isEmpty())
return map; return map;
return process(QVariant::fromValue(map)).value<Store>(); return storeFromVariant(process(variantFromStore(map)));
} }
QVariant UserFileVersion17Upgrader::process(const QVariant &entry) QVariant UserFileVersion17Upgrader::process(const QVariant &entry)
@@ -716,13 +716,13 @@ QVariant UserFileVersion17Upgrader::process(const QVariant &entry)
return result; return result;
} }
case QVariant::Map: { case QVariant::Map: {
Store result = entry.value<Store>(); Store result = storeFromVariant(entry);
for (Store::iterator i = result.begin(), end = result.end(); i != end; ++i) { for (Store::iterator i = result.begin(), end = result.end(); i != end; ++i) {
QVariant &v = i.value(); QVariant &v = i.value();
v = process(v); v = process(v);
} }
result.insert(USER_STICKY_KEYS_KEY, m_sticky); result.insert(USER_STICKY_KEYS_KEY, m_sticky);
return QVariant::fromValue(result); return variantFromStore(result);
} }
default: default:
return entry; return entry;
@@ -731,7 +731,7 @@ QVariant UserFileVersion17Upgrader::process(const QVariant &entry)
Store UserFileVersion18Upgrader::upgrade(const Store &map) Store UserFileVersion18Upgrader::upgrade(const Store &map)
{ {
return process(QVariant::fromValue(map)).value<Store>(); return storeFromVariant(process(variantFromStore(map)));
} }
QVariant UserFileVersion18Upgrader::process(const QVariant &entry) QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
@@ -740,7 +740,7 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
case QVariant::List: case QVariant::List:
return Utils::transform(entry.toList(), &UserFileVersion18Upgrader::process); return Utils::transform(entry.toList(), &UserFileVersion18Upgrader::process);
case QVariant::Map: { case QVariant::Map: {
Store map = entry.value<Store>(); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
Key key = it.key() == "AutotoolsProjectManager.MakeStep.AdditionalArguments" Key key = it.key() == "AutotoolsProjectManager.MakeStep.AdditionalArguments"
@@ -748,7 +748,7 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
: it.key(); : it.key();
result.insert(key, UserFileVersion18Upgrader::process(it.value())); result.insert(key, UserFileVersion18Upgrader::process(it.value()));
} }
return QVariant::fromValue(result); return variantFromStore(result);
} }
default: default:
return entry; return entry;
@@ -757,7 +757,7 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry)
Store UserFileVersion19Upgrader::upgrade(const Store &map) Store UserFileVersion19Upgrader::upgrade(const Store &map)
{ {
return process(QVariant::fromValue(map), KeyList()).value<Store>(); return storeFromVariant(process(variantFromStore(map), KeyList()));
} }
QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList &path) QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList &path)
@@ -797,7 +797,7 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList
return Utils::transform(entry.toList(), return Utils::transform(entry.toList(),
std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path)); std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path));
case QVariant::Map: { case QVariant::Map: {
Store map = entry.value<Store>(); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
Key key = it.key(); Key key = it.key();
@@ -820,7 +820,7 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList
} }
result.insert(key, value); result.insert(key, value);
}; };
return QVariant::fromValue(result); return variantFromStore(result);
} }
default: default:
return entry; return entry;
@@ -829,7 +829,7 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList
Store UserFileVersion20Upgrader::upgrade(const Store &map) Store UserFileVersion20Upgrader::upgrade(const Store &map)
{ {
return process(QVariant::fromValue(map)).value<Store>(); return storeFromVariant(process(variantFromStore(map)));
} }
QVariant UserFileVersion20Upgrader::process(const QVariant &entry) QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
@@ -838,7 +838,7 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
case QVariant::List: case QVariant::List:
return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process); return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process);
case QVariant::Map: { case QVariant::Map: {
Store map = entry.value<Store>(); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) {
Key key = it.key(); Key key = it.key();
@@ -849,7 +849,7 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
value = UserFileVersion20Upgrader::process(value); value = UserFileVersion20Upgrader::process(value);
result.insert(key, value); result.insert(key, value);
} }
return QVariant::fromValue(result); return variantFromStore(result);
} }
default: default:
return entry; return entry;
@@ -858,7 +858,7 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry)
Store UserFileVersion21Upgrader::upgrade(const Store &map) Store UserFileVersion21Upgrader::upgrade(const Store &map)
{ {
return process(QVariant::fromValue(map)).value<Store>(); return storeFromVariant(process(variantFromStore(map)));
} }
QVariant UserFileVersion21Upgrader::process(const QVariant &entry) QVariant UserFileVersion21Upgrader::process(const QVariant &entry)
@@ -867,17 +867,17 @@ QVariant UserFileVersion21Upgrader::process(const QVariant &entry)
case QVariant::List: case QVariant::List:
return Utils::transform(entry.toList(), &UserFileVersion21Upgrader::process); return Utils::transform(entry.toList(), &UserFileVersion21Upgrader::process);
case QVariant::Map: { case QVariant::Map: {
Store entryMap = entry.value<Store>(); Store entryMap = storeFromVariant(entry);
if (entryMap.value("ProjectExplorer.ProjectConfiguration.Id").toString() if (entryMap.value("ProjectExplorer.ProjectConfiguration.Id").toString()
== "DeployToGenericLinux") { == "DeployToGenericLinux") {
entryMap.insert("_checkMakeInstall", true); entryMap.insert("_checkMakeInstall", true);
return QVariant::fromValue(entryMap); return variantFromStore(entryMap);
} }
Store map = entry.value<Store>(); Store map = storeFromVariant(entry);
Store result; Store result;
for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) for (auto it = map.cbegin(), end = map.cend(); it != end; ++it)
result.insert(it.key(), UserFileVersion21Upgrader::process(it.value())); result.insert(it.key(), UserFileVersion21Upgrader::process(it.value()));
return QVariant::fromValue(result); return variantFromStore(result);
} }
default: default:
return entry; return entry;
@@ -898,7 +898,7 @@ public:
TestUserFileAccessor(Project *project) : UserFileAccessor(project) { } TestUserFileAccessor(Project *project) : UserFileAccessor(project) { }
void storeSharedSettings(const Store &data) const { m_storedSettings = data; } void storeSharedSettings(const Store &data) const { m_storedSettings = data; }
QVariant retrieveSharedSettings() const override { return QVariant::fromValue(m_storedSettings); } QVariant retrieveSharedSettings() const override { return variantFromStore(m_storedSettings); }
using UserFileAccessor::preprocessReadSettings; using UserFileAccessor::preprocessReadSettings;
using UserFileAccessor::prepareToWriteSettings; using UserFileAccessor::prepareToWriteSettings;

View File

@@ -442,7 +442,7 @@ public:
if (tmp.isEmpty()) if (tmp.isEmpty())
continue; continue;
data.insert(QNXConfigDataKey + Key::number(count), QVariant::fromValue(tmp)); data.insert(QNXConfigDataKey + Key::number(count), variantFromStore(tmp));
++count; ++count;
} }
@@ -464,7 +464,7 @@ public:
continue; continue;
QnxConfiguration config; QnxConfiguration config;
config.fromMap(data.value(key).value<Store>()); config.fromMap(storeFromVariant(data.value(key)));
m_configurations[config.m_envFile] = config; m_configurations[config.m_envFile] = config;
} }
} }

View File

@@ -187,7 +187,7 @@ static bool restoreQtVersions()
if (!ok || count < 0) if (!ok || count < 0)
continue; continue;
const Store qtversionMap = it.value().value<Store>(); const Store qtversionMap = storeFromVariant(it.value());
const QString type = qtversionMap.value(QTVERSION_TYPE_KEY).toString(); const QString type = qtversionMap.value(QTVERSION_TYPE_KEY).toString();
bool restored = false; bool restored = false;
@@ -261,7 +261,7 @@ void QtVersionManager::updateFromInstaller(bool emitSignal)
if (!ok || count < 0) if (!ok || count < 0)
continue; continue;
Store qtversionMap = it.value().value<Store>(); Store qtversionMap = storeFromVariant(it.value());
const QString type = qtversionMap.value(QTVERSION_TYPE_KEY).toString(); const QString type = qtversionMap.value(QTVERSION_TYPE_KEY).toString();
const QString autoDetectionSource = qtversionMap.value("autodetectionSource").toString(); const QString autoDetectionSource = qtversionMap.value("autodetectionSource").toString();
sdkVersions << autoDetectionSource; sdkVersions << autoDetectionSource;

View File

@@ -208,7 +208,7 @@ ICodeStylePreferences *CodeStylePool::loadCodeStyle(const FilePath &fileName)
if (m.contains(codeStyleDataKey)) { if (m.contains(codeStyleDataKey)) {
const QByteArray id = fileName.completeBaseName().toUtf8(); const QByteArray id = fileName.completeBaseName().toUtf8();
const QString displayName = reader.restoreValue(displayNameKey).toString(); const QString displayName = reader.restoreValue(displayNameKey).toString();
const Store map = reader.restoreValue(codeStyleDataKey).value<Store>(); const Store map = storeFromVariant(reader.restoreValue(codeStyleDataKey));
if (d->m_factory) { if (d->m_factory) {
codeStyle = d->m_factory->createCodeStyle(); codeStyle = d->m_factory->createCodeStyle();
codeStyle->setId(id); codeStyle->setId(id);
@@ -245,7 +245,7 @@ void CodeStylePool::exportCodeStyle(const FilePath &fileName, ICodeStylePreferen
const Store map = codeStyle->toMap(); const Store map = codeStyle->toMap();
const Store tmp = { const Store tmp = {
{displayNameKey, codeStyle->displayName()}, {displayNameKey, codeStyle->displayName()},
{codeStyleDataKey, QVariant::fromValue(map)} {codeStyleDataKey, variantFromStore(map)}
}; };
PersistentSettingsWriter writer(fileName, QLatin1String(codeStyleDocKey)); PersistentSettingsWriter writer(fileName, QLatin1String(codeStyleDocKey));
writer.save(tmp, Core::ICore::dialogParent()); writer.save(tmp, Core::ICore::dialogParent());