From 9688c9fe14773316837c864a16715f8c2a260a20 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Nov 2013 22:10:52 +0530 Subject: [PATCH] Handle case of less than a screenful of books --- src/calibre/gui2/library/views.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index 10d0ba55fc..ac52aa6fe2 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -880,13 +880,19 @@ class BooksView(QTableView): # {{{ 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() + try: + rows = self.row_at_bottom() - self.row_at_top() + except TypeError: + rows = moved 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() + try: + rows = self.row_at_bottom() - self.row_at_top() + except TypeError: + rows = moved if moved > rows: index = self.model().index(orig.row() - rows, index.column()) return index