summaryrefslogtreecommitdiff
path: root/src/plugins/clangcodemodel/clangprojectsettings.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@qt.io>2018-01-23 11:13:14 +0100
committerNikolai Kosjar <nikolai.kosjar@qt.io>2018-01-29 08:13:51 +0000
commit49ba25e1838284038f5c37b5f9a1cb411cb4ab32 (patch)
tree781dd70c0fe09766d4c83b2af00e70e74bd21eda /src/plugins/clangcodemodel/clangprojectsettings.cpp
parent9b4688f1a4e88344b9a86abc58373b9e4c3ea9f8 (diff)
downloadqt-creator-49ba25e1838284038f5c37b5f9a1cb411cb4ab32.tar.gz
Clang: Let ClangProjectSettings announce changes
Change-Id: Idd6c91f5e8f0a73e4a15fe2f4b667302e6ee5e49 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/clangcodemodel/clangprojectsettings.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangprojectsettings.cpp43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/plugins/clangcodemodel/clangprojectsettings.cpp b/src/plugins/clangcodemodel/clangprojectsettings.cpp
index 2668ee3998..698447cc4b 100644
--- a/src/plugins/clangcodemodel/clangprojectsettings.cpp
+++ b/src/plugins/clangcodemodel/clangprojectsettings.cpp
@@ -42,6 +42,25 @@ static QString warningConfigIdKey()
static QString customCommandLineKey()
{ return QLatin1String("ClangCodeModel.CustomCommandLineKey"); }
+static bool useGlobalConfigFromSettings(ProjectExplorer::Project *project)
+{
+ const QVariant useGlobalConfigVariant = project->namedSettings(useGlobalConfigKey());
+ return useGlobalConfigVariant.isValid() ? useGlobalConfigVariant.toBool() : true;
+}
+
+static Core::Id warningConfigIdFromSettings(ProjectExplorer::Project *project)
+{
+ return Core::Id::fromSetting(project->namedSettings(warningConfigIdKey()));
+}
+
+static QStringList customCommandLineFromSettings(ProjectExplorer::Project *project)
+{
+ QStringList options = project->namedSettings(customCommandLineKey()).toStringList();
+ if (options.empty())
+ options = ClangProjectSettings::globalCommandLineOptions();
+ return options;
+}
+
ClangProjectSettings::ClangProjectSettings(ProjectExplorer::Project *project)
: m_project(project)
{
@@ -88,23 +107,27 @@ void ClangProjectSettings::setCommandLineOptions(const QStringList &options)
void ClangProjectSettings::load()
{
- const QVariant useGlobalConfigVariant = m_project->namedSettings(useGlobalConfigKey());
- const bool useGlobalConfig = useGlobalConfigVariant.isValid()
- ? useGlobalConfigVariant.toBool()
- : true;
-
- setUseGlobalConfig(useGlobalConfig);
- setWarningConfigId(Core::Id::fromSetting(m_project->namedSettings(warningConfigIdKey())));
- m_customCommandLineOptions = m_project->namedSettings(customCommandLineKey()).toStringList();
- if (m_customCommandLineOptions.empty())
- m_customCommandLineOptions = globalCommandLineOptions();
+ setUseGlobalConfig(useGlobalConfigFromSettings(m_project));
+ setWarningConfigId(warningConfigIdFromSettings(m_project));
+ m_customCommandLineOptions = customCommandLineFromSettings(m_project);
}
void ClangProjectSettings::store()
{
+ bool settingsChanged = false;
+ if (useGlobalConfig() != useGlobalConfigFromSettings(m_project))
+ settingsChanged = true;
+ if (warningConfigId() != warningConfigIdFromSettings(m_project))
+ settingsChanged = true;
+ if (commandLineOptions() != customCommandLineFromSettings(m_project))
+ settingsChanged = true;
+
m_project->setNamedSettings(useGlobalConfigKey(), useGlobalConfig());
m_project->setNamedSettings(warningConfigIdKey(), warningConfigId().toSetting());
m_project->setNamedSettings(customCommandLineKey(), m_customCommandLineOptions);
+
+ if (settingsChanged)
+ emit changed();
}
QStringList ClangProjectSettings::globalCommandLineOptions()