diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-01-10 11:38:06 +0100 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2019-01-14 14:10:06 +0000 |
commit | ae0d895d968e2826264d3a02e3d88ae7642cd12f (patch) | |
tree | e69d668672f09c046f0a3876980a231985aca159 /src/plugins/cpptools/cppcodemodelsettingspage.cpp | |
parent | f8aad27a8867a4015e13751c5496a46427ddc548 (diff) | |
download | qt-creator-ae0d895d968e2826264d3a02e3d88ae7642cd12f.tar.gz |
Clang: Warn of potentially expensive checks
...for the code model.
If a diagnostic configuration with potentially expensive checks is
selected in Options/Preferences > C++ > Code Model, show a warning below
the combo box.
Change-Id: I52c5c2e229fd50c0fd82f70154fb5b727726ba31
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppcodemodelsettingspage.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodemodelsettingspage.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.cpp b/src/plugins/cpptools/cppcodemodelsettingspage.cpp index c404c433d0..af5f6b1fd2 100644 --- a/src/plugins/cpptools/cppcodemodelsettingspage.cpp +++ b/src/plugins/cpptools/cppcodemodelsettingspage.cpp @@ -28,10 +28,13 @@ #include "clangdiagnosticconfigswidget.h" #include "cppmodelmanager.h" #include "cpptoolsconstants.h" +#include "cpptoolsreuse.h" #include "ui_cppcodemodelsettingspage.h" +#include <clangtools/clangtoolsconstants.h> // for opening the respective options page #include <coreplugin/icore.h> #include <utils/algorithm.h> +#include <utils/utilsicons.h> #include <QTextStream> @@ -43,6 +46,12 @@ CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(QWidget *parent) , m_ui(new Ui::CppCodeModelSettingsPage) { m_ui->setupUi(this); + m_ui->expensiveChecksHintIcon->setPixmap(Utils::Icons::WARNING.pixmap()); + m_ui->expensiveChecksHintIcon->setVisible(false); + m_ui->expensiveChecksHintText->setVisible(false); + connect(m_ui->expensiveChecksHintText, &QLabel::linkActivated, [](const QString &){ + Core::ICore::showOptionsDialog(ClangTools::Constants::SETTINGS_PAGE_ID); + }); } CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget() @@ -69,6 +78,20 @@ void CppCodeModelSettingsWidget::applyToSettings() const m_settings->toSettings(Core::ICore::settings()); } +static bool hasConfigExpensiveChecks(const Core::Id &configId) +{ + if (!configId.isValid()) + return false; + + const ClangDiagnosticConfig config + = ClangDiagnosticConfigsModel( + codeModelSettings()->clangCustomDiagnosticConfigs()) + .configWithId(configId); + + return !config.clazyChecks().isEmpty() + || config.clangTidyMode() != ClangDiagnosticConfig::TidyMode::Disabled; +} + void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() { const bool isClangActive = CppModelManager::instance()->isClangCodeModelActive(); @@ -88,6 +111,17 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() if (applyClangCodeModelWidgetsToSettings()) m_settings->toSettings(Core::ICore::settings()); }); + + const auto checkForExpensiveChecks = [this](const Core::Id &configId) { + const bool visible = hasConfigExpensiveChecks(configId); + m_ui->expensiveChecksHintIcon->setVisible(visible); + m_ui->expensiveChecksHintText->setVisible(visible); + }; + + checkForExpensiveChecks(m_ui->clangDiagnosticConfigsSelectionWidget->currentConfigId()); + connect(m_ui->clangDiagnosticConfigsSelectionWidget, + &ClangDiagnosticConfigsSelectionWidget::currentConfigChanged, + checkForExpensiveChecks); } void CppCodeModelSettingsWidget::setupGeneralWidgets() |