* @brief Serialises a workspace's widget refs as a QJsonArray of objects. */
| 122 | * @brief Serialises a workspace's widget refs as a QJsonArray of objects. |
| 123 | */ |
| 124 | [[nodiscard]] static QJsonArray refsToJson(int workspaceId, |
| 125 | const std::vector<DataModel::WidgetRef>& refs) |
| 126 | { |
| 127 | QJsonArray arr; |
| 128 | for (const auto& r : refs) { |
| 129 | QJsonObject entry; |
| 130 | entry[QStringLiteral("widgetType")] = r.widgetType; |
| 131 | entry[QStringLiteral("widgetTypeSlug")] = API::EnumLabels::dashboardWidgetSlug(r.widgetType); |
| 132 | entry[QStringLiteral("groupId")] = r.groupUniqueId; |
| 133 | entry[QStringLiteral("relativeIndex")] = r.relativeIndex; |
| 134 | entry[QStringLiteral("widgetId")] = |
| 135 | widgetIdFor(workspaceId, r.widgetType, r.groupUniqueId, r.relativeIndex); |
| 136 | arr.append(entry); |
| 137 | } |
| 138 | |
| 139 | return arr; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * @brief Returns a hint on how to unlock @a wtype on @a group, or empty when none applies. |
no test coverage detected