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,
|
FolderNode *createSourceGroupNode(const QString &sourceGroupName,
|
||||||
const FilePath &sourceDirectory)
|
const FilePath &sourceDirectory,
|
||||||
|
FolderNode *targetRoot)
|
||||||
{
|
{
|
||||||
if (sourceGroupName.isEmpty())
|
FolderNode *currentNode = targetRoot;
|
||||||
return {};
|
|
||||||
|
|
||||||
auto sgNode = createCMakeVFolder(sourceDirectory,
|
if (!sourceGroupName.isEmpty()) {
|
||||||
Node::DefaultFolderPriority + 5,
|
const QStringList parts = sourceGroupName.split("\\");
|
||||||
sourceGroupName);
|
|
||||||
|
|
||||||
sgNode->setListInProject(false);
|
for (const QString &p : parts) {
|
||||||
sgNode->setIcon(QIcon::fromTheme("edit-copy", ::Utils::Icons::COPY.icon()));
|
FolderNode *existingNode = Utils::findOrDefault(currentNode->folderNodes(),
|
||||||
return sgNode;
|
[&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,
|
void addCompileGroups(ProjectNode *targetRoot,
|
||||||
@@ -475,12 +491,9 @@ void addCompileGroups(ProjectNode *targetRoot,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FolderNode *insertNode = targetRoot;
|
FolderNode *insertNode = createSourceGroupNode(td.sourceGroups[i],
|
||||||
if (auto sgNode = createSourceGroupNode(td.sourceGroups[i], baseDirectory)) {
|
baseDirectory,
|
||||||
insertNode = sgNode.get();
|
targetRoot);
|
||||||
targetRoot->addNode(std::move(sgNode));
|
|
||||||
}
|
|
||||||
|
|
||||||
insertNode->addNestedNodes(std::move(sourceGroupFileNodes[i]));
|
insertNode->addNestedNodes(std::move(sourceGroupFileNodes[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user