Commit a63998f5 authored by hjk's avatar hjk
Browse files

ProjectExplorer: Avoid some needless intermediate lists



... when creating folder nodes in the flat model.

Change-Id: I28f95589d774fc83e1a30c8328707bd1db6be03e
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
(cherry picked from commit 1a416d3f

)
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
parent 2df18ec3
......@@ -264,23 +264,25 @@ void FlatModel::saveExpandData()
void FlatModel::addFolderNode(WrapperNode *parent, FolderNode *folderNode, QSet<Node *> *seen)
{
const QList<FolderNode *> subFolderNodes = folderNode->folderNodes();
for (FolderNode *subFolderNode : subFolderNodes) {
if (!filter(subFolderNode) && !seen->contains(subFolderNode)) {
seen->insert(subFolderNode);
auto node = new WrapperNode(subFolderNode);
parent->appendChild(node);
addFolderNode(node, subFolderNode, seen);
node->sortChildren(&sortWrapperNodes);
} else {
addFolderNode(parent, subFolderNode, seen);
for (Node *node : folderNode->nodes()) {
if (FolderNode *subFolderNode = node->asFolderNode()) {
if (!filter(subFolderNode) && !seen->contains(subFolderNode)) {
seen->insert(subFolderNode);
auto node = new WrapperNode(subFolderNode);
parent->appendChild(node);
addFolderNode(node, subFolderNode, seen);
node->sortChildren(&sortWrapperNodes);
} else {
addFolderNode(parent, subFolderNode, seen);
}
}
}
const QList<FileNode *> fileNodes = folderNode->fileNodes();
for (FileNode *fileNode : fileNodes) {
if (!filter(fileNode) && !seen->contains(fileNode)) {
seen->insert(fileNode);
parent->appendChild(new WrapperNode(fileNode));
for (Node *node : folderNode->nodes()) {
if (FileNode *fileNode = node->asFileNode()) {
if (!filter(fileNode) && !seen->contains(fileNode)) {
seen->insert(fileNode);
parent->appendChild(new WrapperNode(fileNode));
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment