MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / move

Method move

launcher/minecraft/PackProfile.cpp:687–725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685}
686
687void 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
727void PackProfile::invalidateLaunchProfile()
728{

Callers 3

startMethod · 0.80

Calls 3

QModelIndexClass · 0.85
isMoveableMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected