Merge pull request #637 from BlueGreenMagick/field-drag-drop-fix

fix drag drop field repositioning
This commit is contained in:
Damien Elmes 2020-05-27 10:24:07 +10:00 committed by GitHub
commit 835d1eb994
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,12 +59,19 @@ class FieldDialog(QDialog):
fieldList = self.form.fieldList fieldList = self.form.fieldList
indicatorPos = fieldList.dropIndicatorPosition() indicatorPos = fieldList.dropIndicatorPosition()
dropPos = fieldList.indexAt(ev.pos()).row() dropPos = fieldList.indexAt(ev.pos()).row()
if indicatorPos == QAbstractItemView.OnViewport: # to bottom idx = self.currentIdx
self.moveField(fieldList.count()) if dropPos == idx:
return
if indicatorPos == QAbstractItemView.OnViewport: # to bottom.
movePos = fieldList.count() - 1
elif indicatorPos == QAbstractItemView.AboveItem: elif indicatorPos == QAbstractItemView.AboveItem:
self.moveField(dropPos) movePos = dropPos
elif indicatorPos == QAbstractItemView.BelowItem: elif indicatorPos == QAbstractItemView.BelowItem:
self.moveField(dropPos + 1) movePos = dropPos + 1
# the item in idx is removed thus subtract 1.
if idx < dropPos:
movePos -= 1
self.moveField(movePos + 1) # convert to 1 based.
def onRowChange(self, idx): def onRowChange(self, idx):
if idx == -1: if idx == -1: