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

Method moveAction

app/src/DataModel/ProjectModel.cpp:3877–3899  ·  view source on GitHub ↗

* @brief Moves an action within the project actions list, renumbering actionIds. */

Source from the content-addressed store, hash-verified

3875 * @brief Moves an action within the project actions list, renumbering actionIds.
3876 */
3877void 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.

Callers 1

moveCurrentActionMethod · 0.80

Calls 3

beginMethod · 0.80
clampFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected