moving slides after moving serviceItems, need to fix count of slides

This commit is contained in:
Chris Cochrun 2023-01-24 06:17:47 -06:00
parent 02c4c8a47a
commit 08ed111efc
5 changed files with 47 additions and 6 deletions

View file

@ -373,8 +373,8 @@ void ServiceItemModel::removeItem(int index) {
}
bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
qDebug() << index(sourceIndex).row();
qDebug() << index(destIndex).row();
qDebug() << sourceIndex;
qDebug() << destIndex;
const int lastIndex = rowCount() - 1;
@ -388,16 +388,21 @@ bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
const bool isMoveDown = destIndex > sourceIndex;
if (!beginMoveRows(parent, sourceIndex, sourceIndex + count - 1,
parent, isMoveDown ? destIndex + 2 : destIndex)) {
parent, isMoveDown ? destIndex + 1 : destIndex)) {
qDebug() << "Can't move rows";
return false;
}
qDebug() << "starting move: " << "source: " << sourceIndex << "dest: " << destIndex;
m_items.move(sourceIndex, isMoveDown ? destIndex + 1 : destIndex);
m_items.move(sourceIndex, destIndex);
endMoveRows();
QModelIndex idx = index(destIndex);
ServiceItem *item = m_items[idx.row()];
emit rowMoved(sourceIndex, destIndex, *item);
return true;
}