* @brief Resolves a workspace from args, optionally creating one when allowed. */
| 1537 | * @brief Resolves a workspace from args, optionally creating one when allowed. |
| 1538 | */ |
| 1539 | static QJsonObject resolveOrCreateTileWorkspace(const QJsonObject& args, QJsonArray& steps) |
| 1540 | { |
| 1541 | QJsonObject wsArgs; |
| 1542 | if (args.contains(QStringLiteral("workspaceId"))) |
| 1543 | wsArgs[QStringLiteral("workspaceId")] = args.value(QStringLiteral("workspaceId")).toInt(); |
| 1544 | |
| 1545 | if (!args.value(QStringLiteral("workspace")).toString().isEmpty()) |
| 1546 | wsArgs[QStringLiteral("title")] = args.value(QStringLiteral("workspace")).toString(); |
| 1547 | |
| 1548 | auto wsReply = resolveWorkspace(wsArgs); |
| 1549 | if (wsReply.value(QStringLiteral("ok")).toBool()) |
| 1550 | return wsReply; |
| 1551 | |
| 1552 | const auto workspaceTitle = args.value(QStringLiteral("workspace")).toString(); |
| 1553 | if (workspaceTitle.isEmpty() || !args.value(QStringLiteral("createWorkspace")).toBool(false)) |
| 1554 | return wsReply; |
| 1555 | |
| 1556 | const auto addWsReply = createTileWorkspace(workspaceTitle, steps); |
| 1557 | if (!addWsReply.value(QStringLiteral("ok")).toBool()) |
| 1558 | return attachRepairHint(addWsReply, QStringLiteral("project.workspace.add")); |
| 1559 | |
| 1560 | QJsonObject created = addWsReply.value(QStringLiteral("result")).toObject(); |
| 1561 | created[QStringLiteral("widgetCount")] = 0; |
| 1562 | wsReply[QStringLiteral("ok")] = true; |
| 1563 | wsReply[QStringLiteral("workspace")] = created; |
| 1564 | return wsReply; |
| 1565 | } |
| 1566 | |
| 1567 | /** |
| 1568 | * @brief Resolves an optional dataset reference for the tile, updating group args in place. |
no test coverage detected