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

Method add

app/src/API/Handlers/WorkspacesHandler.cpp:779–795  ·  view source on GitHub ↗

* @brief Creates a new workspace; returns the assigned id. */

Source from the content-addressed store, hash-verified

777 * @brief Creates a new workspace; returns the assigned id.
778 */
779API::CommandResponse API::Handlers::WorkspacesHandler::add(const QString& id,
780 const QJsonObject& params)
781{
782 if (!inProjectFileMode())
783 return CommandResponse::makeError(
784 id, ErrorCode::InvalidParam, QStringLiteral("Workspace mutations require ProjectFile mode"));
785
786 const QString title = params.value(QStringLiteral("title")).toString(QStringLiteral("Workspace"));
787
788 const int newId = DataModel::ProjectModel::instance().addWorkspace(title);
789
790 QJsonObject result;
791 result[QStringLiteral("id")] = newId;
792 result[QStringLiteral("title")] = title;
793 result[QStringLiteral("added")] = true;
794 return CommandResponse::makeSuccess(id, result);
795}
796
797/**
798 * @brief Deletes a workspace. No-op if id not found.

Callers

nothing calls this directly

Calls 3

inProjectFileModeFunction · 0.85
addWorkspaceMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected