* @brief Deletes the group at @p groupId; opt-in confirmation reuses deleteCurrentGroup's dialog. */
| 7875 | * @brief Deletes the group at @p groupId; opt-in confirmation reuses deleteCurrentGroup's dialog. |
| 7876 | */ |
| 7877 | void DataModel::ProjectModel::deleteGroup(int groupId, bool confirm) |
| 7878 | { |
| 7879 | if (groupId < 0 || static_cast<size_t>(groupId) >= m_groups.size()) |
| 7880 | return; |
| 7881 | |
| 7882 | const auto previousSelection = m_selectedGroup; |
| 7883 | setSelectedGroup(m_groups[groupId]); |
| 7884 | |
| 7885 | const bool previousSuppress = m_suppressMessageBoxes; |
| 7886 | m_suppressMessageBoxes = !confirm; |
| 7887 | deleteCurrentGroup(); |
| 7888 | m_suppressMessageBoxes = previousSuppress; |
| 7889 | |
| 7890 | if (previousSelection.groupId >= 0 |
| 7891 | && static_cast<size_t>(previousSelection.groupId) < m_groups.size() |
| 7892 | && previousSelection.groupId != groupId) |
| 7893 | setSelectedGroup(m_groups[previousSelection.groupId]); |
| 7894 | } |
| 7895 | |
| 7896 | /** |
| 7897 | * @brief Duplicates the group at @p groupId via the existing selection-based path. |