Book list: Fix a regression in the previous release that broke drag and drop of multiple books. Fixes #1999995 [Unable to drag & drop multiple books to tag browser](https://bugs.launchpad.net/calibre/+bug/1999995)

This commit is contained in:
Kovid Goyal 2022-12-18 10:14:44 +05:30
parent 0f75c185b7
commit c37df3f108
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 21 additions and 12 deletions

View File

@ -119,6 +119,12 @@ def mousePressEvent(self, event):
return qt_item_view_base_class(self).mousePressEvent(self, event) return qt_item_view_base_class(self).mousePressEvent(self, event)
def mouseReleaseEvent(self, event):
if hasattr(self, 'handle_mouse_press_event'):
return self.handle_mouse_release_event(event)
return qt_item_view_base_class(self).mouseReleaseEvent(self, event)
def drag_icon(self, cover, multiple): def drag_icon(self, cover, multiple):
cover = cover.scaledToHeight(120, Qt.TransformationMode.SmoothTransformation) cover = cover.scaledToHeight(120, Qt.TransformationMode.SmoothTransformation)
if multiple: if multiple:
@ -263,7 +269,7 @@ def setup_dnd_interface(cls_or_self):
cls = cls_or_self cls = cls_or_self
fmap = globals() fmap = globals()
for x in ( for x in (
'dragMoveEvent', 'event_has_mods', 'mousePressEvent', 'mouseMoveEvent', 'dragMoveEvent', 'event_has_mods', 'mousePressEvent', 'mouseMoveEvent', 'mouseReleaseEvent',
'drag_data', 'drag_icon', 'dragEnterEvent', 'dropEvent', 'paths_from_event'): 'drag_data', 'drag_icon', 'dragEnterEvent', 'dropEvent', 'paths_from_event'):
func = fmap[x] func = fmap[x]
setattr(cls, x, func) setattr(cls, x, func)

View File

@ -1229,8 +1229,11 @@ class BooksView(QTableView): # {{{
# ensure clicked row is always selected # ensure clicked row is always selected
index, QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows) index, QItemSelectionModel.SelectionFlag.Select | QItemSelectionModel.SelectionFlag.Rows)
else: else:
QTableView.mousePressEvent(self, ev)
def handle_mouse_release_event(self, ev):
if ( if (
m == Qt.KeyboardModifier.NoModifier and ev.button() == Qt.MouseButton.LeftButton and ev.modifiers() == Qt.KeyboardModifier.NoModifier and ev.button() == Qt.MouseButton.LeftButton and
self.editTriggers() & QAbstractItemView.EditTrigger.SelectedClicked self.editTriggers() & QAbstractItemView.EditTrigger.SelectedClicked
): ):
# As of Qt 6, Qt does not clear a multi-row selection when the # As of Qt 6, Qt does not clear a multi-row selection when the
@ -1240,7 +1243,7 @@ class BooksView(QTableView): # {{{
sm = self.selectionModel() sm = self.selectionModel()
if index.isValid() and sm.isSelected(index): if index.isValid() and sm.isSelected(index):
self.select_rows((index,), using_ids=False, change_current=False, scroll=False) self.select_rows((index,), using_ids=False, change_current=False, scroll=False)
QTableView.mousePressEvent(self, ev) QTableView.mouseReleaseEvent(self, ev)
@property @property
def column_map(self): def column_map(self):