ProjectExplorer: Move Node::nodeType implementation

... to the only remaining user, and rename it there.

Change-Id: I0bdb3179282e323f5ad7b41d034bb5f3db8f6ffc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-03-01 11:02:29 +01:00
parent 32c3867131
commit b0e125ac11
3 changed files with 17 additions and 24 deletions

View File

@@ -355,6 +355,21 @@ Node *ProjectTreeWidget::nodeForFile(const FileName &fileName)
Node *bestNode = nullptr;
int bestNodeExpandCount = INT_MAX;
// FIXME: Check that the values used make sense in the context.
auto priority = [](Node *node) {
if (node->asFileNode())
return 1;
if (node->isFolderNodeType())
return 2;
if (node->isVirtualFolderType())
return 3;
if (node->isProjectNodeType())
return 4;
QTC_CHECK(false);
return 1;
};
// FIXME: Looks like this could be done with less cycles.
for (Project *project : SessionManager::projects()) {
if (ProjectNode *projectNode = project->rootProjectNode()) {
projectNode->forEachGenericNode([&](Node *node) {
@@ -362,10 +377,10 @@ Node *ProjectTreeWidget::nodeForFile(const FileName &fileName)
if (!bestNode) {
bestNode = node;
bestNodeExpandCount = ProjectTreeWidget::expandedCount(node);
} else if (node->nodeType() < bestNode->nodeType()) {
} else if (priority(node) < priority(bestNode)) {
bestNode = node;
bestNodeExpandCount = ProjectTreeWidget::expandedCount(node);
} else if (node->nodeType() == bestNode->nodeType()) {
} else if (priority(node) == priority(bestNode)) {
int nodeExpandCount = ProjectTreeWidget::expandedCount(node);
if (nodeExpandCount < bestNodeExpandCount) {
bestNode = node;