* @brief Serializes the complete project state to a QJsonObject. */
| 1928 | * @brief Serializes the complete project state to a QJsonObject. |
| 1929 | */ |
| 1930 | QJsonObject DataModel::ProjectModel::serializeToJson() const |
| 1931 | { |
| 1932 | QJsonObject json; |
| 1933 | json.insert(Keys::Title, m_title); |
| 1934 | json.insert(Keys::PointCount, m_pointCount); |
| 1935 | json.insert(Keys::PlotTimeRange, m_plotTimeRange); |
| 1936 | json.insert(Keys::ChangeDrivenTransforms, m_changeDrivenTransforms); |
| 1937 | json.insert(Keys::HexadecimalDelimiters, m_hexadecimalDelimiters); |
| 1938 | |
| 1939 | const QString writer = DataModel::current_writer_version(); |
| 1940 | const QString creator = m_writerVersionAtCreation.isEmpty() ? writer : m_writerVersionAtCreation; |
| 1941 | json.insert(Keys::SchemaVersion, DataModel::kSchemaVersion); |
| 1942 | json.insert(Keys::WriterVersion, writer); |
| 1943 | json.insert(Keys::WriterVersionAtCreation, creator); |
| 1944 | json.insert(Keys::NextUniqueId, m_nextUniqueId); |
| 1945 | |
| 1946 | if (!m_passwordHash.isEmpty()) |
| 1947 | json.insert(Keys::PasswordHash, m_passwordHash); |
| 1948 | |
| 1949 | if (m_apiCallAllowFullSurface) |
| 1950 | json.insert(Keys::ApiCallAllowFullSurface, true); |
| 1951 | |
| 1952 | if (!m_controlScriptCode.isEmpty()) |
| 1953 | json.insert(Keys::ControlScriptCode, m_controlScriptCode); |
| 1954 | |
| 1955 | QJsonArray groupArray; |
| 1956 | for (const auto& group : std::as_const(m_groups)) |
| 1957 | groupArray.append(DataModel::serialize(group)); |
| 1958 | |
| 1959 | json.insert(Keys::Groups, groupArray); |
| 1960 | |
| 1961 | if (!m_groupFolders.empty()) |
| 1962 | json.insert(Keys::GroupFolders, serializeFolders(m_groupFolders)); |
| 1963 | |
| 1964 | QJsonArray actionsArray; |
| 1965 | for (const auto& action : std::as_const(m_actions)) |
| 1966 | actionsArray.append(DataModel::serialize(action)); |
| 1967 | |
| 1968 | json.insert(Keys::Actions, actionsArray); |
| 1969 | |
| 1970 | QJsonArray sourcesArray; |
| 1971 | for (const auto& source : std::as_const(m_sources)) |
| 1972 | sourcesArray.append(DataModel::serialize(source)); |
| 1973 | |
| 1974 | json.insert(Keys::Sources, sourcesArray); |
| 1975 | |
| 1976 | if (m_customizeWorkspaces) { |
| 1977 | json.insert(Keys::CustomizeWorkspaces, true); |
| 1978 | |
| 1979 | QJsonArray workspacesArray; |
| 1980 | for (const auto& ws : std::as_const(m_workspaces)) |
| 1981 | workspacesArray.append(DataModel::serialize(ws)); |
| 1982 | |
| 1983 | json.insert(Keys::Workspaces, workspacesArray); |
| 1984 | |
| 1985 | QJsonArray foldersArray; |
| 1986 | for (const auto& folder : std::as_const(m_workspaceFolders)) |
| 1987 | foldersArray.append(DataModel::serialize(folder)); |
no test coverage detected