Fix drag and drop of books into bookshelf view not working. Fixes #2139529 [Drag & Drop of new books not working when in new Bookshelf View](https://bugs.launchpad.net/calibre/+bug/2139529)

This commit is contained in:
Kovid Goyal 2026-02-01 13:36:21 +05:30
parent 38a6cc4a5d
commit e3e9df79b6
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 6 deletions

View File

@ -468,9 +468,12 @@ def setup_dnd_interface(cls_or_self):
self = cls_or_self
self.drag_allowed = True
self.drag_start_pos = None
self.setDragEnabled(True)
self.setDragDropOverwriteMode(False)
self.setDragDropMode(QAbstractItemView.DragDropMode.DragDrop)
if isinstance(self, QAbstractItemView):
self.setDragEnabled(True)
self.setDragDropOverwriteMode(False)
self.setDragDropMode(QAbstractItemView.DragDropMode.DragDrop)
else:
self.setAcceptDrops(True)
# }}}

View File

@ -1527,9 +1527,8 @@ class BookshelfView(MomentumScrollMixin, QAbstractScrollArea):
self.second_line_renderer = self.build_template_renderer('authors', '')
# Initialize drag and drop
# so we set the attributes manually
self.drag_allowed = True
self.drag_start_pos = None
setup_dnd_interface(self)
self.bookcase = BookCase(self)
self.bookcase.shelf_added.connect(self.on_shelf_layout_done, type=Qt.ConnectionType.QueuedConnection)
self.bookcase.num_of_groups_changed.connect(self.update_scrollbar_ranges, type=Qt.ConnectionType.QueuedConnection)