diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 09c529b7dd0..a6173a6f26d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -511,8 +511,6 @@ public: QAction *m_openFileAction; QAction *m_projectTreeCollapseAllAction; QAction *m_projectTreeExpandAllAction; - QAction *m_projectTreeCollapseNodeAction = nullptr; - QAction *m_projectTreeExpandNodeAction = nullptr; Utils::ParameterAction *m_closeProjectFilesActionFileMenu; Utils::ParameterAction *m_closeProjectFilesActionContextMenu; QAction *m_searchOnFileSystem; @@ -1352,26 +1350,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er // Collapse & Expand. const Id treeGroup = Constants::G_PROJECT_TREE; - - dd->m_projectTreeCollapseNodeAction = new QAction(tr("Collapse"), this); - connect(dd->m_projectTreeCollapseNodeAction, &QAction::triggered, - ProjectTree::instance(), &ProjectTree::collapseCurrentNode); - Command * const collapseNodeCmd = ActionManager::registerAction( - dd->m_projectTreeCollapseNodeAction, "ProjectExplorer.CollapseNode", - projectTreeContext); - dd->m_projectTreeExpandNodeAction = new QAction(tr("Expand"), this); - connect(dd->m_projectTreeExpandNodeAction, &QAction::triggered, - ProjectTree::instance(), &ProjectTree::expandCurrentNode); - Command * const expandNodeCmd = ActionManager::registerAction( - dd->m_projectTreeExpandNodeAction, "ProjectExplorer.ExpandNode", - projectTreeContext); - for (Core::ActionContainer * const ac : {msubProjectContextMenu, mfolderContextMenu, - mprojectContextMenu}) { - ac->addSeparator(treeGroup); - ac->addAction(collapseNodeCmd, treeGroup); - ac->addAction(expandNodeCmd, treeGroup); - } - dd->m_projectTreeCollapseAllAction = new QAction(tr("Collapse All"), this); Command * const collapseCmd = ActionManager::registerAction( dd->m_projectTreeCollapseAllAction, Constants::PROJECTTREE_COLLAPSE_ALL, diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp index d22541872c3..b42da7ad66c 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 lastFocusedProjectTreeWidget; if (!focus) { - focus = currentWidget(); + focus = Utils::findOrDefault(m_projectTreeWidgets, &ProjectTree::hasFocus); lastFocusedProjectTreeWidget = focus; } if (!focus) @@ -284,27 +284,15 @@ 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 (const auto w = currentWidget()) + if (auto w = Utils::findOrDefault(s_instance->m_projectTreeWidgets, &ProjectTree::hasFocus)) w->collapseAll(); } void ProjectTree::expandAll() { - if (const auto w = currentWidget()) + if (auto w = Utils::findOrDefault(s_instance->m_projectTreeWidgets, &ProjectTree::hasFocus)) w->expandAll(); } @@ -356,11 +344,6 @@ 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; diff --git a/src/plugins/projectexplorer/projecttree.h b/src/plugins/projectexplorer/projecttree.h index 6b25b4a12eb..bf1335e5be5 100644 --- a/src/plugins/projectexplorer/projecttree.h +++ b/src/plugins/projectexplorer/projecttree.h @@ -82,9 +82,6 @@ public: static Project *projectForNode(const Node *node); static Node *nodeForFile(const Utils::FilePath &fileName); - void collapseCurrentNode(); - void expandCurrentNode(); - void collapseAll(); void expandAll(); @@ -120,7 +117,6 @@ private: void updateExternalFileWarning(); static bool hasFocus(Internal::ProjectTreeWidget *widget); - Internal::ProjectTreeWidget *currentWidget() const; void hideContextMenu(); private: diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 66613eb5910..b3ae5756e7a 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -430,16 +430,6 @@ void ProjectTreeWidget::setAutoSynchronization(bool sync) syncFromDocumentManager(); } -void ProjectTreeWidget::collapseCurrentNode() -{ - m_view->collapse(m_view->currentIndex()); -} - -void ProjectTreeWidget::expandCurrentNode() -{ - m_view->expand(m_view->currentIndex()); -} - void ProjectTreeWidget::collapseAll() { m_view->collapseAll(); diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h index 935d041f7fd..e53396c4b9a 100644 --- a/src/plugins/projectexplorer/projecttreewidget.h +++ b/src/plugins/projectexplorer/projecttreewidget.h @@ -67,8 +67,6 @@ public: void toggleAutoSynchronization(); void editCurrentItem(); - void collapseCurrentNode(); - void expandCurrentNode(); void collapseAll(); void expandAll();