From 44a42db1ae4460142185e429ff6b39e37d6e3623 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 26 Feb 2019 13:34:23 +0100 Subject: [PATCH] ProjectExplorer: "Upstream" line number display for FileNodes So far only used and set with QBS, but conceptually usable more generally, and harmless if not used. Change-Id: I1d2d615f5613340690de22a1c7d716a193fb1f05 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/projectnodes.cpp | 8 ++++++++ src/plugins/projectexplorer/projectnodes.h | 1 + src/plugins/qbsprojectmanager/qbsnodes.cpp | 7 ------- src/plugins/qbsprojectmanager/qbsnodes.h | 2 -- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index 1c629da625b..86fc719af6e 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -417,6 +417,14 @@ bool FileNode::supportsAction(ProjectAction action, const Node *node) const return parentFolder && parentFolder->supportsAction(action, node); } +QString FileNode::displayName() const +{ + int l = line(); + if (l < 0) + return Node::displayName(); + return Node::displayName() + ':' + QString::number(l); +} + /*! \class ProjectExplorer::FolderNode diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index 678852e854b..b34863e455d 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -200,6 +200,7 @@ public: const std::function factory, QFutureInterface> *future = nullptr); bool supportsAction(ProjectAction action, const Node *node) const override; + QString displayName() const override; private: FileType m_fileType; diff --git a/src/plugins/qbsprojectmanager/qbsnodes.cpp b/src/plugins/qbsprojectmanager/qbsnodes.cpp index 91280dac418..1630871aa44 100644 --- a/src/plugins/qbsprojectmanager/qbsnodes.cpp +++ b/src/plugins/qbsprojectmanager/qbsnodes.cpp @@ -242,13 +242,6 @@ QbsFileNode::QbsFileNode(const Utils::FileName &filePath, setLine(line); } -QString QbsFileNode::displayName() const -{ - int l = line(); - if (l < 0) - return ProjectExplorer::FileNode::displayName(); - return ProjectExplorer::FileNode::displayName() + QLatin1Char(':') + QString::number(l); -} // --------------------------------------------------------------------------- // QbsBaseProjectNode: diff --git a/src/plugins/qbsprojectmanager/qbsnodes.h b/src/plugins/qbsprojectmanager/qbsnodes.h index c1296ec5b2d..73a30a4d803 100644 --- a/src/plugins/qbsprojectmanager/qbsnodes.h +++ b/src/plugins/qbsprojectmanager/qbsnodes.h @@ -44,8 +44,6 @@ class QbsFileNode : public ProjectExplorer::FileNode public: QbsFileNode(const Utils::FileName &filePath, const ProjectExplorer::FileType fileType, int line); - - QString displayName() const override; }; // ---------------------------------------------------------------------------