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 <ivan.donchevskii@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-02-11 13:04:28 +01:00
parent 4eaedac72f
commit fd04104484

View File

@@ -321,8 +321,6 @@ void DiagnosticView::openEditorForCurrentIndex()
void DiagnosticView::setModel(QAbstractItemModel *theProxyModel) void DiagnosticView::setModel(QAbstractItemModel *theProxyModel)
{ {
const auto proxyModel = static_cast<QSortFilterProxyModel *>(theProxyModel); const auto proxyModel = static_cast<QSortFilterProxyModel *>(theProxyModel);
const auto sourceModel = static_cast<ClangToolsDiagnosticModel *>(proxyModel->sourceModel());
Debugger::DetailedErrorView::setModel(proxyModel); Debugger::DetailedErrorView::setModel(proxyModel);
auto *header = new HeaderWithCheckBoxInColumn(Qt::Horizontal, auto *header = new HeaderWithCheckBoxInColumn(Qt::Horizontal,
@@ -330,12 +328,17 @@ void DiagnosticView::setModel(QAbstractItemModel *theProxyModel)
this); this);
connect(header, &HeaderWithCheckBoxInColumn::checkBoxClicked, this, [=](bool checked) { connect(header, &HeaderWithCheckBoxInColumn::checkBoxClicked, this, [=](bool checked) {
m_ignoreSetSelectedFixItsCount = true; m_ignoreSetSelectedFixItsCount = true;
sourceModel->rootItem()->forChildrenAtLevel(2, [&](::Utils::TreeItem *item) { for (int i = 0, count = proxyModel->rowCount(); i < count; ++i) {
auto diagnosticItem = static_cast<DiagnosticItem *>(item); const QModelIndex filePathItemIndex = proxyModel->index(i, 0);
diagnosticItem->setData(DiagnosticView::DiagnosticColumn, 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<DiagnosticItem *>(diagnosticItemIndex.internalPointer());
item->setData(DiagnosticView::DiagnosticColumn,
checked ? Qt::Checked : Qt::Unchecked, checked ? Qt::Checked : Qt::Unchecked,
Qt::CheckStateRole); Qt::CheckStateRole);
}); }
}
m_ignoreSetSelectedFixItsCount = false; m_ignoreSetSelectedFixItsCount = false;
}); });
setHeader(header); setHeader(header);