* @brief Creates a new workspace; returns the assigned id. */
| 777 | * @brief Creates a new workspace; returns the assigned id. |
| 778 | */ |
| 779 | API::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. |
nothing calls this directly
no test coverage detected