From c56109c1f31c240ff635b3f96cfccf0bbbb655fc Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 16 Jan 2023 09:08:57 +0530 Subject: [PATCH] Book list: Fix a regression in the previous release that broke dragging to select multiple books --- src/calibre/gui2/library/views.py | 16 +++++++++++++--- src/calibre/utils/windows/winspeech.cpp | 2 ++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 00742c8951..e3b4b5dad6 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -1177,6 +1177,14 @@ class BooksView(QTableView): # {{{ def handle_mouse_press_event(self, ev): m = ev.modifiers() + b = ev.button() + if ( + m == Qt.KeyboardModifier.NoModifier and b == Qt.MouseButton.LeftButton and + self.editTriggers() & QAbstractItemView.EditTrigger.SelectedClicked + ): + index = self.indexAt(ev.pos()) + self.last_mouse_press_on_row = index.row() + if m & Qt.KeyboardModifier.ShiftModifier: # Shift-Click in QTableView is badly behaved. index = self.indexAt(ev.pos()) @@ -1240,9 +1248,11 @@ class BooksView(QTableView): # {{{ # edit triggers contain SelectedClicked and the clicked row is # already selected, so do it ourselves index = self.indexAt(ev.pos()) - sm = self.selectionModel() - if index.isValid() and sm.isSelected(index): - self.select_rows((index,), using_ids=False, change_current=False, scroll=False) + last_press, self.last_mouse_press_on_row = getattr(self, 'last_mouse_press_on_row', -111), -112 + if index.row() == last_press: + sm = self.selectionModel() + if index.isValid() and sm.isSelected(index): + self.select_rows((index,), using_ids=False, change_current=False, scroll=False) QTableView.mouseReleaseEvent(self, ev) @property diff --git a/src/calibre/utils/windows/winspeech.cpp b/src/calibre/utils/windows/winspeech.cpp index 3e8a881ab0..b8aab7d9a4 100644 --- a/src/calibre/utils/windows/winspeech.cpp +++ b/src/calibre/utils/windows/winspeech.cpp @@ -13,10 +13,12 @@ #include #include #include +#include using namespace winrt::Windows::Foundation; using namespace winrt::Windows::Foundation::Collections; using namespace winrt::Windows::Media::SpeechSynthesis; +using namespace winrt::Windows::Media::Playback; using namespace winrt::Windows::Storage::Streams; static PyObject*