Handle case of less than a screenful of books

This commit is contained in:
Kovid Goyal 2013-11-05 22:10:52 +05:30
parent d50c85b885
commit 9688c9fe14

View File

@ -880,13 +880,19 @@ class BooksView(QTableView): # {{{
orig = self.currentIndex() orig = self.currentIndex()
index = QTableView.moveCursor(self, action, modifiers) index = QTableView.moveCursor(self, action, modifiers)
if action == QTableView.MovePageDown: if action == QTableView.MovePageDown:
rows = self.row_at_bottom() - self.row_at_top()
moved = index.row() - orig.row() moved = index.row() - orig.row()
try:
rows = self.row_at_bottom() - self.row_at_top()
except TypeError:
rows = moved
if moved > rows: if moved > rows:
index = self.model().index(orig.row() + rows, index.column()) index = self.model().index(orig.row() + rows, index.column())
elif action == QTableView.MovePageUp: elif action == QTableView.MovePageUp:
rows = self.row_at_bottom() - self.row_at_top()
moved = orig.row() - index.row() moved = orig.row() - index.row()
try:
rows = self.row_at_bottom() - self.row_at_top()
except TypeError:
rows = moved
if moved > rows: if moved > rows:
index = self.model().index(orig.row() - rows, index.column()) index = self.model().index(orig.row() - rows, index.column())
return index return index