* @brief Materialises the synthetic workspace list into m_workspaces and flips the project into * customize mode so the user can edit it from there. */
| 7060 | * customize mode so the user can edit it from there. |
| 7061 | */ |
| 7062 | int DataModel::ProjectModel::autoGenerateWorkspaces() |
| 7063 | { |
| 7064 | if (AppState::instance().operationMode() != SerialStudio::ProjectFile) |
| 7065 | return -1; |
| 7066 | |
| 7067 | if (m_customizeWorkspaces && !m_workspaces.empty()) |
| 7068 | return m_workspaces.front().workspaceId; |
| 7069 | |
| 7070 | auto seed = buildAutoWorkspaces(); |
| 7071 | if (seed.empty()) |
| 7072 | return -1; |
| 7073 | |
| 7074 | m_workspaces = std::move(seed); |
| 7075 | m_workspaceFolders = buildAutoWorkspaceFoldersFor(m_workspaces); |
| 7076 | m_autoSnapshot = m_workspaces; |
| 7077 | const bool flagChanged = !m_customizeWorkspaces; |
| 7078 | m_customizeWorkspaces = true; |
| 7079 | |
| 7080 | Q_ASSERT(!m_workspaces.empty()); |
| 7081 | Q_ASSERT(m_workspaces.front().workspaceId >= WorkspaceIds::AutoStart); |
| 7082 | |
| 7083 | setModified(true); |
| 7084 | if (flagChanged) |
| 7085 | Q_EMIT customizeWorkspacesChanged(); |
| 7086 | |
| 7087 | Q_EMIT editorWorkspacesChanged(); |
| 7088 | Q_EMIT activeWorkspacesChanged(); |
| 7089 | return m_workspaces.front().workspaceId; |
| 7090 | } |
| 7091 | |
| 7092 | /** |
| 7093 | * @brief Repairs folder records after load: detaches cyclic or dangling folder parents and |
no test coverage detected