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

Method actionDelete

app/src/API/Handlers/ProjectHandler.cpp:2641–2661  ·  view source on GitHub ↗

* @brief Delete an action by id */

Source from the content-addressed store, hash-verified

2639 * @brief Delete an action by id
2640 */
2641API::CommandResponse API::Handlers::ProjectHandler::actionDelete(const QString& id,
2642 const QJsonObject& params)
2643{
2644 if (!params.contains(QStringLiteral("actionId")))
2645 return CommandResponse::makeError(
2646 id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: actionId"));
2647
2648 const int actionId = params.value(QStringLiteral("actionId")).toInt();
2649 auto& project = DataModel::ProjectModel::instance();
2650 const auto& actions = project.actions();
2651 if (actionId < 0 || static_cast<size_t>(actionId) >= actions.size())
2652 return CommandResponse::makeError(
2653 id, ErrorCode::InvalidParam, QStringLiteral("Action id not found: %1").arg(actionId));
2654
2655 project.deleteAction(actionId);
2656
2657 QJsonObject result;
2658 result[QStringLiteral("actionId")] = actionId;
2659 result[QStringLiteral("deleted")] = true;
2660 return CommandResponse::makeSuccess(id, result);
2661}
2662
2663/**
2664 * @brief Duplicate an action by id

Callers

nothing calls this directly

Calls 5

actionsMethod · 0.80
deleteActionMethod · 0.80
containsMethod · 0.45
valueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected