From fd04104484a4e1936015e9b4b5f6c38d08fbbbdd Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 11 Feb 2019 13:04:28 +0100 Subject: [PATCH] ClangTools: Toggle only filtered fixits by header check box When toggling the check box in the diagnostic view header, toggle only the filtered items instead of all. This allows to easily check all the filtered items, which is useful for creating separate commits. Change-Id: I7589bc57e61a5560fd7de738a8ae63131a1a6fa6 Reviewed-by: Ivan Donchevskii --- .../clangtools/clangtoolsdiagnosticview.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp index 54cea0c7766..40fa9adc369 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticview.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticview.cpp @@ -321,8 +321,6 @@ void DiagnosticView::openEditorForCurrentIndex() void DiagnosticView::setModel(QAbstractItemModel *theProxyModel) { const auto proxyModel = static_cast(theProxyModel); - const auto sourceModel = static_cast(proxyModel->sourceModel()); - Debugger::DetailedErrorView::setModel(proxyModel); auto *header = new HeaderWithCheckBoxInColumn(Qt::Horizontal, @@ -330,12 +328,17 @@ void DiagnosticView::setModel(QAbstractItemModel *theProxyModel) this); connect(header, &HeaderWithCheckBoxInColumn::checkBoxClicked, this, [=](bool checked) { m_ignoreSetSelectedFixItsCount = true; - sourceModel->rootItem()->forChildrenAtLevel(2, [&](::Utils::TreeItem *item) { - auto diagnosticItem = static_cast(item); - diagnosticItem->setData(DiagnosticView::DiagnosticColumn, - checked ? Qt::Checked : Qt::Unchecked, - Qt::CheckStateRole); - }); + for (int i = 0, count = proxyModel->rowCount(); i < count; ++i) { + const QModelIndex filePathItemIndex = proxyModel->index(i, 0); + for (int j = 0, count = proxyModel->rowCount(filePathItemIndex); j < count; ++j) { + const QModelIndex proxyIndex = proxyModel->index(j, 0, filePathItemIndex); + const QModelIndex diagnosticItemIndex = proxyModel->mapToSource(proxyIndex); + auto item = static_cast(diagnosticItemIndex.internalPointer()); + item->setData(DiagnosticView::DiagnosticColumn, + checked ? Qt::Checked : Qt::Unchecked, + Qt::CheckStateRole); + } + } m_ignoreSetSelectedFixItsCount = false; }); setHeader(header);