Edit book: When copying files do it in order so that the files are pasted in the same order when pasting into another editor instance. Fixes #2037198 [Calibre Editor: "Paste # files from other editor instance" > Files Pasted Out of Order](https://bugs.launchpad.net/calibre/+bug/2037198)

This commit is contained in:
Kovid Goyal 2023-09-24 10:03:16 +05:30
parent 4af337c571
commit 34b3ee1138
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -876,6 +876,16 @@ class FileList(QTreeWidget, OpenWithHandler):
ans.discard('')
return ans
@property
def selected_names_in_order(self):
root = self.invisibleRootItem()
for category_item in (root.child(i) for i in range(root.childCount())):
for child in (category_item.child(i) for i in range(category_item.childCount())):
if child.isSelected():
name = child.data(0, NAME_ROLE)
if name:
yield name
def move_selected_text_items(self, amt: int) -> bool:
parent = self.categories['text']
children = tuple(parent.child(i) for i in range(parent.childCount()))
@ -906,7 +916,7 @@ class FileList(QTreeWidget, OpenWithHandler):
return changed
def copy_selected_files(self):
self.initiate_file_copy.emit(self.selected_names)
self.initiate_file_copy.emit(tuple(self.selected_names_in_order))
def paste_from_other_instance(self):
self.initiate_file_paste.emit()