mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Booklist: Fix using Page Up/Down keys moving book list by one row too many. Fixes #1248109 [Page up and page down keys scroll one book too much](https://bugs.launchpad.net/calibre/+bug/1248109)
This commit is contained in:
parent
1f8d7c69be
commit
144fa523ef
@ -859,6 +859,38 @@ class BooksView(QTableView): # {{{
|
||||
self.horizontalScrollBar().setValue(val)
|
||||
return ret
|
||||
|
||||
def row_at_top(self):
|
||||
pos = 0
|
||||
while pos < 100:
|
||||
ans = self.rowAt(pos)
|
||||
if ans > -1:
|
||||
return ans
|
||||
pos += 5
|
||||
|
||||
def row_at_bottom(self):
|
||||
pos = self.viewport().height()
|
||||
limit = pos - 100
|
||||
while pos > limit:
|
||||
ans = self.rowAt(pos)
|
||||
if ans > -1:
|
||||
return ans
|
||||
pos -= 5
|
||||
|
||||
def moveCursor(self, action, modifiers):
|
||||
orig = self.currentIndex()
|
||||
index = QTableView.moveCursor(self, action, modifiers)
|
||||
if action == QTableView.MovePageDown:
|
||||
rows = self.row_at_bottom() - self.row_at_top()
|
||||
moved = index.row() - orig.row()
|
||||
if moved > rows:
|
||||
index = self.model().index(orig.row() + rows, index.column())
|
||||
elif action == QTableView.MovePageUp:
|
||||
rows = self.row_at_bottom() - self.row_at_top()
|
||||
moved = orig.row() - index.row()
|
||||
if moved > rows:
|
||||
index = self.model().index(orig.row() - rows, index.column())
|
||||
return index
|
||||
|
||||
def ids_to_rows(self, ids):
|
||||
row_map = OrderedDict()
|
||||
ids = frozenset(ids)
|
||||
|
Loading…
x
Reference in New Issue
Block a user