diff --git a/src/calibre/gui2/library/alternate_views.py b/src/calibre/gui2/library/alternate_views.py index b09bec64c8..80ca24fc71 100644 --- a/src/calibre/gui2/library/alternate_views.py +++ b/src/calibre/gui2/library/alternate_views.py @@ -850,4 +850,14 @@ class GridView(QListView): except ValueError: pass + def moveCursor(self, action, modifiers): + index = QListView.moveCursor(self, action, modifiers) + if action in (QListView.MoveLeft, QListView.MoveRight) and index.isValid(): + ci = self.currentIndex() + if ci.isValid() and index.row() == ci.row(): + nr = index.row() + (1 if action == QListView.MoveRight else -1) + if 0 <= nr < self.model().rowCount(QModelIndex()): + index = self.model().index(nr, 0) + return index + # }}}