forked from qt-creator/qt-creator
Clang: Add default configurations with Clang-Tidy checks
The first configuration contains most of checks which make sense for most of generic projects. The second configuration is extremely slow but plays the role of Clang static analyzer. For the sake of viewing these checks Clang-Tidy checks tree is modified to be expandable in read-only mode. Change-Id: I41c4ee26bcdf05384507427b842d61e255d59bf7 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
@@ -112,7 +112,7 @@ public:
|
||||
const QModelIndex index = indexForCheck(check);
|
||||
if (!index.isValid())
|
||||
continue;
|
||||
auto node = static_cast<ProjectExplorer::Tree *>(index.internalPointer());
|
||||
auto *node = static_cast<ProjectExplorer::Tree *>(index.internalPointer());
|
||||
node->checked = state;
|
||||
propagateUp(index);
|
||||
propagateDown(index);
|
||||
@@ -161,6 +161,18 @@ public:
|
||||
return ProjectExplorer::SelectableFilesModel::data(index, role);
|
||||
}
|
||||
|
||||
void setEnabled(bool enabled)
|
||||
{
|
||||
m_enabled = enabled;
|
||||
}
|
||||
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override
|
||||
{
|
||||
if (role == Qt::CheckStateRole && !m_enabled)
|
||||
return false;
|
||||
return ProjectExplorer::SelectableFilesModel::setData(index, value, role);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// TODO: Remove/replace this method after base class refactoring is done.
|
||||
@@ -220,6 +232,8 @@ private:
|
||||
for (const ProjectExplorer::Tree *t : root->childDirectories)
|
||||
collectChecks(t, checks);
|
||||
}
|
||||
|
||||
bool m_enabled = true;
|
||||
};
|
||||
|
||||
ClangDiagnosticConfigsWidget::ClangDiagnosticConfigsWidget(const Core::Id &configToSelect,
|
||||
@@ -489,7 +503,11 @@ void ClangDiagnosticConfigsWidget::syncClangTidyWidgets(const ClangDiagnosticCon
|
||||
break;
|
||||
}
|
||||
|
||||
m_tidyChecksWidget->setEnabled(!config.isReadOnly());
|
||||
const bool enabled = !config.isReadOnly();
|
||||
m_tidyChecks->tidyMode->setEnabled(enabled);
|
||||
m_tidyChecks->plainTextEditButton->setText(enabled ? tr("Edit Checks as String...")
|
||||
: tr("View Checks as String..."));
|
||||
m_tidyTreeModel->setEnabled(enabled);
|
||||
connectClangTidyItemChanged();
|
||||
}
|
||||
|
||||
@@ -650,12 +668,17 @@ void ClangDiagnosticConfigsWidget::setupTabs()
|
||||
m_tidyChecks->checksPrefixesTree->header()->setStretchLastSection(false);
|
||||
m_tidyChecks->checksPrefixesTree->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
connect(m_tidyChecks->plainTextEditButton, &QPushButton::clicked, this, [this]() {
|
||||
const bool readOnly = selectedConfig().isReadOnly();
|
||||
|
||||
QDialog dialog;
|
||||
dialog.setWindowTitle(tr("Checks"));
|
||||
dialog.setLayout(new QVBoxLayout);
|
||||
auto *textEdit = new QTextEdit(&dialog);
|
||||
textEdit->setReadOnly(readOnly);
|
||||
dialog.layout()->addWidget(textEdit);
|
||||
auto *buttonsBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
auto *buttonsBox = new QDialogButtonBox(QDialogButtonBox::Ok
|
||||
| (readOnly ? QDialogButtonBox::NoButton
|
||||
: QDialogButtonBox::Cancel));
|
||||
dialog.layout()->addWidget(buttonsBox);
|
||||
QObject::connect(buttonsBox, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
|
||||
QObject::connect(buttonsBox, &QDialogButtonBox::rejected, &dialog, &QDialog::reject);
|
||||
|
||||
Reference in New Issue
Block a user