summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcodemodelsettingspage.cpp
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2017-11-02 16:26:17 +0100
committerIvan Donchevskii <ivan.donchevskii@qt.io>2017-11-16 11:05:21 +0000
commit8eececaa96153c69c11ac42c4b09e5b1944f9d4e (patch)
treef6eca7fb0a3e3d850420c26ccbeafced62efd429 /src/plugins/cpptools/cppcodemodelsettingspage.cpp
parentcdaa4aee1a5caa411b4f790ce1d6834da281eb54 (diff)
downloadqt-creator-8eececaa96153c69c11ac42c4b09e5b1944f9d4e.tar.gz
Clang: add clang plugins checks to code model settings
Add UI controls to change settings and apply them together with warnings and command line options. Current settings are not very flexible but should be easy to test and use without reading tidy/clazy help. Change-Id: I1ca6b49a42a1169b34a703dd50de0bbc105df28f Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppcodemodelsettingspage.cpp')
-rw-r--r--src/plugins/cpptools/cppcodemodelsettingspage.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.cpp b/src/plugins/cpptools/cppcodemodelsettingspage.cpp
index e6af115aed..d9bc8c9370 100644
--- a/src/plugins/cpptools/cppcodemodelsettingspage.cpp
+++ b/src/plugins/cpptools/cppcodemodelsettingspage.cpp
@@ -29,6 +29,8 @@
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
#include "ui_cppcodemodelsettingspage.h"
+#include "ui_clazychecks.h"
+#include "ui_tidychecks.h"
#include <coreplugin/icore.h>
#include <utils/algorithm.h>
@@ -84,6 +86,65 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets()
diagnosticConfigsModel,
m_settings->clangDiagnosticConfigId());
m_ui->clangSettingsGroupBox->layout()->addWidget(m_clangDiagnosticConfigsWidget);
+
+ setupPluginsWidgets();
+}
+
+void CppCodeModelSettingsWidget::setupPluginsWidgets()
+{
+ m_clazyChecks.reset(new CppTools::Ui::ClazyChecks);
+ m_clazyChecksWidget = new QWidget();
+ m_clazyChecks->setupUi(m_clazyChecksWidget);
+
+ m_tidyChecks.reset(new CppTools::Ui::TidyChecks);
+ m_tidyChecksWidget = new QWidget();
+ m_tidyChecks->setupUi(m_tidyChecksWidget);
+
+ m_ui->pluginChecks->layout()->addWidget(m_tidyChecksWidget);
+ m_ui->pluginChecks->layout()->addWidget(m_clazyChecksWidget);
+ m_clazyChecksWidget->setVisible(false);
+ connect(m_ui->pluginSelection,
+ static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
+ [this](int index) {
+ (index ? m_clazyChecksWidget : m_tidyChecksWidget)->setVisible(true);
+ (!index ? m_clazyChecksWidget : m_tidyChecksWidget)->setVisible(false);
+ });
+
+ setupTidyChecks();
+ setupClazyChecks();
+}
+
+void CppCodeModelSettingsWidget::setupTidyChecks()
+{
+ m_currentTidyChecks = m_settings->tidyChecks();
+ for (QObject *child : m_tidyChecksWidget->children()) {
+ auto *check = qobject_cast<QCheckBox *>(child);
+ if (!check)
+ continue;
+ if (m_currentTidyChecks.indexOf(check->text()) != -1)
+ check->setChecked(true);
+ connect(check, &QCheckBox::clicked, [this, check](bool checked) {
+ const QString prefix = check->text();
+ checked ? m_currentTidyChecks.append(',' + prefix)
+ : m_currentTidyChecks.remove(',' + prefix);
+ });
+ }
+}
+
+void CppCodeModelSettingsWidget::setupClazyChecks()
+{
+ m_currentClazyChecks = m_settings->clazyChecks();
+ if (!m_currentClazyChecks.isEmpty())
+ m_clazyChecks->clazyLevel->setCurrentText(m_currentClazyChecks);
+ connect(m_clazyChecks->clazyLevel,
+ static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),
+ [this](int index) {
+ if (index == 0) {
+ m_currentClazyChecks.clear();
+ return;
+ }
+ m_currentClazyChecks = m_clazyChecks->clazyLevel->itemText(index);
+ });
}
void CppCodeModelSettingsWidget::setupGeneralWidgets()
@@ -117,6 +178,16 @@ bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
settingsChanged = true;
}
+ if (m_settings->tidyChecks() != m_currentTidyChecks) {
+ m_settings->setTidyChecks(m_currentTidyChecks);
+ settingsChanged = true;
+ }
+
+ if (m_settings->clazyChecks() != m_currentClazyChecks) {
+ m_settings->setClazyChecks(m_currentClazyChecks);
+ settingsChanged = true;
+ }
+
return settingsChanged;
}