* @brief Resolves an optional dataset reference for the tile, updating group args in place. */
| 1568 | * @brief Resolves an optional dataset reference for the tile, updating group args in place. |
| 1569 | */ |
| 1570 | static QJsonObject resolveTileDataset(const QJsonObject& args, QJsonObject& groupArgs) |
| 1571 | { |
| 1572 | const bool hasDatasetRef = |
| 1573 | !args.value(QStringLiteral("dataset")).toString().isEmpty() || args.contains(Keys::UniqueId); |
| 1574 | if (!hasDatasetRef) |
| 1575 | return {}; |
| 1576 | |
| 1577 | QJsonObject dsArgs; |
| 1578 | if (args.contains(Keys::UniqueId)) |
| 1579 | dsArgs[Keys::UniqueId] = args.value(Keys::UniqueId).toInt(); |
| 1580 | |
| 1581 | const auto datasetName = args.value(QStringLiteral("dataset")).toString(); |
| 1582 | if (datasetName.contains(QLatin1Char('/'))) |
| 1583 | dsArgs[QStringLiteral("path")] = datasetName; |
| 1584 | else if (!datasetName.isEmpty()) |
| 1585 | dsArgs[QStringLiteral("title")] = datasetName; |
| 1586 | |
| 1587 | if (args.contains(QStringLiteral("groupId"))) |
| 1588 | dsArgs[QStringLiteral("groupId")] = args.value(QStringLiteral("groupId")).toInt(); |
| 1589 | |
| 1590 | const auto dsReply = resolveDataset(dsArgs); |
| 1591 | if (!dsReply.value(QStringLiteral("ok")).toBool()) |
| 1592 | return dsReply; |
| 1593 | |
| 1594 | const auto dataset = dsReply.value(QStringLiteral("dataset")).toObject(); |
| 1595 | if (!groupArgs.contains(QStringLiteral("groupId"))) |
| 1596 | groupArgs[QStringLiteral("groupId")] = dataset.value(QStringLiteral("groupId")).toInt(); |
| 1597 | |
| 1598 | return dsReply; |
| 1599 | } |
| 1600 | |
| 1601 | /** |
| 1602 | * @brief Enables the dataset option a widget type requires, recording the API step. |
no test coverage detected