ProjectExplorer: Introduce a FolderNode::findProjectNode()

And use it.

Change-Id: Iaf13c4661e397bdb4d756c352683b696e337c8af
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2018-12-18 14:01:36 +01:00
parent 74723498cc
commit f2bade30cf
3 changed files with 23 additions and 8 deletions

View File

@@ -525,6 +525,22 @@ void FolderNode::forEachProjectNode(const std::function<void(const ProjectNode *
}
}
const ProjectNode *FolderNode::findProjectNode(const std::function<bool(const ProjectNode *)> &predicate) const
{
if (const ProjectNode *projectNode = asProjectNode()) {
if (predicate(projectNode))
return projectNode;
}
for (const std::unique_ptr<Node> &n : m_nodes) {
if (FolderNode *fn = n->asFolderNode()) {
if (const ProjectNode *pn = fn->findProjectNode(predicate))
return pn;
}
}
return nullptr;
}
const QList<Node *> FolderNode::nodes() const
{
return Utils::toRawPointer<QList>(m_nodes);