From d01c22b8057b5eeea5661777c6dd56a71554bf55 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 27 Oct 2022 12:09:05 +0200 Subject: [PATCH] ProjectExplorer: Show near paths as relative Previously if a path was not a child of the directory it was inserted into it would be displayed as an absolute path. This changes it to show it relative with ".." as long as there are no more than 5 "../"'s. Fixes: QTCREATORBUG-288 Change-Id: I456138e97298d58ac6d95e69443c8e187fb8782c Reviewed-by: Eike Ziller Reviewed-by: --- src/plugins/projectexplorer/projectnodes.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index a0e24f80ae1..45f185e5682 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -52,9 +52,15 @@ static FolderNode *recursiveFindOrCreateFolderNode(FolderNode *folder, isRelative = true; directoryWithoutPrefix = directory.relativeChildPath(path); } else { - isRelative = false; - path.clear(); - directoryWithoutPrefix = directory; + const FilePath relativePath = directory.relativePathFrom(path); + if (relativePath.path().count("../") < 5) { + isRelative = true; + directoryWithoutPrefix = relativePath; + } else { + isRelative = false; + path.clear(); + directoryWithoutPrefix = directory; + } } } QStringList parts = directoryWithoutPrefix.path().split('/', Qt::SkipEmptyParts);