* @brief Returns a structured snapshot of the active project (sources, groups, tables, hint). */
| 3879 | * @brief Returns a structured snapshot of the active project (sources, groups, tables, hint). |
| 3880 | */ |
| 3881 | API::CommandResponse API::Handlers::ProjectHandler::projectSnapshot(const QString& id, |
| 3882 | const QJsonObject& params) |
| 3883 | { |
| 3884 | const bool verbose = params.value(QStringLiteral("verbose")).toBool(false); |
| 3885 | const auto& pm = DataModel::ProjectModel::instance(); |
| 3886 | |
| 3887 | QJsonObject snapshot; |
| 3888 | snapshot[Keys::Title] = pm.title(); |
| 3889 | snapshot[Keys::PointCount] = pm.pointCount(); |
| 3890 | snapshot[QStringLiteral("filePath")] = pm.jsonFilePath(); |
| 3891 | snapshot[QStringLiteral("modified")] = pm.modified(); |
| 3892 | snapshot[QStringLiteral("sources")] = buildSnapshotSources(pm, verbose); |
| 3893 | |
| 3894 | int totalDatasets = 0; |
| 3895 | const QJsonArray groups = buildSnapshotGroups(pm, totalDatasets); |
| 3896 | snapshot[QStringLiteral("groups")] = groups; |
| 3897 | snapshot[QStringLiteral("groupCount")] = groups.size(); |
| 3898 | snapshot[QStringLiteral("datasetCount")] = totalDatasets; |
| 3899 | snapshot[QStringLiteral("workspaces")] = buildSnapshotWorkspaces(pm); |
| 3900 | snapshot[QStringLiteral("dataTables")] = buildSnapshotTables(pm); |
| 3901 | |
| 3902 | const int operationMode = static_cast<int>(AppState::instance().operationMode()); |
| 3903 | snapshot[QStringLiteral("operationMode")] = operationMode; |
| 3904 | snapshot[QStringLiteral("_explanations")] = |
| 3905 | buildSnapshotExplanations(pm, operationMode, totalDatasets); |
| 3906 | |
| 3907 | QJsonObject result; |
| 3908 | result[QStringLiteral("snapshot")] = snapshot; |
| 3909 | result[QStringLiteral("hint")] = buildSnapshotHint(totalDatasets); |
| 3910 | attachProjectEpoch(result); |
| 3911 | return CommandResponse::makeSuccess(id, result); |
| 3912 | } |
| 3913 | |
| 3914 | /** |
| 3915 | * @brief Returns datasets in the order FrameBuilder traverses them. |
nothing calls this directly
no test coverage detected