Skip to content
Snippets Groups Projects
Commit 39e2c013 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ProjectExplorer: Handle root directory when creating folders


Handle root directory properly (a empty filePath in the base node) when
creating folder nodes in the project tree.

Change-Id: Iad761b94ee210406ed5ab9ceb2d00ce25db90046
Reviewed-by: default avatarTim Jenssen <tim.jenssen@qt.io>
parent f9e93577
No related branches found
No related tags found
No related merge requests found
......@@ -383,12 +383,17 @@ FolderNode *FolderNode::folderNode(const Utils::FileName &directory) const
FolderNode *FolderNode::recursiveFindOrCreateFolderNode(const QString &directory)
{
Utils::FileName path = filePath();
QString workPath;
if (path.isEmpty() || path.toFileInfo().isRoot()) {
workPath = directory;
} else {
QDir parentDir(path.toString());
QString relativePath = parentDir.relativeFilePath(directory);
if (relativePath == ".")
relativePath.clear();
workPath = parentDir.relativeFilePath(directory);
if (workPath == ".")
workPath.clear();
}
const QStringList parts = workPath.split('/', QString::SkipEmptyParts);
QStringList parts = relativePath.split('/', QString::SkipEmptyParts);
ProjectExplorer::FolderNode *parent = this;
foreach (const QString &part, parts) {
path.appendPath(part);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment