MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / addWorkspace

Method addWorkspace

app/src/DataModel/ProjectModel.cpp:5055–5077  ·  view source on GitHub ↗

* @brief Creates a new user-defined workspace with the given title. */

Source from the content-addressed store, hash-verified

5053 * @brief Creates a new user-defined workspace with the given title.
5054 */
5055int 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.

Callers 2

addMethod · 0.80
createWorkspaceMethod · 0.80

Calls 2

operationModeMethod · 0.80
isEmptyMethod · 0.80

Tested by

no test coverage detected