cleaning up moveRows to be easier to maintain
This commit is contained in:
parent
766dc02b91
commit
aff30cc9e8
1 changed files with 6 additions and 5 deletions
|
@ -326,16 +326,17 @@ bool ServiceItemModel::moveRows(int sourceIndex, int destIndex, int count) {
|
|||
qDebug() << index(sourceIndex).row();
|
||||
qDebug() << index(destIndex).row();
|
||||
|
||||
if (sourceIndex < 0 || sourceIndex == destIndex ||
|
||||
destIndex == -1 || destIndex > rowCount() ||
|
||||
sourceIndex >= rowCount()) {
|
||||
const int lastIndex = rowCount() - 1;
|
||||
|
||||
if (sourceIndex == destIndex
|
||||
|| (sourceIndex < 0 || sourceIndex > lastIndex)
|
||||
|| (destIndex < 0 || destIndex > lastIndex)) {
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
const QModelIndex parent = index(sourceIndex).parent();
|
||||
const bool isMoveDown = destIndex > sourceIndex;
|
||||
|
||||
|
||||
if (!beginMoveRows(parent, sourceIndex, sourceIndex + count - 1,
|
||||
parent, isMoveDown ? destIndex + 1 : destIndex)) {
|
||||
qDebug() << "Can't move rows";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue