From ffa88006a5da2fa288fbbbd2771e59ee7168bef2 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 25 Feb 2019 18:08:36 +0100 Subject: [PATCH] ProjectExplorer: Replace FolderNode ctor display argument ... by use of the setter. Change-Id: Ie6bf15b4dfae4d4e4d98694313b6e7dc9a22c117 Reviewed-by: Christian Kandeler --- .../compilationdatabaseproject.cpp | 3 ++- src/plugins/projectexplorer/projectnodes.cpp | 14 ++++++-------- src/plugins/projectexplorer/projectnodes.h | 3 +-- .../qbsprojectmanager/qbsnodetreebuilder.cpp | 4 ++-- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp index acae72ff4bd..720f539e399 100644 --- a/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp +++ b/src/plugins/compilationdatabaseprojectmanager/compilationdatabaseproject.cpp @@ -250,8 +250,9 @@ FolderNode *addChildFolderNode(FolderNode *parent, const QString &childName) { Utils::FileName parentPath = parent->filePath(); auto node = std::make_unique( - parentPath.appendPath(childName), NodeType::Folder, childName); + parentPath.appendPath(childName), NodeType::Folder); FolderNode *childNode = node.get(); + childNode->setDisplayName(childName); parent->addNode(std::move(node)); return childNode; diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index f2cdedb1900..e41395b80a3 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -422,17 +422,14 @@ bool FileNode::supportsAction(ProjectAction action, const Node *node) const \sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode */ -FolderNode::FolderNode(const Utils::FileName &folderPath, NodeType nodeType, - const QString &displayName) : - Node(nodeType), - m_displayName(displayName) +FolderNode::FolderNode(const Utils::FileName &folderPath, NodeType nodeType) : + Node(nodeType) { setFilePath(folderPath); setPriority(DefaultFolderPriority); setListInProject(false); setIsGenerated(false); - if (m_displayName.isEmpty()) - m_displayName = folderPath.toUserOutput(); + m_displayName = folderPath.toUserOutput(); } /*! @@ -784,7 +781,7 @@ bool FolderNode::showWhenEmpty() const \sa ProjectExplorer::FileNode, ProjectExplorer::ProjectNode */ VirtualFolderNode::VirtualFolderNode(const Utils::FileName &folderPath, int priority) : - FolderNode(folderPath, NodeType::VirtualFolder, QString()) + FolderNode(folderPath, NodeType::VirtualFolder) { setPriority(priority); } @@ -810,10 +807,11 @@ QString VirtualFolderNode::addFileFilter() const Creates an uninitialized project node object. */ ProjectNode::ProjectNode(const Utils::FileName &projectFilePath) : - FolderNode(projectFilePath, NodeType::Project, projectFilePath.fileName()) + FolderNode(projectFilePath, NodeType::Project) { setPriority(DefaultProjectPriority); setListInProject(true); + setDisplayName(projectFilePath.fileName()); } bool ProjectNode::canAddSubProject(const QString &proFilePath) const diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index 98651a0e9f8..e117abdc2ea 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -206,8 +206,7 @@ private: class PROJECTEXPLORER_EXPORT FolderNode : public Node { public: - explicit FolderNode(const Utils::FileName &folderPath, NodeType nodeType = NodeType::Folder, - const QString &displayName = QString()); + explicit FolderNode(const Utils::FileName &folderPath, NodeType nodeType = NodeType::Folder); QString displayName() const override; QIcon icon() const; diff --git a/src/plugins/qbsprojectmanager/qbsnodetreebuilder.cpp b/src/plugins/qbsprojectmanager/qbsnodetreebuilder.cpp index 87827f61c98..c863cf67477 100644 --- a/src/plugins/qbsprojectmanager/qbsnodetreebuilder.cpp +++ b/src/plugins/qbsprojectmanager/qbsnodetreebuilder.cpp @@ -215,8 +215,8 @@ std::unique_ptr QbsNodeTreeBuilder::buildTree(QbsProject *pr setupProjectNode(root.get(), project->qbsProjectData(), project->qbsProject()); auto buildSystemFiles = std::make_unique(project->projectDirectory(), - ProjectExplorer::NodeType::Folder, - QCoreApplication::translate("QbsRootProjectNode", "Qbs files")); + ProjectExplorer::NodeType::Folder); + buildSystemFiles->setDisplayName(QCoreApplication::translate("QbsRootProjectNode", "Qbs files")); Utils::FileName base = project->projectDirectory(); const QStringList &files = unreferencedBuildSystemFiles(project->qbsProject());