From c639964f9217abeec6dec00aa48a33fcad58cdc9 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Mon, 28 Jan 2019 16:15:19 +0100 Subject: [PATCH] ClangTools: Add expand/collapse button Change-Id: I0981aeb4dad001eb561a4e83201ab21f3510b3e5 Reviewed-by: Ivan Donchevskii --- src/plugins/clangtools/clangtidyclazytool.cpp | 19 +++++++++++++++++++ src/plugins/clangtools/clangtidyclazytool.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/plugins/clangtools/clangtidyclazytool.cpp b/src/plugins/clangtools/clangtidyclazytool.cpp index 1cf0c81fa4b..d7033df170d 100644 --- a/src/plugins/clangtools/clangtidyclazytool.cpp +++ b/src/plugins/clangtools/clangtidyclazytool.cpp @@ -260,6 +260,23 @@ ClangTidyClazyTool::ClangTidyClazyTool() }); m_clear = action; + // Expand/Collapse + action = new QAction(this); + action->setDisabled(true); + action->setCheckable(true); + action->setIcon(Utils::Icons::EXPAND_ALL_TOOLBAR.icon()); + action->setToolTip(tr("Expand All")); + connect(action, &QAction::toggled, [this](bool checked){ + if (checked) { + m_expandCollapse->setToolTip(tr("Collapse All")); + m_diagnosticView->expandAll(); + } else { + m_expandCollapse->setToolTip(tr("Expand All")); + m_diagnosticView->collapseAll(); + } + }); + m_expandCollapse = action; + // Filter line edit m_filterLineEdit = new Utils::FancyLineEdit(); m_filterLineEdit->setFiltering(true); @@ -310,6 +327,7 @@ ClangTidyClazyTool::ClangTidyClazyTool() m_perspective.addToolBarAction(m_clear); m_perspective.addToolBarAction(m_goBack); m_perspective.addToolBarAction(m_goNext); + m_perspective.addToolBarAction(m_expandCollapse); m_perspective.addToolBarWidget(m_filterLineEdit); m_perspective.addToolBarWidget(m_applyFixitsButton); @@ -426,6 +444,7 @@ void ClangTidyClazyTool::handleStateUpdate() const int issuesVisible = m_diagnosticFilterModel->rowCount(); m_goBack->setEnabled(issuesVisible > 1); m_goNext->setEnabled(issuesVisible > 1); + m_expandCollapse->setEnabled(issuesVisible); QString message; if (m_running) { diff --git a/src/plugins/clangtools/clangtidyclazytool.h b/src/plugins/clangtools/clangtidyclazytool.h index a82ff809993..7cde29f89d7 100644 --- a/src/plugins/clangtools/clangtidyclazytool.h +++ b/src/plugins/clangtools/clangtidyclazytool.h @@ -71,6 +71,7 @@ private: QAction *m_goBack = nullptr; QAction *m_goNext = nullptr; QAction *m_clear = nullptr; + QAction *m_expandCollapse = nullptr; Utils::Perspective m_perspective{ClangTidyClazyPerspectiveId, tr("Clang-Tidy and Clazy")}; };