From 06f69ee1704892d2cd8b57b16c9a202013788dd0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 14 Jul 2020 17:20:18 +0530 Subject: [PATCH] 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) --- src/calibre/gui2/tweak_book/file_list.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 76ddcd20e0..477aa5b451 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -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())):