From 4e0ff112e4cb97d2179287e6bd3cb707dc64406d Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 1 Mar 2019 08:38:17 +0100 Subject: [PATCH] ResourceEditor: Change signature of ResourceTopLevelNode ctor Replace the parent node by the only data item it is used for to make it more clear that this is not about tree structure. Also move the parameter with possible default to the last position. Change-Id: Ibf62328dea335b5999595e5cebb36051ec84bc3a Reviewed-by: Christian Kandeler --- src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp | 3 ++- src/plugins/resourceeditor/resourceeditorplugin.cpp | 2 +- src/plugins/resourceeditor/resourcenode.cpp | 6 +++--- src/plugins/resourceeditor/resourcenode.h | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp index a302b4db08d..adba361c154 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodetreebuilder.cpp @@ -168,7 +168,8 @@ static void createTree(const QmakePriFile *pri, QmakePriFileNode *node, const Fi int eid = vfs->idForFileName(file.toString(), QMakeVfs::VfsExact); vfs->readFile(eid, &contents, &errorMessage); } - vfolder->addNode(std::make_unique(file, contents, vfolder.get())); + vfolder->addNode(std::make_unique + (file, vfolder->filePath(), contents)); } } else { for (const FileName &fn : newFilePaths) { diff --git a/src/plugins/resourceeditor/resourceeditorplugin.cpp b/src/plugins/resourceeditor/resourceeditorplugin.cpp index c7de69cb630..f5c3fa19289 100644 --- a/src/plugins/resourceeditor/resourceeditorplugin.cpp +++ b/src/plugins/resourceeditor/resourceeditorplugin.cpp @@ -217,7 +217,7 @@ void ResourceEditorPlugin::extensionsInitialized() FolderNode *const pn = file->parentFolderNode(); QTC_ASSERT(pn, continue); const Utils::FileName path = file->filePath(); - auto topLevel = std::make_unique(path, QString(), pn); + auto topLevel = std::make_unique(path, pn->filePath()); topLevel->setIsGenerated(file->isGenerated()); pn->replaceSubtree(file, std::move(topLevel)); } diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index 8431fa16fe2..cc9888ca6ac 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -73,7 +73,7 @@ public: FolderNode *parent = m_node->parentFolderNode(); QTC_ASSERT(parent, return false); parent->replaceSubtree(m_node, std::make_unique( - m_node->filePath(), m_node->contents(), parent)); + m_node->filePath(), parent->filePath(), m_node->contents())); return true; } @@ -265,7 +265,8 @@ bool SimpleResourceFolderNode::renameFile(const QString &filePath, const QString } // Internal ResourceTopLevelNode::ResourceTopLevelNode(const FileName &filePath, - const QString &contents, FolderNode *parent) + const FileName &base, + const QString &contents) : FolderNode(filePath) { setIcon(FileIconProvider::icon(filePath.toString())); @@ -283,7 +284,6 @@ ResourceTopLevelNode::ResourceTopLevelNode(const FileName &filePath, m_contents = contents; } - FileName base = parent->filePath(); if (filePath.isChildOf(base)) setDisplayName(filePath.relativeChildPath(base).toUserOutput()); else diff --git a/src/plugins/resourceeditor/resourcenode.h b/src/plugins/resourceeditor/resourcenode.h index 9d38e3c6222..f732c6ae522 100644 --- a/src/plugins/resourceeditor/resourcenode.h +++ b/src/plugins/resourceeditor/resourcenode.h @@ -35,7 +35,8 @@ class RESOURCE_EXPORT ResourceTopLevelNode : public ProjectExplorer::FolderNode { public: ResourceTopLevelNode(const Utils::FileName &filePath, - const QString &contents, FolderNode *parent); + const Utils::FileName &basePath, + const QString &contents = {}); ~ResourceTopLevelNode() override; void addInternalNodes();