Commit 327f09c2 authored by Tobias Hunger's avatar Tobias Hunger

ProjectExplorer: Override filePath for recursiveFindOrCreateFolder

Override the base node's filePath for recursiveFindOrCreateFolder (and
buildTree, which is based on that). This makes it possible to use this
method to build up trees below project nodes, etc. that have no
representation as a existing directory in the filesystem.

Change-Id: I29fd1ab5b81b144b3db1966dc08dd50470c2d5d7
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent d59489c4
......@@ -409,9 +409,10 @@ FolderNode *FolderNode::folderNode(const Utils::FileName &directory) const
});
}
FolderNode *FolderNode::recursiveFindOrCreateFolderNode(const QString &directory)
FolderNode *FolderNode::recursiveFindOrCreateFolderNode(const QString &directory,
const Utils::FileName &overrideBaseDir)
{
Utils::FileName path = filePath();
Utils::FileName path = overrideBaseDir.isEmpty() ? filePath() : overrideBaseDir;
QString workPath;
if (path.isEmpty() || path.toFileInfo().isRoot()) {
workPath = directory;
......@@ -440,7 +441,7 @@ FolderNode *FolderNode::recursiveFindOrCreateFolderNode(const QString &directory
return parent;
}
void FolderNode::buildTree(QList<FileNode *> &files)
void FolderNode::buildTree(QList<FileNode *> &files, const Utils::FileName &overrideBaseDir)
{
// Gather old list
QList<ProjectExplorer::FileNode *> oldFiles = recursiveFileNodes();
......@@ -461,7 +462,8 @@ void FolderNode::buildTree(QList<FileNode *> &files)
foreach (ProjectExplorer::FileNode *fn, added) {
// Get relative path to rootNode
QString parentDir = fn->filePath().toFileInfo().absolutePath();
ProjectExplorer::FolderNode *folder = recursiveFindOrCreateFolderNode(parentDir);
ProjectExplorer::FolderNode *folder
= recursiveFindOrCreateFolderNode(parentDir, overrideBaseDir);
addedFolderMapping[folder] << fn;
}
......
......@@ -193,8 +193,9 @@ public:
QList<FileNode *> recursiveFileNodes() const;
QList<FolderNode *> folderNodes() const;
FolderNode *folderNode(const Utils::FileName &directory) const;
FolderNode *recursiveFindOrCreateFolderNode(const QString &directory);
void buildTree(QList<FileNode *> &files);
FolderNode *recursiveFindOrCreateFolderNode(const QString &directory,
const Utils::FileName &overrideBaseDir = Utils::FileName());
void buildTree(QList<FileNode *> &files, const Utils::FileName &overrideBaseDir = Utils::FileName());
virtual void accept(NodesVisitor *visitor);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment