forked from qt-creator/qt-creator
CMake: Support nested source_groups
Support nesting of source groups based on the source group name, split at "\\" strings. Change-Id: I6c0e5c64b2b4ee84cd07cde1ff5accc5c3b853df Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
@@ -396,19 +396,35 @@ void addProjects(const QHash<Utils::FilePath, ProjectNode *> &cmakeListsNodes,
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<FolderNode> createSourceGroupNode(const QString &sourceGroupName,
|
||||
const FilePath &sourceDirectory)
|
||||
FolderNode *createSourceGroupNode(const QString &sourceGroupName,
|
||||
const FilePath &sourceDirectory,
|
||||
FolderNode *targetRoot)
|
||||
{
|
||||
if (sourceGroupName.isEmpty())
|
||||
return {};
|
||||
FolderNode *currentNode = targetRoot;
|
||||
|
||||
auto sgNode = createCMakeVFolder(sourceDirectory,
|
||||
Node::DefaultFolderPriority + 5,
|
||||
sourceGroupName);
|
||||
if (!sourceGroupName.isEmpty()) {
|
||||
const QStringList parts = sourceGroupName.split("\\");
|
||||
|
||||
sgNode->setListInProject(false);
|
||||
sgNode->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));
|
||||
return sgNode;
|
||||
for (const QString &p : parts) {
|
||||
FolderNode *existingNode = Utils::findOrDefault(currentNode->folderNodes(),
|
||||
[&p](const FolderNode *fn) {
|
||||
return fn->displayName() == p;
|
||||
});
|
||||
|
||||
if (!existingNode) {
|
||||
auto node = createCMakeVFolder(sourceDirectory, Node::DefaultFolderPriority + 5, p);
|
||||
node->setListInProject(false);
|
||||
node->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));
|
||||
|
||||
existingNode = node.get();
|
||||
|
||||
currentNode->addNode(std::move(node));
|
||||
}
|
||||
|
||||
currentNode = existingNode;
|
||||
}
|
||||
}
|
||||
return currentNode;
|
||||
}
|
||||
|
||||
void addCompileGroups(ProjectNode *targetRoot,
|
||||
@@ -475,12 +491,9 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
}
|
||||
}
|
||||
|
||||
FolderNode *insertNode = targetRoot;
|
||||
if (auto sgNode = createSourceGroupNode(td.sourceGroups[i], baseDirectory)) {
|
||||
insertNode = sgNode.get();
|
||||
targetRoot->addNode(std::move(sgNode));
|
||||
}
|
||||
|
||||
FolderNode *insertNode = createSourceGroupNode(td.sourceGroups[i],
|
||||
baseDirectory,
|
||||
targetRoot);
|
||||
insertNode->addNestedNodes(std::move(sourceGroupFileNodes[i]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user