* @brief Validates each group and its datasets against the source-id set. */
| 5750 | * @brief Validates each group and its datasets against the source-id set. |
| 5751 | */ |
| 5752 | static void validateGroups(const std::vector<DataModel::Group>& groups, |
| 5753 | const QSet<int>& sourceIds, |
| 5754 | QJsonArray& issues, |
| 5755 | bool& ok) |
| 5756 | { |
| 5757 | for (const auto& g : groups) { |
| 5758 | const QString gloc = QStringLiteral("group[%1]").arg(g.groupId); |
| 5759 | |
| 5760 | if (g.title.trimmed().isEmpty()) |
| 5761 | addIssue(issues, QStringLiteral("warning"), gloc, QStringLiteral("Group has no title")); |
| 5762 | |
| 5763 | if (g.datasets.empty()) |
| 5764 | addIssue(issues, |
| 5765 | QStringLiteral("warning"), |
| 5766 | gloc, |
| 5767 | QStringLiteral("Group has no datasets; nothing to display")); |
| 5768 | |
| 5769 | if (!sourceIds.contains(g.sourceId)) { |
| 5770 | ok = false; |
| 5771 | addIssue(issues, |
| 5772 | QStringLiteral("error"), |
| 5773 | gloc, |
| 5774 | QStringLiteral("Group references missing source id %1").arg(g.sourceId)); |
| 5775 | } |
| 5776 | |
| 5777 | QSet<int> datasetIndexes; |
| 5778 | for (const auto& d : g.datasets) |
| 5779 | validateDataset(d, g, sourceIds, datasetIndexes, issues, ok); |
| 5780 | } |
| 5781 | } |
| 5782 | |
| 5783 | /** |
| 5784 | * @brief Validates actions (non-blocking sanity checks: titles, payloads). |