Book list: Fix a regression in the previous release that broke dragging to select multiple books

This commit is contained in:
Kovid Goyal 2023-01-16 09:08:57 +05:30
parent 37f042affc
commit c56109c1f3
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 15 additions and 3 deletions

View File

@ -1177,6 +1177,14 @@ class BooksView(QTableView): # {{{
def handle_mouse_press_event(self, ev): def handle_mouse_press_event(self, ev):
m = ev.modifiers() 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: if m & Qt.KeyboardModifier.ShiftModifier:
# Shift-Click in QTableView is badly behaved. # Shift-Click in QTableView is badly behaved.
index = self.indexAt(ev.pos()) index = self.indexAt(ev.pos())
@ -1240,9 +1248,11 @@ class BooksView(QTableView): # {{{
# edit triggers contain SelectedClicked and the clicked row is # edit triggers contain SelectedClicked and the clicked row is
# already selected, so do it ourselves # already selected, so do it ourselves
index = self.indexAt(ev.pos()) index = self.indexAt(ev.pos())
sm = self.selectionModel() last_press, self.last_mouse_press_on_row = getattr(self, 'last_mouse_press_on_row', -111), -112
if index.isValid() and sm.isSelected(index): if index.row() == last_press:
self.select_rows((index,), using_ids=False, change_current=False, scroll=False) 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) QTableView.mouseReleaseEvent(self, ev)
@property @property

View File

@ -13,10 +13,12 @@
#include <winrt/Windows.Foundation.Collections.h> #include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Storage.Streams.h> #include <winrt/Windows.Storage.Streams.h>
#include <winrt/Windows.Media.SpeechSynthesis.h> #include <winrt/Windows.Media.SpeechSynthesis.h>
#include <winrt/Windows.Media.Playback.h>
using namespace winrt::Windows::Foundation; using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections; using namespace winrt::Windows::Foundation::Collections;
using namespace winrt::Windows::Media::SpeechSynthesis; using namespace winrt::Windows::Media::SpeechSynthesis;
using namespace winrt::Windows::Media::Playback;
using namespace winrt::Windows::Storage::Streams; using namespace winrt::Windows::Storage::Streams;
static PyObject* static PyObject*