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

Method get

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

* @brief Returns widget refs for a single workspace. */

Source from the content-addressed store, hash-verified

746 * @brief Returns widget refs for a single workspace.
747 */
748API::CommandResponse API::Handlers::WorkspacesHandler::get(const QString& id,
749 const QJsonObject& params)
750{
751 if (!params.contains(QStringLiteral("id")))
752 return CommandResponse::makeError(
753 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: id"));
754
755 const int wid = params.value(QStringLiteral("id")).toInt();
756
757 const auto& workspaces = DataModel::ProjectModel::instance().activeWorkspaces();
758 const auto it = findWorkspace(workspaces, wid);
759 if (it == workspaces.end())
760 return CommandResponse::makeError(
761 id, ErrorCode::InvalidParam, QStringLiteral("Workspace not found: %1").arg(wid));
762
763 QJsonObject result;
764 result[QStringLiteral("id")] = it->workspaceId;
765 result[QStringLiteral("title")] = it->title;
766 result[QStringLiteral("icon")] = it->icon;
767 result[QStringLiteral("description")] = it->description;
768 result[QStringLiteral("widgets")] = refsToJson(it->workspaceId, it->widgetRefs);
769 return CommandResponse::makeSuccess(id, result);
770}
771
772//--------------------------------------------------------------------------------------------------
773// Mutations

Callers

nothing calls this directly

Calls 4

findWorkspaceFunction · 0.85
refsToJsonFunction · 0.85
containsMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected