py3 compat: FIx d&d in file list in editor

Fixes #1887508 [Cannot drag and drop files while editing a book](https://bugs.launchpad.net/calibre/+bug/1887508)
This commit is contained in:
Kovid Goyal 2020-07-14 17:20:18 +05:30
parent dc64f044db
commit 06f69ee170
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -792,9 +792,9 @@ class FileList(QTreeWidget, OpenWithHandler):
def dropEvent(self, event):
with self:
text = self.categories['text']
pre_drop_order = {text.child(i):i for i in range(text.childCount())}
pre_drop_order = {text.child(i).data(0, NAME_ROLE):i for i in range(text.childCount())}
super(FileList, self).dropEvent(event)
current_order = {text.child(i):i for i in range(text.childCount())}
current_order = {text.child(i).data(0, NAME_ROLE):i for i in range(text.childCount())}
if current_order != pre_drop_order:
order = []
for child in (text.child(i) for i in range(text.childCount())):