From 2aacf26a77a343b913b8f1bc5b566e04616db805 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 25 Feb 2019 17:32:26 +0100 Subject: [PATCH] ProjectExplorer: Remove Node::m_id It was only used within cmake, in a role that is nowadays covered by buildKey. Change-Id: I4fd77c06a3bb8965db5235315cb017c7b548fbaa Reviewed-by: Christian Kandeler --- .../cmakeprojectmanager/cmakeprojectnodes.cpp | 15 ++++----------- .../cmakeprojectmanager/cmakeprojectnodes.h | 5 ++--- .../cmakeprojectmanager/servermodereader.cpp | 4 ++-- src/plugins/projectexplorer/projectnodes.cpp | 15 +-------------- src/plugins/projectexplorer/projectnodes.h | 7 ++----- 5 files changed, 11 insertions(+), 35 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp index e01ce3a9951..ac1f832bc97 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.cpp @@ -109,18 +109,12 @@ void noAutoAdditionNotify(const QStringList &filePaths, const ProjectExplorer::P CMakeInputsNode::CMakeInputsNode(const Utils::FileName &cmakeLists) : ProjectExplorer::ProjectNode(cmakeLists) { - setNodeId(generateId(cmakeLists)); setPriority(Node::DefaultPriority - 10); // Bottom most! setDisplayName(QCoreApplication::translate("CMakeFilesProjectNode", "CMake Modules")); setIcon(QIcon(":/projectexplorer/images/session.png")); // TODO: Use a better icon! setListInProject(false); } -QByteArray CMakeInputsNode::generateId(const Utils::FileName &inputFile) -{ - return inputFile.toString().toUtf8() + "/cmakeInputs"; -} - bool CMakeInputsNode::showInSimpleTree() const { return true; @@ -175,17 +169,16 @@ bool CMakeProjectNode::addFiles(const QStringList &filePaths, QStringList *) } CMakeTargetNode::CMakeTargetNode(const Utils::FileName &directory, const QString &target) : - ProjectExplorer::ProjectNode(directory) + ProjectExplorer::ProjectNode(directory), m_target(target) { - setNodeId(generateId(directory, target)); setPriority(Node::DefaultProjectPriority + 900); setIcon(QIcon(":/projectexplorer/images/build.png")); // TODO: Use proper icon! setListInProject(false); } -QByteArray CMakeTargetNode::generateId(const Utils::FileName &directory, const QString &target) +QString CMakeTargetNode::generateId(const Utils::FileName &directory, const QString &target) { - return directory.toString().toUtf8() + "///::///" + target.toUtf8(); + return directory.toString() + "///::///" + target; } bool CMakeTargetNode::showInSimpleTree() const @@ -200,7 +193,7 @@ QString CMakeTargetNode::tooltip() const QString CMakeTargetNode::buildKey() const { - return QString::fromUtf8(id()); + return generateId(filePath(), m_target); } bool CMakeTargetNode::supportsAction(ProjectExplorer::ProjectAction action, diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h index 0c8174c10e0..ba53326ad01 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h @@ -35,8 +35,6 @@ class CMakeInputsNode : public ProjectExplorer::ProjectNode public: CMakeInputsNode(const Utils::FileName &cmakeLists); - static QByteArray generateId(const Utils::FileName &inputFile); - bool showInSimpleTree() const final; }; @@ -66,7 +64,7 @@ class CMakeTargetNode : public ProjectExplorer::ProjectNode public: CMakeTargetNode(const Utils::FileName &directory, const QString &target); - static QByteArray generateId(const Utils::FileName &directory, const QString &target); + static QString generateId(const Utils::FileName &directory, const QString &target); void setTargetInformation(const QList &artifacts, const QString &type); @@ -80,6 +78,7 @@ public: private: QString m_tooltip; + QString m_target; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/servermodereader.cpp b/src/plugins/cmakeprojectmanager/servermodereader.cpp index baa7a776dc2..4a9a02d0a6c 100644 --- a/src/plugins/cmakeprojectmanager/servermodereader.cpp +++ b/src/plugins/cmakeprojectmanager/servermodereader.cpp @@ -840,10 +840,10 @@ static CMakeTargetNode *createTargetNode(const QHash(cmln->findNode([&targetId](const Node *n) { - return n->id() == targetId; + return n->buildKey() == targetId; })); if (!tn) { auto newNode = std::make_unique(dir, displayName); diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index db84ef190a8..f2cdedb1900 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -128,11 +128,6 @@ void Node::setPriority(int p) m_priority = p; } -void Node::setNodeId(const QByteArray &nodeId) -{ - m_nodeId = nodeId; -} - void Node::setFilePath(const Utils::FileName &filePath) { m_filePath = filePath; @@ -237,11 +232,6 @@ int Node::line() const return m_line; } -QByteArray Node::id() const -{ - return m_nodeId; -} - QString Node::displayName() const { return filePath().fileName(); @@ -346,7 +336,6 @@ FileNode *FileNode::clone() const { auto fn = new FileNode(filePath(), fileType()); fn->setLine(line()); - fn->setNodeId(id()); fn->setIsGenerated(isGenerated()); fn->setEnabled(isEnabled()); fn->setPriority(priority()); @@ -794,12 +783,10 @@ bool FolderNode::showWhenEmpty() const \sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode */ -VirtualFolderNode::VirtualFolderNode(const Utils::FileName &folderPath, int priority, - const QByteArray &id) : +VirtualFolderNode::VirtualFolderNode(const Utils::FileName &folderPath, int priority) : FolderNode(folderPath, NodeType::VirtualFolder, QString()) { setPriority(priority); - setNodeId(id); } QString VirtualFolderNode::addFileFilter() const diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index 047c5469556..98651a0e9f8 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -127,7 +127,6 @@ public: const Utils::FileName &filePath() const; // file system path int line() const; - QByteArray id() const; virtual QString displayName() const; virtual QString tooltip() const; bool isEnabled() const; @@ -164,13 +163,11 @@ protected: void setPriority(int priority); void setLine(int line); - void setNodeId(const QByteArray &nodeId); void setFilePath(const Utils::FileName &filePath); private: FolderNode *m_parentFolderNode = nullptr; Utils::FileName m_filePath; - QByteArray m_nodeId; int m_line = -1; int m_priority = DefaultPriority; const NodeType m_nodeType; @@ -310,8 +307,7 @@ private: class PROJECTEXPLORER_EXPORT VirtualFolderNode : public FolderNode { public: - explicit VirtualFolderNode(const Utils::FileName &folderPath, int priority, - const QByteArray &id = {}); + explicit VirtualFolderNode(const Utils::FileName &folderPath, int priority); void setAddFileFilter(const QString &filter) { m_addFileFilter = filter; } QString addFileFilter() const override; @@ -356,6 +352,7 @@ public: protected: explicit ProjectNode(const Utils::FileName &projectFilePath); + QString m_target; }; class PROJECTEXPLORER_EXPORT ContainerNode : public FolderNode