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