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
indicatorPos = fieldList.dropIndicatorPosition()
dropPos = fieldList.indexAt(ev.pos()).row()
if indicatorPos == QAbstractItemView.OnViewport: # to bottom
self.moveField(fieldList.count())
idx = self.currentIdx
if dropPos == idx:
return
if indicatorPos == QAbstractItemView.OnViewport: # to bottom.
movePos = fieldList.count() - 1
elif indicatorPos == QAbstractItemView.AboveItem:
self.moveField(dropPos)
movePos = dropPos
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):
if idx == -1: