summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
diff options
context:
space:
mode:
authorIvan Donchevskii <ivan.donchevskii@qt.io>2018-05-25 13:19:29 +0200
committerIvan Donchevskii <ivan.donchevskii@qt.io>2018-06-20 07:00:16 +0000
commit6575cfc6744370d49ebd2cc84e667057272fdd61 (patch)
tree6950d8b5804722d4783a42a78cee4aa96ad00dec /src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
parentcdcac66c78bbdaf18be6ae72a711ea0557d492e7 (diff)
downloadqt-creator-6575cfc6744370d49ebd2cc84e667057272fdd61.tar.gz
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>
Diffstat (limited to 'src/plugins/cpptools/clangdiagnosticconfigswidget.cpp')
-rw-r--r--src/plugins/cpptools/clangdiagnosticconfigswidget.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp b/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
index 6b5e0d7334..fb683a07ae 100644
--- a/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
+++ b/src/plugins/cpptools/clangdiagnosticconfigswidget.cpp
@@ -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);