CMakeProjectManager: Add File System virtual folder

If a CMake project cannot be parsed by CMake, it is practically unusable in
Qt Creator. According to discussion in QTCREATORBUG-24677, a virtual
folder with the project's file system view is added to the project
manager as a convenience feature.

Fixes: QTCREATORBUG-24677
Change-Id: I48775bb89c704d3f7e5bb21ec6481bd5cc0f4b6c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Dmitriy Purgin
2020-10-26 15:36:59 +01:00
parent 56eb7628c3
commit 53115259ba
8 changed files with 94 additions and 14 deletions

View File

@@ -208,5 +208,31 @@ void addHeaderNodes(ProjectNode *root,
root->addNode(std::move(headerNode));
}
void addFileSystemNodes(ProjectNode *root, const QList<const FileNode *> &allFiles)
{
QTC_ASSERT(root, return );
static QIcon fileSystemNodeIcon = Core::FileIconProvider::directoryIcon(
ProjectExplorer::Constants::FILEOVERLAY_UNKNOWN);
auto fileSystemNode = std::make_unique<VirtualFolderNode>(root->filePath());
fileSystemNode->setPriority(Node::DefaultPriority - 6);
fileSystemNode->setDisplayName(
QCoreApplication::translate("CMakeProjectManager::Internal::ProjectTreeHelper",
"<File System>"));
fileSystemNode->setIcon(fileSystemNodeIcon);
for (const FileNode *fn : allFiles) {
if (!fn->filePath().isChildOf(root->filePath()))
continue;
std::unique_ptr<FileNode> node(fn->clone());
node->setEnabled(false);
fileSystemNode->addNestedNode(std::move(node));
}
if (!fileSystemNode->isEmpty())
root->addNode(std::move(fileSystemNode));
}
} // namespace Internal
} // namespace CMakeProjectManager