ProjectExplorer: Add a FolderNode::addNestedNode() function

Also, rename buildTree() to addNestedNodes(), it's really
adding things, not recompletely (re-)building the subtree.

Use it whenever possible to avoid intermediate lists of items
to insert.

Change-Id: I5fde41e5b164a8a292410bd381a85f5efadf3471
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
hjk
2017-03-10 17:30:40 +01:00
parent 7428aa9cec
commit 4d8352a6c1
10 changed files with 46 additions and 55 deletions

View File

@@ -556,14 +556,11 @@ void PythonProject::refresh()
parseProject();
QDir baseDir(projectDirectory().toString());
QList<FileNode *> fileNodes
= Utils::transform(m_files, [baseDir](const QString &f) -> FileNode * {
const QString displayName = baseDir.relativeFilePath(f);
return new PythonFileNode(FileName::fromString(f), displayName);
});
auto newRoot = new PythonProjectNode(this);
newRoot->buildTree(fileNodes);
for (const QString &f : m_files) {
const QString displayName = baseDir.relativeFilePath(f);
newRoot->addNestedNode(new PythonFileNode(FileName::fromString(f), displayName));
}
setRootProjectNode(newRoot);
emit parsingFinished();