| 685 | } |
| 686 | |
| 687 | void PackProfile::move(const int index, const MoveDirection direction) |
| 688 | { |
| 689 | int theirIndex; |
| 690 | if (direction == MoveUp) |
| 691 | { |
| 692 | theirIndex = index - 1; |
| 693 | } |
| 694 | else |
| 695 | { |
| 696 | theirIndex = index + 1; |
| 697 | } |
| 698 | |
| 699 | if (index < 0 || index >= d->components.size()) |
| 700 | return; |
| 701 | if (theirIndex >= rowCount()) |
| 702 | theirIndex = rowCount() - 1; |
| 703 | if (theirIndex == -1) |
| 704 | theirIndex = rowCount() - 1; |
| 705 | if (index == theirIndex) |
| 706 | return; |
| 707 | int togap = theirIndex > index ? theirIndex + 1 : theirIndex; |
| 708 | |
| 709 | auto from = getComponent(index); |
| 710 | auto to = getComponent(theirIndex); |
| 711 | |
| 712 | if (!from || !to || !to->isMoveable() || !from->isMoveable()) |
| 713 | { |
| 714 | return; |
| 715 | } |
| 716 | beginMoveRows(QModelIndex(), index, index, QModelIndex(), togap); |
| 717 | #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) |
| 718 | d->components.swapItemsAt(index, theirIndex); |
| 719 | #else |
| 720 | d->components.swap(index, theirIndex); |
| 721 | #endif |
| 722 | endMoveRows(); |
| 723 | invalidateLaunchProfile(); |
| 724 | scheduleSave(); |
| 725 | } |
| 726 | |
| 727 | void PackProfile::invalidateLaunchProfile() |
| 728 | { |
no test coverage detected