* @brief Duplicate an action by id */
| 2664 | * @brief Duplicate an action by id |
| 2665 | */ |
| 2666 | API::CommandResponse API::Handlers::ProjectHandler::actionDuplicate(const QString& id, |
| 2667 | const QJsonObject& params) |
| 2668 | { |
| 2669 | if (!params.contains(QStringLiteral("actionId"))) |
| 2670 | return CommandResponse::makeError( |
| 2671 | id, ErrorCode::MissingParam, QStringLiteral("Missing required parameter: actionId")); |
| 2672 | |
| 2673 | const int actionId = params.value(QStringLiteral("actionId")).toInt(); |
| 2674 | auto& project = DataModel::ProjectModel::instance(); |
| 2675 | const auto& actions = project.actions(); |
| 2676 | if (actionId < 0 || static_cast<size_t>(actionId) >= actions.size()) |
| 2677 | return CommandResponse::makeError( |
| 2678 | id, ErrorCode::InvalidParam, QStringLiteral("Action id not found: %1").arg(actionId)); |
| 2679 | |
| 2680 | project.duplicateAction(actionId); |
| 2681 | |
| 2682 | QJsonObject result; |
| 2683 | result[QStringLiteral("actionId")] = actionId; |
| 2684 | result[QStringLiteral("duplicated")] = true; |
| 2685 | return CommandResponse::makeSuccess(id, result); |
| 2686 | } |
| 2687 | |
| 2688 | //-------------------------------------------------------------------------------------------------- |
| 2689 | // Output widget commands |
nothing calls this directly
no test coverage detected