* @brief Moves the currently selected dataset within its group. */
| 6595 | * @brief Moves the currently selected dataset within its group. |
| 6596 | */ |
| 6597 | bool DataModel::ProjectEditor::moveCurrentDataset(int direction) |
| 6598 | { |
| 6599 | if (m_currentView != DatasetView) |
| 6600 | return false; |
| 6601 | |
| 6602 | const int gid = m_selectedDataset.groupId; |
| 6603 | const int did = m_selectedDataset.datasetId; |
| 6604 | if (gid < 0 || did < 0) |
| 6605 | return false; |
| 6606 | |
| 6607 | const auto& groups = DataModel::ProjectModel::instance().groups(); |
| 6608 | if (static_cast<size_t>(gid) >= groups.size()) |
| 6609 | return false; |
| 6610 | |
| 6611 | const int n = static_cast<int>(groups[gid].datasets.size()); |
| 6612 | const int target = did + (direction < 0 ? -1 : 1); |
| 6613 | if (target < 0 || target >= n) |
| 6614 | return false; |
| 6615 | |
| 6616 | m_pendingSelectionKind = PendingSelectionKind::Dataset; |
| 6617 | m_pendingSelectionGroupId = gid; |
| 6618 | m_pendingSelectionItemId = target; |
| 6619 | DataModel::ProjectModel::instance().moveDataset(gid, did, target); |
| 6620 | return true; |
| 6621 | } |
| 6622 | |
| 6623 | /** |
| 6624 | * @brief Moves the currently selected action up or down in the actions list. |
nothing calls this directly
no test coverage detected