aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/projecttree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/projectexplorer/projecttree.cpp')
-rw-r--r--src/plugins/projectexplorer/projecttree.cpp48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp
index 1ff829a061..01cb2f0ca6 100644
--- a/src/plugins/projectexplorer/projecttree.cpp
+++ b/src/plugins/projectexplorer/projecttree.cpp
@@ -39,15 +39,16 @@
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
-#include <coreplugin/infobar.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/vcsmanager.h>
#include <utils/algorithm.h>
+#include <utils/infobar.h>
#include <utils/qtcassert.h>
#include <QApplication>
+#include <QFileInfo>
#include <QMenu>
#include <QTimer>
@@ -154,7 +155,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 +285,21 @@ void ProjectTree::sessionAndTreeChanged()
emit treeChanged();
}
+void ProjectTree::expandCurrentNodeRecursively()
+{
+ if (const auto w = currentWidget())
+ w->expandCurrentNodeRecursively();
+}
+
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();
}
@@ -307,8 +314,8 @@ void ProjectTree::updateExternalFileWarning()
auto document = qobject_cast<Core::IDocument *>(sender());
if (!document || document->filePath().isEmpty())
return;
- Core::InfoBar *infoBar = document->infoBar();
- Core::Id externalFileId(EXTERNAL_FILE_WARNING);
+ Utils::InfoBar *infoBar = document->infoBar();
+ Utils::Id externalFileId(EXTERNAL_FILE_WARNING);
if (!document->isModified()) {
infoBar->removeInfo(externalFileId);
return;
@@ -332,9 +339,10 @@ void ProjectTree::updateExternalFileWarning()
return;
}
}
- infoBar->addInfo(Core::InfoBarEntry(externalFileId,
- tr("<b>Warning:</b> This file is outside the project directory."),
- Core::InfoBarEntry::GlobalSuppression::Enabled));
+ infoBar->addInfo(
+ Utils::InfoBarEntry(externalFileId,
+ tr("<b>Warning:</b> This file is outside the project directory."),
+ Utils::InfoBarEntry::GlobalSuppression::Enabled));
}
bool ProjectTree::hasFocus(ProjectTreeWidget *widget)
@@ -344,6 +352,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;
@@ -459,6 +472,23 @@ Node *ProjectTree::nodeForFile(const FilePath &fileName)
return node;
}
+const QList<Node *> ProjectTree::siblingsWithSameBaseName(const Node *fileNode)
+{
+ ProjectNode *productNode = fileNode->parentProjectNode();
+ while (productNode && !productNode->isProduct())
+ productNode = productNode->parentProjectNode();
+ if (!productNode)
+ return {};
+ const QFileInfo fi = fileNode->filePath().toFileInfo();
+ const auto filter = [&fi](const Node *n) {
+ return n->asFileNode()
+ && n->filePath().toFileInfo().dir() == fi.dir()
+ && n->filePath().toFileInfo().completeBaseName() == fi.completeBaseName()
+ && n->filePath().toString() != fi.filePath();
+ };
+ return productNode->findNodes(filter);
+}
+
void ProjectTree::hideContextMenu()
{
m_focusForContextMenu = nullptr;