aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projecttree.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2019-12-19 15:45:24 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2019-12-20 09:37:57 +0000
commita5785e678e56d4711462795ad9639a6d0a4b207a (patch)
tree79d202bf4796765fa2a7d6c35590cef441b290ae /src/plugins/projectexplorer/projecttree.cpp
parent5ef320d9fc3deea2c920c76a81362de39c3f17b9 (diff)
ProjectTree: Add per-node "Expand" and "Collapse" actions
Change-Id: Ic722598f7bb2665ac7a09c24b7eefa9dc6787808 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/projectexplorer/projecttree.cpp')
-rw-r--r--src/plugins/projectexplorer/projecttree.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp
index b42da7ad66c..d22541872c3 100644
--- a/src/plugins/projectexplorer/projecttree.cpp
+++ b/src/plugins/projectexplorer/projecttree.cpp
@@ -154,7 +154,7 @@ void ProjectTree::update()
ProjectTreeWidget *focus = m_focusForContextMenu;
static QPointer<ProjectTreeWidget> lastFocusedProjectTreeWidget;
if (!focus) {
- focus = Utils::findOrDefault(m_projectTreeWidgets, &ProjectTree::hasFocus);
+ focus = currentWidget();
lastFocusedProjectTreeWidget = focus;
}
if (!focus)
@@ -284,15 +284,27 @@ void ProjectTree::sessionAndTreeChanged()
emit treeChanged();
}
+void ProjectTree::collapseCurrentNode()
+{
+ if (const auto w = currentWidget())
+ w->collapseCurrentNode();
+}
+
+void ProjectTree::expandCurrentNode()
+{
+ if (const auto w = currentWidget())
+ w->expandCurrentNode();
+}
+
void ProjectTree::collapseAll()
{
- if (auto w = Utils::findOrDefault(s_instance->m_projectTreeWidgets, &ProjectTree::hasFocus))
+ if (const auto w = currentWidget())
w->collapseAll();
}
void ProjectTree::expandAll()
{
- if (auto w = Utils::findOrDefault(s_instance->m_projectTreeWidgets, &ProjectTree::hasFocus))
+ if (const auto w = currentWidget())
w->expandAll();
}
@@ -344,6 +356,11 @@ bool ProjectTree::hasFocus(ProjectTreeWidget *widget)
|| s_instance->m_focusForContextMenu == widget);
}
+ProjectTreeWidget *ProjectTree::currentWidget() const
+{
+ return findOrDefault(m_projectTreeWidgets, &ProjectTree::hasFocus);
+}
+
void ProjectTree::showContextMenu(ProjectTreeWidget *focus, const QPoint &globalPos, Node *node)
{
QMenu *contextMenu = nullptr;