Grid View: Allow the left and right arrow keys to traverse over rows. Fixes #1295901 [[Enhancement Request] Allow continuous right and left scrolling in cover grid](https://bugs.launchpad.net/calibre/+bug/1295901)

This commit is contained in:
Kovid Goyal 2014-03-22 08:38:24 +05:30
parent c570ace3f9
commit 0e11cafb0c

View File

@ -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
# }}}