forked from qt-creator/qt-creator
Revert "ProjectExplorer: Simplify node creation"
It breaks the project tree, at least for Qt Creator CMake project.
This reverts commit d1284570d6
.
Change-Id: Ic5fe14cd4da476ca421551968e67fb8688433bbf
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
d85dd1962b
commit
0dd8d64060
@@ -39,24 +39,37 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder,
|
|||||||
const FilePath &overrideBaseDir,
|
const FilePath &overrideBaseDir,
|
||||||
const FolderNode::FolderNodeFactory &factory)
|
const FolderNode::FolderNodeFactory &factory)
|
||||||
{
|
{
|
||||||
QList<FilePath> paths;
|
Utils::FilePath path = overrideBaseDir.isEmpty() ? folder->filePath() : overrideBaseDir;
|
||||||
const Utils::FilePath basePath = overrideBaseDir.isEmpty() ? folder->filePath()
|
|
||||||
: overrideBaseDir;
|
|
||||||
Utils::FilePath path = basePath.isEmpty() ? directory : basePath.relativeChildPath(directory);
|
|
||||||
|
|
||||||
while (!path.isEmpty()) {
|
Utils::FilePath directoryWithoutPrefix;
|
||||||
paths.append(path);
|
bool isRelative = false;
|
||||||
path = path.parentDir();
|
|
||||||
|
if (path.isEmpty() || path.isRootPath()) {
|
||||||
|
directoryWithoutPrefix = directory;
|
||||||
|
isRelative = false;
|
||||||
|
} else {
|
||||||
|
if (directory.isChildOf(path) || directory == path) {
|
||||||
|
isRelative = true;
|
||||||
|
directoryWithoutPrefix = directory.relativeChildPath(path);
|
||||||
|
} else {
|
||||||
|
isRelative = false;
|
||||||
|
path.clear();
|
||||||
|
directoryWithoutPrefix = directory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::reverse(std::begin(paths), std::end(paths));
|
QStringList parts = directoryWithoutPrefix.path().split('/', Qt::SkipEmptyParts);
|
||||||
|
if (directory.osType() != OsTypeWindows && !isRelative && !parts.isEmpty())
|
||||||
|
parts[0].prepend('/');
|
||||||
|
|
||||||
FolderNode *parent = folder;
|
ProjectExplorer::FolderNode *parent = folder;
|
||||||
for (const auto ¤tPath : paths) {
|
for (const QString &part : std::as_const(parts)) {
|
||||||
FolderNode *next = parent->folderNode(currentPath);
|
path = path.pathAppended(part);
|
||||||
|
// Find folder in subFolders
|
||||||
|
FolderNode *next = parent->folderNode(path);
|
||||||
if (!next) {
|
if (!next) {
|
||||||
// No FolderNode yet, so create it
|
// No FolderNode yet, so create it
|
||||||
auto tmp = factory(currentPath);
|
auto tmp = factory(path);
|
||||||
tmp->setDisplayName(currentPath.fileName());
|
tmp->setDisplayName(part);
|
||||||
next = tmp.get();
|
next = tmp.get();
|
||||||
parent->addNode(std::move(tmp));
|
parent->addNode(std::move(tmp));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user