CMakePM: Treat all sourceGroups as sourcesOrHeaders project nodes

Previously only "Source Files" and "Header Files" were treated as
sourceOrHeaders project nodes.

But source_group can introduce a new source group which needs to be also
treated as sourcesOrHeaders project node.

Fixes: QTCREATORBUG-29799
Change-Id: I833d80155fba3fb0269aeab149ea74b0d2edd271
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2023-10-30 14:54:25 +01:00
parent 4a220ab20a
commit 973e9dcf90
3 changed files with 11 additions and 8 deletions

View File

@@ -594,7 +594,7 @@ static FolderNode *createSourceGroupNode(const QString &sourceGroupName,
FolderNode *existingNode = currentNode->findChildFolderNode( FolderNode *existingNode = currentNode->findChildFolderNode(
[&p](const FolderNode *fn) { return fn->displayName() == p; }); [&p](const FolderNode *fn) { return fn->displayName() == p; });
if (!existingNode) { if (!existingNode) {
auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p); auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p, true);
node->setListInProject(false); node->setListInProject(false);
node->setIcon([] { return Icon::fromTheme("edit-copy"); }); node->setIcon([] { return Icon::fromTheme("edit-copy"); });

View File

@@ -19,13 +19,13 @@ namespace CMakeProjectManager::Internal {
std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath, std::unique_ptr<FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName) const QString &displayName,
bool sourcesOrHeaders)
{ {
auto newFolder = std::make_unique<VirtualFolderNode>(basePath); auto newFolder = std::make_unique<VirtualFolderNode>(basePath);
newFolder->setPriority(priority); newFolder->setPriority(priority);
newFolder->setDisplayName(displayName); newFolder->setDisplayName(displayName);
newFolder->setIsSourcesOrHeaders(displayName == "Source Files" newFolder->setIsSourcesOrHeaders(sourcesOrHeaders);
|| displayName == "Header Files");
return newFolder; return newFolder;
} }
@@ -33,13 +33,14 @@ void addCMakeVFolder(FolderNode *base,
const Utils::FilePath &basePath, const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName, const QString &displayName,
std::vector<std::unique_ptr<FileNode>> &&files) std::vector<std::unique_ptr<FileNode>> &&files,
bool sourcesOrHeaders)
{ {
if (files.size() == 0) if (files.size() == 0)
return; return;
FolderNode *folder = base; FolderNode *folder = base;
if (!displayName.isEmpty()) { if (!displayName.isEmpty()) {
auto newFolder = createCMakeVFolder(basePath, priority, displayName); auto newFolder = createCMakeVFolder(basePath, priority, displayName, sourcesOrHeaders);
folder = newFolder.get(); folder = newFolder.get();
base->addNode(std::move(newFolder)); base->addNode(std::move(newFolder));
} }

View File

@@ -11,13 +11,15 @@ namespace CMakeProjectManager::Internal {
std::unique_ptr<ProjectExplorer::FolderNode> createCMakeVFolder(const Utils::FilePath &basePath, std::unique_ptr<ProjectExplorer::FolderNode> createCMakeVFolder(const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName); const QString &displayName,
bool sourcesOrHeaders);
void addCMakeVFolder(ProjectExplorer::FolderNode *base, void addCMakeVFolder(ProjectExplorer::FolderNode *base,
const Utils::FilePath &basePath, const Utils::FilePath &basePath,
int priority, int priority,
const QString &displayName, const QString &displayName,
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&files); std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&files,
bool sourcesOrHeaders = false);
std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&removeKnownNodes( std::vector<std::unique_ptr<ProjectExplorer::FileNode>> &&removeKnownNodes(
const QSet<Utils::FilePath> &knownFiles, const QSet<Utils::FilePath> &knownFiles,