* @brief Moves an action within the project actions list, renumbering actionIds. */
| 3875 | * @brief Moves an action within the project actions list, renumbering actionIds. |
| 3876 | */ |
| 3877 | void DataModel::ProjectModel::moveAction(int fromActionId, int toActionId) |
| 3878 | { |
| 3879 | const int n = static_cast<int>(m_actions.size()); |
| 3880 | if (fromActionId < 0 || fromActionId >= n) |
| 3881 | return; |
| 3882 | |
| 3883 | const int target = std::clamp(toActionId, 0, n - 1); |
| 3884 | if (target == fromActionId) |
| 3885 | return; |
| 3886 | |
| 3887 | auto action = m_actions[fromActionId]; |
| 3888 | m_actions.erase(m_actions.begin() + fromActionId); |
| 3889 | m_actions.insert(m_actions.begin() + target, action); |
| 3890 | |
| 3891 | for (size_t i = 0; i < m_actions.size(); ++i) |
| 3892 | m_actions[i].actionId = static_cast<int>(i); |
| 3893 | |
| 3894 | if (m_selectedAction.actionId == fromActionId) |
| 3895 | m_selectedAction = m_actions[target]; |
| 3896 | |
| 3897 | Q_EMIT actionsChanged(); |
| 3898 | setModified(true); |
| 3899 | } |
| 3900 | |
| 3901 | /** |
| 3902 | * @brief Moves an output widget within its group's outputWidgets list. |
no test coverage detected