ClangTools: Put a clazy setting to its proper place

We do not go out of our way to retain the old settings value, as the
setting affects only the UI behavior in the same widget it is displayed
in.

Change-Id: Ie0d66b3909364e15a05013eddaf742b161941f67
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Kandeler
2024-02-22 14:17:10 +01:00
parent 498625520a
commit cdd85477fb
5 changed files with 7 additions and 21 deletions

View File

@@ -98,9 +98,11 @@ ClangToolsSettings::ClangToolsSettings()
setSettingsGroup(Constants::SETTINGS_ID);
clangTidyExecutable.setSettingsKey("ClangTidyExecutable");
clazyStandaloneExecutable.setSettingsKey("ClazyStandaloneExecutable");
enableLowerClazyLevels.setSettingsKey("EnableLowerClazyLevels");
enableLowerClazyLevels.setDefaultValue(true);
readSettings();
}

View File

@@ -71,6 +71,8 @@ public:
Utils::FilePath executable(CppEditor::ClangToolType tool) const;
void setExecutable(CppEditor::ClangToolType tool, const Utils::FilePath &path);
Utils::BoolAspect enableLowerClazyLevels{this};
CppEditor::ClangDiagnosticConfigs diagnosticConfigs() const { return m_diagnosticConfigs; }
void setDiagnosticConfigs(const CppEditor::ClangDiagnosticConfigs &configs)
{ m_diagnosticConfigs = configs; }

View File

@@ -10,7 +10,6 @@
#include "clangtoolsutils.h"
#include "executableinfo.h"
#include <cppeditor/cppcodemodelsettings.h>
#include <cppeditor/cppeditorconstants.h>
#include <cppeditor/cpptoolsreuse.h>
@@ -1008,10 +1007,10 @@ DiagnosticConfigsWidget::DiagnosticConfigsWidget(const ClangDiagnosticConfigs &c
connect(m_clazyChecks->enableLowerLevelsCheckBox, &QCheckBox::stateChanged, this, [this] {
const bool enable = m_clazyChecks->enableLowerLevelsCheckBox->isChecked();
m_clazyTreeModel->setEnableLowerLevels(enable);
codeModelSettings()->setEnableLowerClazyLevels(enable);
ClangToolsSettings::instance()->enableLowerClazyLevels.setValue(enable);
});
const Qt::CheckState checkEnableLowerClazyLevels
= codeModelSettings()->enableLowerClazyLevels() ? Qt::Checked : Qt::Unchecked;
= ClangToolsSettings::instance()->enableLowerClazyLevels.value() ? Qt::Checked : Qt::Unchecked;
m_clazyChecks->enableLowerLevelsCheckBox->setCheckState(checkEnableLowerClazyLevels);
m_tidyChecks = new TidyChecksWidget;

View File

@@ -32,7 +32,6 @@ using namespace Utils;
namespace CppEditor {
static Id initialClangDiagnosticConfigId() { return Constants::CPP_CLANG_DIAG_CONFIG_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; }
@@ -79,7 +78,6 @@ bool operator==(const CppEditor::CppCodeModelSettings::Data &s1,
&& s1.skipIndexingBigFiles == s2.skipIndexingBigFiles
&& s1.useBuiltinPreprocessor == s2.useBuiltinPreprocessor
&& s1.indexerFileSizeLimitInMb == s2.indexerFileSizeLimitInMb
&& s1.enableLowerClazyLevels == s2.enableLowerClazyLevels
&& s1.categorizeFindReferences == s2.categorizeFindReferences
&& s1.ignoreFiles == s2.ignoreFiles && s1.ignorePattern == s2.ignorePattern;
}
@@ -87,7 +85,6 @@ bool operator==(const CppEditor::CppCodeModelSettings::Data &s1,
Store CppCodeModelSettings::Data::toMap() const
{
Store store;
store.insert(enableLowerClazyLevelsKey(), enableLowerClazyLevels);
store.insert(pchUsageKey(), pchUsage);
store.insert(interpretAmbiguousHeadersAsCHeadersKey(), interpretAmbigiousHeadersAsC);
store.insert(skipIndexingBigFilesKey(), skipIndexingBigFiles);
@@ -101,8 +98,6 @@ Store CppCodeModelSettings::Data::toMap() const
void CppCodeModelSettings::Data::fromMap(const Utils::Store &store)
{
const CppCodeModelSettings::Data def;
enableLowerClazyLevels
= store.value(enableLowerClazyLevelsKey(), def.enableLowerClazyLevels).toBool();
pchUsage = static_cast<PCHUsage>(store.value(pchUsageKey(), def.pchUsage).toInt());
interpretAmbigiousHeadersAsC = store
.value(interpretAmbiguousHeadersAsCHeadersKey(),
@@ -139,13 +134,6 @@ void CppCodeModelSettings::setData(const Data &data)
}
}
void CppCodeModelSettings::setEnableLowerClazyLevels(bool enable)
{
Data d = data();
d.enableLowerClazyLevels = enable;
setData(d);
}
void CppCodeModelSettings::setCategorizeFindReferences(bool categorize)
{
Data d = data();

View File

@@ -47,7 +47,6 @@ public:
bool skipIndexingBigFiles = true;
bool useBuiltinPreprocessor = true;
int indexerFileSizeLimitInMb = 5;
bool enableLowerClazyLevels = true; // For UI behavior only
bool categorizeFindReferences = false; // Ephemeral!
bool ignoreFiles = false;
QString ignorePattern;
@@ -58,7 +57,6 @@ public:
void setData(const Data &data);
Data data() const { return m_data; }
bool enableLowerClazyLevels() const { return m_data.enableLowerClazyLevels; }
PCHUsage pchUsage() const { return m_data.pchUsage; }
bool interpretAmbigiousHeadersAsC() const { return m_data.interpretAmbigiousHeadersAsC; }
bool skipIndexingBigFiles() const { return m_data.skipIndexingBigFiles; }
@@ -68,9 +66,6 @@ public:
bool ignoreFiles() const { return m_data.ignoreFiles; }
QString ignorePattern() const { return m_data.ignorePattern; }
// FIXME: Doesn't belong here.
void setEnableLowerClazyLevels(bool enable);
void setCategorizeFindReferences(bool categorize);
signals: