forked from qt-creator/qt-creator
Optimize ProjectTree for adding folders/files
Instead of searching the whole tree for the current node, only check the newly added files/folders. Change-Id: I015a955815223767367c4cad476d0620f69abd71 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -237,11 +237,16 @@ void ProjectTreeWidget::rowsInserted(const QModelIndex &parent, int start, int e
|
||||
}
|
||||
|
||||
Node *ProjectTreeWidget::nodeForFile(const Utils::FileName &fileName)
|
||||
{
|
||||
return mostExpandedNode(SessionManager::nodesForFile(fileName));
|
||||
}
|
||||
|
||||
Node *ProjectTreeWidget::mostExpandedNode(const QList<Node *> &nodes)
|
||||
{
|
||||
Node *bestNode = 0;
|
||||
int bestNodeExpandCount = INT_MAX;
|
||||
|
||||
foreach (Node *node, SessionManager::nodesForFile(fileName)) {
|
||||
foreach (Node *node, nodes) {
|
||||
if (!bestNode) {
|
||||
bestNode = node;
|
||||
bestNodeExpandCount = ProjectTreeWidget::expandedCount(node);
|
||||
@@ -256,7 +261,6 @@ Node *ProjectTreeWidget::nodeForFile(const Utils::FileName &fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return bestNode;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user