diff options
author | hjk <hjk@qt.io> | 2023-08-24 17:49:37 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2023-08-25 07:40:04 +0000 |
commit | e1e1af36d25b363850c970ff657bba910aaadd1d (patch) | |
tree | a13e49ef9f876bce0810c013d941b3778bb3d451 | |
parent | b9f9d2574e9e3b7f14af47af6a4180b77b78f726 (diff) |
Some more Key and Store
Change-Id: I78d2c7cfda1f8ece3c6fd9a7d741ec526a9aa6e4
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
-rw-r--r-- | src/plugins/bookmarks/bookmarkmanager.cpp | 4 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppcodemodelsettings.cpp | 79 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppcodestylepreferences.cpp | 6 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppcodestylesettings.cpp | 2 | ||||
-rw-r--r-- | src/plugins/nim/nimconstants.h | 4 | ||||
-rw-r--r-- | src/plugins/projectexplorer/msvctoolchain.cpp | 4 | ||||
-rw-r--r-- | src/plugins/projectexplorer/project.cpp | 14 | ||||
-rw-r--r-- | src/plugins/projectexplorer/project.h | 10 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectcommentssettings.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 6 | ||||
-rw-r--r-- | src/plugins/projectexplorer/userfileaccessor.cpp | 257 | ||||
-rw-r--r-- | src/plugins/texteditor/commentssettings.cpp | 11 | ||||
-rw-r--r-- | src/plugins/texteditor/commentssettings.h | 10 |
13 files changed, 206 insertions, 209 deletions
diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 83a2650b75..2fecba07fc 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -750,14 +750,14 @@ void BookmarkManager::saveBookmarks() for (const Bookmark *bookmark : std::as_const(m_bookmarksList)) list << bookmarkToString(bookmark); - SessionManager::setValue(QLatin1String("Bookmarks"), list); + SessionManager::setValue("Bookmarks", list); } /* Loads the bookmarks from the session settings. */ void BookmarkManager::loadBookmarks() { removeAllBookmarks(); - const QStringList &list = SessionManager::value(QLatin1String("Bookmarks")).toStringList(); + const QStringList &list = SessionManager::value("Bookmarks").toStringList(); for (const QString &bookmarkString : list) addBookmark(bookmarkString); diff --git a/src/plugins/cppeditor/cppcodemodelsettings.cpp b/src/plugins/cppeditor/cppcodemodelsettings.cpp index 318efd14e5..d7f4888b07 100644 --- a/src/plugins/cppeditor/cppcodemodelsettings.cpp +++ b/src/plugins/cppeditor/cppcodemodelsettings.cpp @@ -29,55 +29,36 @@ using namespace Utils; namespace CppEditor { -static Id initialClangDiagnosticConfigId() -{ return Constants::CPP_CLANG_DIAG_CONFIG_BUILDSYSTEM; } - +static Id initialClangDiagnosticConfigId() { return Constants::CPP_CLANG_DIAG_CONFIG_BUILDSYSTEM; } static CppCodeModelSettings::PCHUsage initialPchUsage() -{ return CppCodeModelSettings::PchUse_BuildSystem; } - -static QString enableLowerClazyLevelsKey() -{ return QLatin1String("enableLowerClazyLevels"); } - -static QString pchUsageKey() -{ return QLatin1String(Constants::CPPEDITOR_MODEL_MANAGER_PCH_USAGE); } - -static QString interpretAmbiguousHeadersAsCHeadersKey() -{ return QLatin1String(Constants::CPPEDITOR_INTERPRET_AMBIGIUOUS_HEADERS_AS_C_HEADERS); } - -static QString skipIndexingBigFilesKey() -{ return QLatin1String(Constants::CPPEDITOR_SKIP_INDEXING_BIG_FILES); } - -static QString ignoreFilesKey() -{ return QLatin1String(Constants::CPPEDITOR_IGNORE_FILES); } - -static QString ignorePatternKey() -{ return QLatin1String(Constants::CPPEDITOR_IGNORE_PATTERN); } - -static QString useBuiltinPreprocessorKey() -{ return QLatin1String(Constants::CPPEDITOR_USE_BUILTIN_PREPROCESSOR); } - -static QString indexerFileSizeLimitKey() -{ return QLatin1String(Constants::CPPEDITOR_INDEXER_FILE_SIZE_LIMIT); } - -static QString clangdSettingsKey() { return QLatin1String("ClangdSettings"); } -static QString useClangdKey() { return QLatin1String("UseClangdV7"); } -static QString clangdPathKey() { return QLatin1String("ClangdPath"); } -static QString clangdIndexingKey() { return QLatin1String("ClangdIndexing"); } -static QString clangdIndexingPriorityKey() { return QLatin1String("ClangdIndexingPriority"); } -static QString clangdHeaderSourceSwitchModeKey() { - return QLatin1String("ClangdHeaderSourceSwitchMode"); -} -static QString clangdHeaderInsertionKey() { return QLatin1String("ClangdHeaderInsertion"); } -static QString clangdThreadLimitKey() { return QLatin1String("ClangdThreadLimit"); } -static QString clangdDocumentThresholdKey() { return QLatin1String("ClangdDocumentThreshold"); } -static QString clangdSizeThresholdEnabledKey() { return QLatin1String("ClangdSizeThresholdEnabled"); } -static QString clangdSizeThresholdKey() { return QLatin1String("ClangdSizeThreshold"); } -static QString clangdUseGlobalSettingsKey() { return QLatin1String("useGlobalSettings"); } -static QString clangdblockIndexingSettingsKey() { return QLatin1String("blockIndexing"); } -static QString sessionsWithOneClangdKey() { return QLatin1String("SessionsWithOneClangd"); } -static QString diagnosticConfigIdKey() { return QLatin1String("diagnosticConfigId"); } -static QString checkedHardwareKey() { return QLatin1String("checkedHardware"); } -static QString completionResultsKey() { return QLatin1String("completionResults"); } + { return CppCodeModelSettings::PchUse_BuildSystem; } +static Key enableLowerClazyLevelsKey() { return "enableLowerClazyLevels"; } +static Key pchUsageKey() { return Constants::CPPEDITOR_MODEL_MANAGER_PCH_USAGE; } +static Key interpretAmbiguousHeadersAsCHeadersKey() + { return Constants::CPPEDITOR_INTERPRET_AMBIGIUOUS_HEADERS_AS_C_HEADERS; } +static Key skipIndexingBigFilesKey() { return Constants::CPPEDITOR_SKIP_INDEXING_BIG_FILES; } +static Key ignoreFilesKey() { return Constants::CPPEDITOR_IGNORE_FILES; } +static Key ignorePatternKey() { return Constants::CPPEDITOR_IGNORE_PATTERN; } +static Key useBuiltinPreprocessorKey() { return Constants::CPPEDITOR_USE_BUILTIN_PREPROCESSOR; } +static Key indexerFileSizeLimitKey() { return Constants::CPPEDITOR_INDEXER_FILE_SIZE_LIMIT; } + +static Key clangdSettingsKey() { return "ClangdSettings"; } +static Key useClangdKey() { return "UseClangdV7"; } +static Key clangdPathKey() { return "ClangdPath"; } +static Key clangdIndexingKey() { return "ClangdIndexing"; } +static Key clangdIndexingPriorityKey() { return "ClangdIndexingPriority"; } +static Key clangdHeaderSourceSwitchModeKey() { return "ClangdHeaderSourceSwitchMode"; } +static Key clangdHeaderInsertionKey() { return "ClangdHeaderInsertion"; } +static Key clangdThreadLimitKey() { return "ClangdThreadLimit"; } +static Key clangdDocumentThresholdKey() { return "ClangdDocumentThreshold"; } +static Key clangdSizeThresholdEnabledKey() { return "ClangdSizeThresholdEnabled"; } +static Key clangdSizeThresholdKey() { return "ClangdSizeThreshold"; } +static Key clangdUseGlobalSettingsKey() { return "useGlobalSettings"; } +static Key clangdblockIndexingSettingsKey() { return "blockIndexing"; } +static Key sessionsWithOneClangdKey() { return "SessionsWithOneClangd"; } +static Key diagnosticConfigIdKey() { return "diagnosticConfigId"; } +static Key checkedHardwareKey() { return "checkedHardware"; } +static Key completionResultsKey() { return "completionResults"; } static FilePath g_defaultClangdFilePath; static FilePath fallbackClangdFilePath() @@ -425,7 +406,7 @@ void ClangdSettings::loadSettings() m_data.customDiagnosticConfigs = diagnosticConfigsFromSettings(settings); // Pre-8.0 compat - static const QString oldKey("ClangDiagnosticConfig"); + static const Key oldKey("ClangDiagnosticConfig"); const QVariant configId = settings->value(oldKey); if (configId.isValid()) { m_data.diagnosticConfigId = Id::fromSetting(configId); diff --git a/src/plugins/cppeditor/cppcodestylepreferences.cpp b/src/plugins/cppeditor/cppcodestylepreferences.cpp index c6b497e021..59d2bd232f 100644 --- a/src/plugins/cppeditor/cppcodestylepreferences.cpp +++ b/src/plugins/cppeditor/cppcodestylepreferences.cpp @@ -69,11 +69,11 @@ void CppCodeStylePreferences::slotCurrentValueChanged(const QVariant &value) emit currentCodeStyleSettingsChanged(value.value<CppCodeStyleSettings>()); } -QVariantMap CppCodeStylePreferences::toMap() const +Store CppCodeStylePreferences::toMap() const { - QVariantMap map = ICodeStylePreferences::toMap(); + Store map = ICodeStylePreferences::toMap(); if (!currentDelegate()) { - const QVariantMap dataMap = m_data.toMap(); + const Store dataMap = m_data.toMap(); for (auto it = dataMap.begin(), end = dataMap.end(); it != end; ++it) map.insert(it.key(), it.value()); } diff --git a/src/plugins/cppeditor/cppcodestylesettings.cpp b/src/plugins/cppeditor/cppcodestylesettings.cpp index 2e04d3caa4..557940f766 100644 --- a/src/plugins/cppeditor/cppcodestylesettings.cpp +++ b/src/plugins/cppeditor/cppcodestylesettings.cpp @@ -48,7 +48,7 @@ namespace CppEditor { CppCodeStyleSettings::CppCodeStyleSettings() = default; -QVariantMap CppCodeStyleSettings::toMap() const +Store CppCodeStyleSettings::toMap() const { return { {indentBlockBracesKey, indentBlockBraces}, diff --git a/src/plugins/nim/nimconstants.h b/src/plugins/nim/nimconstants.h index 868fb0b96e..3c0b6f4cb3 100644 --- a/src/plugins/nim/nimconstants.h +++ b/src/plugins/nim/nimconstants.h @@ -30,8 +30,8 @@ const char C_NIMBLEBUILDSTEP_ARGUMENTS[] = "Nim.NimbleBuildStep.Arguments"; // NimbleTaskStep const char C_NIMBLETASKSTEP_ID[] = "Nim.NimbleTaskStep"; -const QString C_NIMBLETASKSTEP_TASKNAME = QStringLiteral("Nim.NimbleTaskStep.TaskName"); -const QString C_NIMBLETASKSTEP_TASKARGS = QStringLiteral("Nim.NimbleTaskStep.TaskArgs"); +const char C_NIMBLETASKSTEP_TASKNAME[] = "Nim.NimbleTaskStep.TaskName"; +const char C_NIMBLETASKSTEP_TASKARGS[] = "Nim.NimbleTaskStep.TaskArgs"; // NimCompilerBuildStep const char C_NIMCOMPILERBUILDSTEP_ID[] = "Nim.NimCompilerBuildStep"; diff --git a/src/plugins/projectexplorer/msvctoolchain.cpp b/src/plugins/projectexplorer/msvctoolchain.cpp index ad73c5e041..d90f7d3d98 100644 --- a/src/plugins/projectexplorer/msvctoolchain.cpp +++ b/src/plugins/projectexplorer/msvctoolchain.cpp @@ -1721,9 +1721,9 @@ QList<OutputLineParser *> ClangClToolChain::createOutputParsers() const return {new ClangClParser}; } -static inline QString llvmDirKey() +static Key llvmDirKey() { - return QStringLiteral("ProjectExplorer.ClangClToolChain.LlvmDir"); + return "ProjectExplorer.ClangClToolChain.LlvmDir"; } void ClangClToolChain::toMap(Store &data) const diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index a41f9b0be5..170419d245 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -773,13 +773,13 @@ Project::RestoreResult Project::fromMap(const Store &map, QString *errorMessage) } if (map.contains(PLUGIN_SETTINGS_KEY)) - d->m_pluginSettings = map.value(PLUGIN_SETTINGS_KEY).toMap(); + d->m_pluginSettings = map.value(PLUGIN_SETTINGS_KEY).value<Store>(); bool ok; int maxI(map.value(TARGET_COUNT_KEY, 0).toInt(&ok)); if (!ok || maxI < 0) maxI = 0; - int active(map.value(ACTIVE_TARGET_KEY, 0).toInt(&ok)); + int active = map.value(ACTIVE_TARGET_KEY, 0).toInt(&ok); if (!ok || active < 0 || active >= maxI) active = 0; @@ -805,7 +805,7 @@ void Project::createTargetFromMap(const Store &map, int index) if (!map.contains(key)) return; - const Store targetMap = map.value(key).toMap(); + const Store targetMap = map.value(key).value<Store>(); Id id = idFromMap(targetMap); if (target(id)) { @@ -978,12 +978,12 @@ Context Project::projectLanguages() const return d->m_projectLanguages; } -QVariant Project::namedSettings(const QString &name) const +QVariant Project::namedSettings(const Key &name) const { return d->m_pluginSettings.value(name); } -void Project::setNamedSettings(const QString &name, const QVariant &value) +void Project::setNamedSettings(const Key &name, const QVariant &value) { if (value.isNull()) d->m_pluginSettings.remove(name); @@ -1075,12 +1075,12 @@ void Project::setCanBuildProducts() d->m_canBuildProducts = true; } -void Project::setExtraData(const QString &key, const QVariant &data) +void Project::setExtraData(const Key &key, const QVariant &data) { d->m_extraData.insert(key, data); } -QVariant Project::extraData(const QString &key) const +QVariant Project::extraData(const Key &key) const { return d->m_extraData.value(key); } diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index 468303670f..40b26d6faa 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -117,8 +117,8 @@ public: Core::Context projectContext() const; Core::Context projectLanguages() const; - QVariant namedSettings(const QString &name) const; - void setNamedSettings(const QString &name, const QVariant &value); + QVariant namedSettings(const Utils::Key &name) const; + void setNamedSettings(const Utils::Key &name, const QVariant &value); void setAdditionalEnvironment(const Utils::EnvironmentItems &envItems); Utils::EnvironmentItems additionalEnvironment() const; @@ -156,8 +156,8 @@ public: void setDisplayName(const QString &name); void setProjectLanguage(Utils::Id id, bool enabled); - void setExtraData(const QString &key, const QVariant &data); - QVariant extraData(const QString &key) const; + void setExtraData(const Utils::Key &key, const QVariant &data); + QVariant extraData(const Utils::Key &key) const; QStringList availableQmlPreviewTranslations(QString *errorMessage); @@ -206,7 +206,7 @@ signals: protected: virtual RestoreResult fromMap(const Utils::Store &map, QString *errorMessage); - void createTargetFromMap(const QVariantMap &map, int index); + void createTargetFromMap(const Utils::Store &map, int index); virtual bool setupTarget(Target *t); void setCanBuildProducts(); diff --git a/src/plugins/projectexplorer/projectcommentssettings.cpp b/src/plugins/projectexplorer/projectcommentssettings.cpp index 6d41244eea..57ced03d38 100644 --- a/src/plugins/projectexplorer/projectcommentssettings.cpp +++ b/src/plugins/projectexplorer/projectcommentssettings.cpp @@ -12,9 +12,11 @@ #include <QVBoxLayout> using namespace TextEditor; +using namespace Utils; namespace ProjectExplorer { namespace Internal { + const char kUseGlobalKey[] = "UseGlobalKey"; ProjectCommentsSettings::ProjectCommentsSettings(ProjectExplorer::Project *project) @@ -55,7 +57,7 @@ void ProjectCommentsSettings::loadSettings() if (!entry.isValid()) return; - const QVariantMap data = entry.toMap(); + const Store data = entry.value<Store>(); m_useGlobalSettings = data.value(kUseGlobalKey, true).toBool(); m_customSettings.enableDoxygen = data.value(CommentsSettings::enableDoxygenSettingsKey(), m_customSettings.enableDoxygen).toBool(); @@ -79,13 +81,13 @@ void ProjectCommentsSettings::saveSettings() return; } - QVariantMap data; + Store data; data.insert(kUseGlobalKey, m_useGlobalSettings); data.insert(CommentsSettings::enableDoxygenSettingsKey(), m_customSettings.enableDoxygen); data.insert(CommentsSettings::generateBriefSettingsKey(), m_customSettings.generateBrief); data.insert(CommentsSettings::leadingAsterisksSettingsKey(), m_customSettings.leadingAsterisks); data.insert(CommentsSettings::commandPrefixKey(), int(m_customSettings.commandPrefix)); - m_project->setNamedSettings(CommentsSettings::mainSettingsKey(), data); + m_project->setNamedSettings(CommentsSettings::mainSettingsKey(), QVariant::fromValue(data)); } class ProjectCommentsSettingsWidget::Private diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 55b4d28cc1..799f55ac17 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1703,7 +1703,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er for (int i = 0; i < customParserCount; ++i) { CustomParserSettings settings; settings.fromMap(s->value(Constants::CUSTOM_PARSER_PREFIX_KEY - + QString::number(i)).toMap()); + + Key::number(i)).value<Store>()); dd->m_customParsers << settings; } @@ -2278,8 +2278,8 @@ void ProjectExplorerPluginPrivate::savePersistentSettings() s->setValueWithDefault(Constants::CUSTOM_PARSER_COUNT_KEY, int(dd->m_customParsers.count()), 0); for (int i = 0; i < dd->m_customParsers.count(); ++i) { - s->setValue(Constants::CUSTOM_PARSER_PREFIX_KEY + QString::number(i), - dd->m_customParsers.at(i).toMap()); + s->setValue(Constants::CUSTOM_PARSER_PREFIX_KEY + Key::number(i), + QVariant::fromValue(dd->m_customParsers.at(i).toMap())); } } diff --git a/src/plugins/projectexplorer/userfileaccessor.cpp b/src/plugins/projectexplorer/userfileaccessor.cpp index 7163778ee6..a627e28d09 100644 --- a/src/plugins/projectexplorer/userfileaccessor.cpp +++ b/src/plugins/projectexplorer/userfileaccessor.cpp @@ -29,7 +29,7 @@ using namespace Utils; using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; -using StringVariantPair = std::pair<const QString, QVariant>; +using KeyVariantPair = std::pair<const Key, QVariant>; static QString userFileExtension() { @@ -121,7 +121,7 @@ public: UserFileVersion19Upgrader() : VersionUpgrader(19, "4.8-pre2") { } Store upgrade(const Store &map) final; - static QVariant process(const QVariant &entry, const QStringList &path); + static QVariant process(const QVariant &entry, const KeyList &path); }; // Version 20 renames "Qbs.Deploy" to "ProjectExplorer.DefaultDeployConfiguration" @@ -323,7 +323,7 @@ SettingsMergeResult UserFileAccessor::merge(const MergingSettingsAccessor::SettingsMergeData &global, const MergingSettingsAccessor::SettingsMergeData &local) const { - const KeyList stickyKeys = keyFromString(global.main.value(USER_STICKY_KEYS_KEY).toStringList()); + const KeyList stickyKeys = keysFromStrings(global.main.value(USER_STICKY_KEYS_KEY).toStringList()); const Key key = local.key; const QVariant mainValue = local.main.value(key); @@ -435,7 +435,7 @@ Store UserFileAccessor::prepareToWriteSettings(const Store &data) const KeyList stickyKeys; SettingsMergeFunction merge = userStickyTrackerFunction(stickyKeys); result = mergeQVariantMaps(tmp, shared, merge).value<Store>(); - result.insert(USER_STICKY_KEYS_KEY, stringFromKey(stickyKeys)); + result.insert(USER_STICKY_KEYS_KEY, stringsFromKeys(stickyKeys)); } else { result = tmp; } @@ -454,7 +454,7 @@ Store UserFileVersion14Upgrader::upgrade(const Store &map) Store result; for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { if (it.value().typeId() == QVariant::Map) - result.insert(it.key(), upgrade(it.value().value<Store>())); + result.insert(it.key(), QVariant::fromValue(upgrade(it.value().value<Store>()))); else if (it.key() == "AutotoolsProjectManager.AutotoolsBuildConfiguration.BuildDirectory" || it.key() == "CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory" || it.key() == "GenericProjectManager.GenericBuildConfiguration.BuildDirectory" @@ -511,15 +511,15 @@ Store UserFileVersion16Upgrader::removeAndroidPackageStep(Store deployMap) { const Key stepListKey = "ProjectExplorer.BuildConfiguration.BuildStepList.0"; Store stepListMap = deployMap.value(stepListKey).value<Store>(); - const QString stepCountKey = "ProjectExplorer.BuildStepList.StepsCount"; + const Key stepCountKey = "ProjectExplorer.BuildStepList.StepsCount"; int stepCount = stepListMap.value(stepCountKey, 0).toInt(); - QString stepKey = "ProjectExplorer.BuildStepList.Step."; + Key stepKey = "ProjectExplorer.BuildStepList.Step."; int targetPosition = 0; for (int sourcePosition = 0; sourcePosition < stepCount; ++sourcePosition) { - Store stepMap = stepListMap.value(stepKey + QString::number(sourcePosition)).value<Store>(); + Store stepMap = stepListMap.value(stepKey + Key::number(sourcePosition)).value<Store>(); if (stepMap.value("ProjectExplorer.ProjectConfiguration.Id").toString() != "Qt4ProjectManager.AndroidPackageInstallationStep") { - stepListMap.insert(stepKey + QString::number(targetPosition), stepMap); + stepListMap.insert(stepKey + Key::number(targetPosition), QVariant::fromValue(stepMap)); ++targetPosition; } } @@ -527,9 +527,9 @@ Store UserFileVersion16Upgrader::removeAndroidPackageStep(Store deployMap) stepListMap.insert(stepCountKey, targetPosition); for (int i = targetPosition; i < stepCount; ++i) - stepListMap.remove(stepKey + QString::number(i)); + stepListMap.remove(stepKey + Key::number(i)); - deployMap.insert(stepListKey, stepListMap); + deployMap.insert(stepListKey, QVariant::fromValue(stepListMap)); return deployMap; } @@ -537,17 +537,17 @@ Store UserFileVersion16Upgrader::insertSteps(Store buildConfigurationMap, const OldStepMaps &oldStepMap, NamePolicy policy) { - const QString bslCountKey = "ProjectExplorer.BuildConfiguration.BuildStepListCount"; + const Key bslCountKey = "ProjectExplorer.BuildConfiguration.BuildStepListCount"; int stepListCount = buildConfigurationMap.value(bslCountKey).toInt(); - const QString bslKey = "ProjectExplorer.BuildConfiguration.BuildStepList."; - const QString bslTypeKey = "ProjectExplorer.ProjectConfiguration.Id"; + const Key bslKey = "ProjectExplorer.BuildConfiguration.BuildStepList."; + const Key bslTypeKey = "ProjectExplorer.ProjectConfiguration.Id"; for (int bslNumber = 0; bslNumber < stepListCount; ++bslNumber) { - Store buildStepListMap = buildConfigurationMap.value(bslKey + QString::number(bslNumber)).value<Store>(); + Store buildStepListMap = buildConfigurationMap.value(bslKey + Key::number(bslNumber)).value<Store>(); if (buildStepListMap.value(bslTypeKey) != "ProjectExplorer.BuildSteps.Build") continue; - const QString bslStepCountKey = "ProjectExplorer.BuildStepList.StepsCount"; + const Key bslStepCountKey = "ProjectExplorer.BuildStepList.StepsCount"; int stepCount = buildStepListMap.value(bslStepCountKey).toInt(); buildStepListMap.insert(bslStepCountKey, stepCount + 2); @@ -556,10 +556,10 @@ Store UserFileVersion16Upgrader::insertSteps(Store buildConfigurationMap, Store androidBuildApkStep; // common settings of all buildsteps - const QString enabledKey = "ProjectExplorer.BuildStep.Enabled"; - const QString idKey = "ProjectExplorer.ProjectConfiguration.Id"; - const QString displayNameKey = "ProjectExplorer.ProjectConfiguration.DisplayName"; - const QString defaultDisplayNameKey = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName"; + const Key enabledKey = "ProjectExplorer.BuildStep.Enabled"; + const Key idKey = "ProjectExplorer.ProjectConfiguration.Id"; + const Key displayNameKey = "ProjectExplorer.ProjectConfiguration.DisplayName"; + const Key defaultDisplayNameKey = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName"; QString displayName = oldStepMap.androidPackageInstall.value(displayNameKey).toString(); QString defaultDisplayName = oldStepMap.androidPackageInstall.value(defaultDisplayNameKey).toString(); @@ -570,7 +570,7 @@ Store UserFileVersion16Upgrader::insertSteps(Store buildConfigurationMap, androidPackageInstallStep.insert(defaultDisplayNameKey, defaultDisplayName); androidPackageInstallStep.insert(enabledKey, enabled); - displayName = oldStepMap.androidDeployQt.value(displayName).toString(); + displayName = oldStepMap.androidDeployQt.value(keyFromString(displayName)).toString(); defaultDisplayName = oldStepMap.androidDeployQt.value(defaultDisplayNameKey).toString(); enabled = oldStepMap.androidDeployQt.value(enabledKey).toBool(); @@ -580,11 +580,11 @@ Store UserFileVersion16Upgrader::insertSteps(Store buildConfigurationMap, androidBuildApkStep.insert(enabledKey, enabled); // settings transferred from AndroidDeployQtStep to QmakeBuildApkStep - const QString ProFilePathForInputFile = "ProFilePathForInputFile"; - const QString DeployActionKey = "Qt4ProjectManager.AndroidDeployQtStep.DeployQtAction"; - const QString KeystoreLocationKey = "KeystoreLocation"; - const QString BuildTargetSdkKey = "BuildTargetSdk"; - const QString VerboseOutputKey = "VerboseOutput"; + const Key ProFilePathForInputFile = "ProFilePathForInputFile"; + const Key DeployActionKey = "Qt4ProjectManager.AndroidDeployQtStep.DeployQtAction"; + const Key KeystoreLocationKey = "KeystoreLocation"; + const Key BuildTargetSdkKey = "BuildTargetSdk"; + const Key VerboseOutputKey = "VerboseOutput"; QString inputFile = oldStepMap.androidDeployQt.value(ProFilePathForInputFile).toString(); int oldDeployAction = oldStepMap.androidDeployQt.value(DeployActionKey).toInt(); @@ -597,16 +597,16 @@ Store UserFileVersion16Upgrader::insertSteps(Store buildConfigurationMap, androidBuildApkStep.insert(BuildTargetSdkKey, buildTargetSdk); androidBuildApkStep.insert(VerboseOutputKey, verbose); - const QString buildStepKey = "ProjectExplorer.BuildStepList.Step."; - buildStepListMap.insert(buildStepKey + QString::number(stepCount), androidPackageInstallStep); - buildStepListMap.insert(buildStepKey + QString::number(stepCount + 1), androidBuildApkStep); + const Key buildStepKey = "ProjectExplorer.BuildStepList.Step."; + buildStepListMap.insert(buildStepKey + Key::number(stepCount), QVariant::fromValue(androidPackageInstallStep)); + buildStepListMap.insert(buildStepKey + Key::number(stepCount + 1), QVariant::fromValue(androidBuildApkStep)); - buildConfigurationMap.insert(bslKey + QString::number(bslNumber), buildStepListMap); + buildConfigurationMap.insert(bslKey + Key::number(bslNumber), QVariant::fromValue(buildStepListMap)); } if (policy == RenameBuildConfiguration) { - const QString displayNameKey = "ProjectExplorer.ProjectConfiguration.DisplayName"; - const QString defaultDisplayNameKey = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName"; + const Key displayNameKey = "ProjectExplorer.ProjectConfiguration.DisplayName"; + const Key defaultDisplayNameKey = "ProjectExplorer.ProjectConfiguration.DefaultDisplayName"; QString defaultDisplayName = buildConfigurationMap.value(defaultDisplayNameKey).toString(); QString displayName = buildConfigurationMap.value(displayNameKey).toString(); @@ -637,10 +637,10 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data) Store result = data; for (int i = 0; i < targetCount; ++i) { - QString targetKey = QLatin1String("ProjectExplorer.Project.Target.") + QString::number(i); + Key targetKey = "ProjectExplorer.Project.Target." + Key::number(i); Store targetMap = data.value(targetKey).value<Store>(); - const QString dcCountKey = "ProjectExplorer.Target.DeployConfigurationCount"; + const Key dcCountKey = "ProjectExplorer.Target.DeployConfigurationCount"; int deployconfigurationCount = targetMap.value(dcCountKey).toInt(); if (!deployconfigurationCount) // should never happen continue; @@ -648,31 +648,31 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data) QList<OldStepMaps> oldSteps; QList<Store> oldBuildConfigurations; - QString deployKey = "ProjectExplorer.Target.DeployConfiguration."; + Key deployKey = "ProjectExplorer.Target.DeployConfiguration."; for (int j = 0; j < deployconfigurationCount; ++j) { Store deployConfigurationMap - = targetMap.value(deployKey + QString::number(j)).value<Store>(); + = targetMap.value(deployKey + Key::number(j)).value<Store>(); OldStepMaps oldStep = extractStepMaps(deployConfigurationMap); if (!oldStep.isEmpty()) { oldSteps.append(oldStep); deployConfigurationMap = removeAndroidPackageStep(deployConfigurationMap); - targetMap.insert(deployKey + QString::number(j), deployConfigurationMap); + targetMap.insert(deployKey + Key::number(j), QVariant::fromValue(deployConfigurationMap)); } } if (oldSteps.isEmpty()) // no android target? continue; - const QString bcCountKey = "ProjectExplorer.Target.BuildConfigurationCount"; + const Key bcCountKey = "ProjectExplorer.Target.BuildConfigurationCount"; int buildConfigurationCount = targetMap.value(bcCountKey).toInt(); if (!buildConfigurationCount) // should never happen continue; - QString bcKey = "ProjectExplorer.Target.BuildConfiguration."; + Key bcKey = "ProjectExplorer.Target.BuildConfiguration."; for (int j = 0; j < buildConfigurationCount; ++j) { - Store oldBuildConfigurationMap = targetMap.value(bcKey + QString::number(j)).value<Store>(); + Store oldBuildConfigurationMap = targetMap.value(bcKey + Key::number(j)).value<Store>(); oldBuildConfigurations.append(oldBuildConfigurationMap); } @@ -691,8 +691,8 @@ Store UserFileVersion16Upgrader::upgrade(const Store &data) targetMap.insert(bcCountKey, newBuildConfigurations.size()); for (int j = 0; j < newBuildConfigurations.size(); ++j) - targetMap.insert(bcKey + QString::number(j), newBuildConfigurations.at(j)); - result.insert(targetKey, targetMap); + targetMap.insert(bcKey + Key::number(j), QVariant::fromValue(newBuildConfigurations.at(j))); + result.insert(targetKey, QVariant::fromValue(targetMap)); } return result; @@ -703,7 +703,7 @@ Store UserFileVersion17Upgrader::upgrade(const Store &map) m_sticky = map.value(USER_STICKY_KEYS_KEY).toList(); if (m_sticky.isEmpty()) return map; - return process(map).value<Store>(); + return process(QVariant::fromValue(map)).value<Store>(); } QVariant UserFileVersion17Upgrader::process(const QVariant &entry) @@ -722,7 +722,7 @@ QVariant UserFileVersion17Upgrader::process(const QVariant &entry) v = process(v); } result.insert(USER_STICKY_KEYS_KEY, m_sticky); - return result; + return QVariant::fromValue(result); } default: return entry; @@ -731,7 +731,7 @@ QVariant UserFileVersion17Upgrader::process(const QVariant &entry) Store UserFileVersion18Upgrader::upgrade(const Store &map) { - return process(map).value<Store>(); + return process(QVariant::fromValue(map)).value<Store>(); } QVariant UserFileVersion18Upgrader::process(const QVariant &entry) @@ -739,15 +739,17 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry) switch (entry.typeId()) { case QVariant::List: return Utils::transform(entry.toList(), &UserFileVersion18Upgrader::process); - case QVariant::Map: - return Utils::transform<QMap<QString, QVariant>>( - entry.value<Store>().toStdMap(), [](const StringVariantPair &item) -> StringVariantPair { - const QString key = (item.first - == "AutotoolsProjectManager.MakeStep.AdditionalArguments" - ? QString("AutotoolsProjectManager.MakeStep.MakeArguments") - : item.first); - return {key, UserFileVersion18Upgrader::process(item.second)}; - }); + case QVariant::Map: { + Store map = entry.value<Store>(); + Store result; + for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { + Key key = it.key() == "AutotoolsProjectManager.MakeStep.AdditionalArguments" + ? Key("AutotoolsProjectManager.MakeStep.MakeArguments") + : it.key(); + result.insert(key, UserFileVersion18Upgrader::process(it.value())); + } + return QVariant::fromValue(result); + } default: return entry; } @@ -755,64 +757,71 @@ QVariant UserFileVersion18Upgrader::process(const QVariant &entry) Store UserFileVersion19Upgrader::upgrade(const Store &map) { - return process(map, QStringList()).value<Store>(); + return process(QVariant::fromValue(map), KeyList()).value<Store>(); } -QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const QStringList &path) +QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const KeyList &path) { - static const QStringList argsKeys = {"Qt4ProjectManager.MaemoRunConfiguration.Arguments", - "CMakeProjectManager.CMakeRunConfiguration.Arguments", - "Ios.run_arguments", - "Nim.NimRunConfiguration.ArgumentAspect", - "ProjectExplorer.CustomExecutableRunConfiguration.Arguments", - "PythonEditor.RunConfiguration.Arguments", - "Qbs.RunConfiguration.CommandLineArguments", - "Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments", - "RemoteLinux.CustomRunConfig.Arguments", - "WinRtRunConfigurationArgumentsId", - "CommandLineArgs"}; - static const QStringList wdKeys = {"BareMetal.RunConfig.WorkingDirectory", - "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory", - "Nim.NimRunConfiguration.WorkingDirectoryAspect", - "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory", - "Qbs.RunConfiguration.WorkingDirectory", - "Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory", - "RemoteLinux.CustomRunConfig.WorkingDirectory", - "RemoteLinux.RunConfig.WorkingDirectory", - "WorkingDir"}; - static const QStringList termKeys = {"CMakeProjectManager.CMakeRunConfiguration.UseTerminal", - "Nim.NimRunConfiguration.TerminalAspect", - "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal", - "PythonEditor.RunConfiguration.UseTerminal", - "Qbs.RunConfiguration.UseTerminal", - "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"}; - static const QStringList libsKeys = {"Qbs.RunConfiguration.UsingLibraryPaths", - "QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath"}; - static const QStringList dyldKeys = {"Qbs.RunConfiguration.UseDyldImageSuffix", - "QmakeProjectManager.QmakeRunConfiguration.UseDyldImageSuffix"}; + static const KeyList argsKeys = {"Qt4ProjectManager.MaemoRunConfiguration.Arguments", + "CMakeProjectManager.CMakeRunConfiguration.Arguments", + "Ios.run_arguments", + "Nim.NimRunConfiguration.ArgumentAspect", + "ProjectExplorer.CustomExecutableRunConfiguration.Arguments", + "PythonEditor.RunConfiguration.Arguments", + "Qbs.RunConfiguration.CommandLineArguments", + "Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments", + "RemoteLinux.CustomRunConfig.Arguments", + "WinRtRunConfigurationArgumentsId", + "CommandLineArgs"}; + static const KeyList wdKeys = {"BareMetal.RunConfig.WorkingDirectory", + "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory", + "Nim.NimRunConfiguration.WorkingDirectoryAspect", + "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory", + "Qbs.RunConfiguration.WorkingDirectory", + "Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory", + "RemoteLinux.CustomRunConfig.WorkingDirectory", + "RemoteLinux.RunConfig.WorkingDirectory", + "WorkingDir"}; + static const KeyList termKeys = {"CMakeProjectManager.CMakeRunConfiguration.UseTerminal", + "Nim.NimRunConfiguration.TerminalAspect", + "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal", + "PythonEditor.RunConfiguration.UseTerminal", + "Qbs.RunConfiguration.UseTerminal", + "Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"}; + static const KeyList libsKeys = {"Qbs.RunConfiguration.UsingLibraryPaths", + "QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath"}; + static const KeyList dyldKeys = {"Qbs.RunConfiguration.UseDyldImageSuffix", + "QmakeProjectManager.QmakeRunConfiguration.UseDyldImageSuffix"}; switch (entry.typeId()) { case QVariant::List: return Utils::transform(entry.toList(), std::bind(&UserFileVersion19Upgrader::process, std::placeholders::_1, path)); - case QVariant::Map: - return Utils::transform<Store>(entry.value<Store>().toStdMap(), - [&](const StringVariantPair &item) -> StringVariantPair { + case QVariant::Map: { + Store map = entry.value<Store>(); + Store result; + for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { + Key key = it.key(); + QVariant value = it.value(); if (path.size() == 2 && path.at(1).startsWith("ProjectExplorer.Target.RunConfiguration.")) { - if (argsKeys.contains(item.first)) - return {"RunConfiguration.Arguments", item.second}; - if (wdKeys.contains(item.first)) - return {"RunConfiguration.WorkingDirectory", item.second}; - if (termKeys.contains(item.first)) - return {"RunConfiguration.UseTerminal", item.second}; - if (libsKeys.contains(item.first)) - return {"RunConfiguration.UseLibrarySearchPath", item.second}; - if (dyldKeys.contains(item.first)) - return {"RunConfiguration.UseDyldImageSuffix", item.second}; + if (argsKeys.contains(key)) + key = "RunConfiguration.Arguments"; + else if (wdKeys.contains(key)) + key = "RunConfiguration.WorkingDirectory"; + else if (termKeys.contains(key)) + key = "RunConfiguration.UseTerminal"; + else if (libsKeys.contains(key)) + key = "RunConfiguration.UseLibrarySearchPath"; + else if (dyldKeys.contains(key)) + key = "RunConfiguration.UseDyldImageSuffix"; + else + value = UserFileVersion19Upgrader::process(value, path + KeyList{key}); + } else { + value = UserFileVersion19Upgrader::process(value, path + KeyList{key}); } - QStringList newPath = path; - newPath.append(item.first); - return {item.first, UserFileVersion19Upgrader::process(item.second, newPath)}; - }); + result.insert(key, value); + }; + return QVariant::fromValue(result); + } default: return entry; } @@ -820,7 +829,7 @@ QVariant UserFileVersion19Upgrader::process(const QVariant &entry, const QString Store UserFileVersion20Upgrader::upgrade(const Store &map) { - return process(map).value<Store>(); + return process(QVariant::fromValue(map)).value<Store>(); } QVariant UserFileVersion20Upgrader::process(const QVariant &entry) @@ -828,17 +837,20 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry) switch (entry.typeId()) { case QVariant::List: return Utils::transform(entry.toList(), &UserFileVersion20Upgrader::process); - case QVariant::Map: - return Utils::transform<QMap<QString, QVariant>>( - entry.value<Store>().toStdMap(), [](const StringVariantPair &item) { - StringVariantPair res = {item.first, item.second}; - if (item.first == "ProjectExplorer.ProjectConfiguration.Id" - && item.second == "Qbs.Deploy") - res.second = QVariant("ProjectExplorer.DefaultDeployConfiguration"); - else - res.second = UserFileVersion20Upgrader::process(item.second); - return res; - }); + case QVariant::Map: { + Store map = entry.value<Store>(); + Store result; + for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) { + Key key = it.key(); + QVariant value = it.value(); + if (key == "ProjectExplorer.ProjectConfiguration.Id" && value == "Qbs.Deploy") + value = "ProjectExplorer.DefaultDeployConfiguration"; + else + value = UserFileVersion20Upgrader::process(value); + result.insert(key, value); + } + return QVariant::fromValue(result); + } default: return entry; } @@ -846,7 +858,7 @@ QVariant UserFileVersion20Upgrader::process(const QVariant &entry) Store UserFileVersion21Upgrader::upgrade(const Store &map) { - return process(map).value<Store>(); + return process(QVariant::fromValue(map)).value<Store>(); } QVariant UserFileVersion21Upgrader::process(const QVariant &entry) @@ -859,12 +871,13 @@ QVariant UserFileVersion21Upgrader::process(const QVariant &entry) if (entryMap.value("ProjectExplorer.ProjectConfiguration.Id").toString() == "DeployToGenericLinux") { entryMap.insert("_checkMakeInstall", true); - return entryMap; + return QVariant::fromValue(entryMap); } - return Utils::transform<Store>( - entryMap.toStdMap(), [](const StringVariantPair &item) -> StringVariantPair{ - return {item.first, UserFileVersion21Upgrader::process(item.second)}; - }); + Store map = entry.value<Store>(); + Store result; + for (auto it = map.cbegin(), end = map.cend(); it != end; ++it) + result.insert(it.key(), UserFileVersion21Upgrader::process(it.value())); + return QVariant::fromValue(result); } default: return entry; @@ -885,7 +898,7 @@ public: TestUserFileAccessor(Project *project) : UserFileAccessor(project) { } void storeSharedSettings(const Store &data) const { m_storedSettings = data; } - QVariant retrieveSharedSettings() const override { return m_storedSettings; } + QVariant retrieveSharedSettings() const override { return QVariant::fromValue(m_storedSettings); } using UserFileAccessor::preprocessReadSettings; using UserFileAccessor::prepareToWriteSettings; diff --git a/src/plugins/texteditor/commentssettings.cpp b/src/plugins/texteditor/commentssettings.cpp index 441d01c353..533b9bab44 100644 --- a/src/plugins/texteditor/commentssettings.cpp +++ b/src/plugins/texteditor/commentssettings.cpp @@ -16,6 +16,7 @@ #include <QSettings> using namespace Layouting; +using namespace Utils; namespace TextEditor { @@ -35,11 +36,11 @@ void CommentsSettings::setData(const Data &data) instance().save(); } -QString CommentsSettings::mainSettingsKey() { return kDocumentationCommentsGroup; } -QString CommentsSettings::enableDoxygenSettingsKey() { return kEnableDoxygenBlocks; } -QString CommentsSettings::generateBriefSettingsKey() { return kGenerateBrief; } -QString CommentsSettings::leadingAsterisksSettingsKey() { return kAddLeadingAsterisks; } -QString CommentsSettings::commandPrefixKey() { return kCommandPrefix; } +Key CommentsSettings::mainSettingsKey() { return kDocumentationCommentsGroup; } +Key CommentsSettings::enableDoxygenSettingsKey() { return kEnableDoxygenBlocks; } +Key CommentsSettings::generateBriefSettingsKey() { return kGenerateBrief; } +Key CommentsSettings::leadingAsterisksSettingsKey() { return kAddLeadingAsterisks; } +Key CommentsSettings::commandPrefixKey() { return kCommandPrefix; } CommentsSettings::CommentsSettings() { diff --git a/src/plugins/texteditor/commentssettings.h b/src/plugins/texteditor/commentssettings.h index 7206a8ccc4..fd37a8e5b7 100644 --- a/src/plugins/texteditor/commentssettings.h +++ b/src/plugins/texteditor/commentssettings.h @@ -26,11 +26,11 @@ public: static Data data() { return instance().m_data; } static void setData(const Data &data); - static QString mainSettingsKey(); - static QString enableDoxygenSettingsKey(); - static QString generateBriefSettingsKey(); - static QString leadingAsterisksSettingsKey(); - static QString commandPrefixKey(); + static Utils::Key mainSettingsKey(); + static Utils::Key enableDoxygenSettingsKey(); + static Utils::Key generateBriefSettingsKey(); + static Utils::Key leadingAsterisksSettingsKey(); + static Utils::Key commandPrefixKey(); private: CommentsSettings(); |