* @brief Creates a new user-defined workspace with the given title. */
| 5053 | * @brief Creates a new user-defined workspace with the given title. |
| 5054 | */ |
| 5055 | int DataModel::ProjectModel::addWorkspace(const QString& title) |
| 5056 | { |
| 5057 | if (AppState::instance().operationMode() != SerialStudio::ProjectFile) |
| 5058 | return -1; |
| 5059 | |
| 5060 | if (!m_customizeWorkspaces) |
| 5061 | setCustomizeWorkspaces(true); |
| 5062 | |
| 5063 | int maxId = WorkspaceIds::UserStart - 1; |
| 5064 | for (const auto& ws : m_workspaces) |
| 5065 | if (ws.workspaceId >= WorkspaceIds::UserStart && ws.workspaceId > maxId) |
| 5066 | maxId = ws.workspaceId; |
| 5067 | |
| 5068 | DataModel::Workspace ws; |
| 5069 | ws.workspaceId = maxId + 1; |
| 5070 | ws.title = title.simplified().isEmpty() ? tr("Workspace") : title.simplified(); |
| 5071 | m_workspaces.push_back(ws); |
| 5072 | |
| 5073 | setModified(true); |
| 5074 | Q_EMIT editorWorkspacesChanged(); |
| 5075 | Q_EMIT activeWorkspacesChanged(); |
| 5076 | return ws.workspaceId; |
| 5077 | } |
| 5078 | |
| 5079 | /** |
| 5080 | * @brief Deletes the workspace with the given ID. |
no test coverage detected