forked from qt-creator/qt-creator
ProjectExplorer: Make Node::pathOrDirectory work for remote files
Change-Id: I643456c0ba691ed4a89d4c6020dea148f6a47f1a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -321,9 +321,9 @@ FileType Node::fileTypeForFileName(const Utils::FilePath &file)
|
||||
|
||||
FilePath Node::pathOrDirectory(bool dir) const
|
||||
{
|
||||
FilePath location;
|
||||
const FolderNode *folder = asFolderNode();
|
||||
if (isVirtualFolderType() && folder) {
|
||||
FilePath location;
|
||||
// Virtual Folder case
|
||||
// If there are files directly below or no subfolders, take the folder path
|
||||
if (!folder->fileNodes().isEmpty() || folder->folderNodes().isEmpty()) {
|
||||
@@ -341,9 +341,19 @@ FilePath Node::pathOrDirectory(bool dir) const
|
||||
QFileInfo fi = location.toFileInfo();
|
||||
while ((!fi.exists() || !fi.isDir()) && !fi.isRoot())
|
||||
fi.setFile(fi.absolutePath());
|
||||
location = FilePath::fromString(fi.absoluteFilePath());
|
||||
} else if (!m_filePath.isEmpty()) {
|
||||
QTC_CHECK(!m_filePath.needsDevice());
|
||||
return FilePath::fromString(fi.absoluteFilePath());
|
||||
}
|
||||
|
||||
if (m_filePath.isEmpty())
|
||||
return {};
|
||||
|
||||
if (m_filePath.needsDevice()) {
|
||||
if (dir)
|
||||
return m_filePath.isDir() ? m_filePath.absoluteFilePath() : m_filePath.absolutePath();
|
||||
return m_filePath;
|
||||
}
|
||||
|
||||
FilePath location;
|
||||
QFileInfo fi = m_filePath.toFileInfo();
|
||||
// remove any /suffixes, which e.g. ResourceNode uses
|
||||
// Note this could be removed again by making path() a true path again
|
||||
@@ -355,7 +365,7 @@ FilePath Node::pathOrDirectory(bool dir) const
|
||||
location = FilePath::fromString(fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath());
|
||||
else
|
||||
location = FilePath::fromString(fi.absoluteFilePath());
|
||||
}
|
||||
|
||||
return location;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user