Qbs: Simplify updateBuildActions()

Now that the sub-project cases are gone, part of the logic are dead.

Change-Id: I37d5bb7fe82ba5d8d2b064dd5231daf201ee6d67
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-02-26 16:35:47 +01:00
parent 55b87968f4
commit e318ecd81d

View File

@@ -314,32 +314,24 @@ void QbsProjectManagerPlugin::updateBuildActions()
bool enabled = false; bool enabled = false;
bool fileVisible = false; bool fileVisible = false;
bool productVisible = false; bool productVisible = false;
bool subprojectVisible = false;
QString fileName; QString fileName;
QString productName; QString productName;
QString subprojectName;
if (Node *editorNode = currentEditorNode()) { if (Node *editorNode = currentEditorNode()) {
QbsProject *editorProject = currentEditorProject();
enabled = editorProject
&& !BuildManager::isBuilding(editorProject)
&& !editorProject->isParsing();
fileName = editorNode->filePath().fileName(); fileName = editorNode->filePath().fileName();
fileVisible = editorProject && editorNode && dynamic_cast<QbsBaseProjectNode *>(editorNode->parentProjectNode());
auto productNode = // FIXME: This code is wrong: If the file is in a Group, then productNode will be
dynamic_cast<QbsProductNode *>(editorNode ? editorNode->parentProjectNode() : nullptr); // null and the action will be disabled. We have to walk up the tree.
auto productNode = dynamic_cast<QbsProductNode *>(editorNode->parentProjectNode());
if (productNode) { if (productNode) {
productVisible = true; productVisible = true;
productName = productNode->displayName(); productName = productNode->displayName();
} }
auto subprojectNode =
dynamic_cast<QbsProjectNode *>(productNode ? productNode->parentFolderNode() : nullptr); if (QbsProject *editorProject = currentEditorProject()) {
if (subprojectNode && editorProject && subprojectNode != editorProject->rootProjectNode()) { enabled = !BuildManager::isBuilding(editorProject) && !editorProject->isParsing();
subprojectVisible = true; fileVisible = dynamic_cast<QbsBaseProjectNode *>(editorNode->parentProjectNode());
subprojectName = subprojectNode->displayName();
} }
} }