diff --git a/src/calibre/gui2/library/alternate_views.py b/src/calibre/gui2/library/alternate_views.py index e39183c218..d07d5ac4ea 100644 --- a/src/calibre/gui2/library/alternate_views.py +++ b/src/calibre/gui2/library/alternate_views.py @@ -1137,10 +1137,10 @@ class GridView(QListView): def moveCursor(self, action, modifiers): index = QListView.moveCursor(self, action, modifiers) - if action in (QListView.MoveLeft, QListView.MoveRight) and index.isValid(): + if action in (QAbstractItemView.CursorAction.MoveLeft, QAbstractItemView.CursorAction.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) + nr = index.row() + (1 if action == QAbstractItemView.CursorAction.MoveRight else -1) if 0 <= nr < self.model().rowCount(QModelIndex()): index = self.model().index(nr, 0) return index diff --git a/src/calibre/gui2/library/views.py b/src/calibre/gui2/library/views.py index af6e80078e..df242ad278 100644 --- a/src/calibre/gui2/library/views.py +++ b/src/calibre/gui2/library/views.py @@ -1166,7 +1166,7 @@ class BooksView(QTableView): # {{{ def moveCursor(self, action, modifiers): orig = self.currentIndex() index = QTableView.moveCursor(self, action, modifiers) - if action == QTableView.MovePageDown: + if action == QAbstractItemView.CursorAction.MovePageDown: moved = index.row() - orig.row() try: rows = self.row_at_bottom() - self.row_at_top() @@ -1174,7 +1174,7 @@ class BooksView(QTableView): # {{{ rows = moved if moved > rows: index = self.model().index(orig.row() + rows, index.column()) - elif action == QTableView.MovePageUp: + elif action == QAbstractItemView.CursorAction.MovePageUp: moved = orig.row() - index.row() try: rows = self.row_at_bottom() - self.row_at_top() @@ -1182,9 +1182,9 @@ class BooksView(QTableView): # {{{ rows = moved if moved > rows: index = self.model().index(orig.row() - rows, index.column()) - elif action == QTableView.MoveHome and modifiers & Qt.KeyboardModifier.ControlModifier: + elif action == QAbstractItemView.CursorAction.MoveHome and modifiers & Qt.KeyboardModifier.ControlModifier: return self.model().index(0, orig.column()) - elif action == QTableView.MoveEnd and modifiers & Qt.KeyboardModifier.ControlModifier: + elif action == QAbstractItemView.CursorAction.MoveEnd and modifiers & Qt.KeyboardModifier.ControlModifier: return self.model().index(self.model().rowCount(QModelIndex()) - 1, orig.column()) return index diff --git a/src/calibre/gui2/metadata/single_download.py b/src/calibre/gui2/metadata/single_download.py index 40032e6e8f..4687c7ec6d 100644 --- a/src/calibre/gui2/metadata/single_download.py +++ b/src/calibre/gui2/metadata/single_download.py @@ -291,7 +291,7 @@ class ResultsView(QTableView): # {{{ def keyPressEvent(self, ev): if ev.key() in (Qt.Key.Key_Left, Qt.Key.Key_Right): - ac = self.MoveDown if ev.key() == Qt.Key.Key_Right else self.MoveUp + ac = QAbstractItemView.CursorAction.MoveDown if ev.key() == Qt.Key.Key_Right else QAbstractItemView.CursorAction.MoveUp index = self.moveCursor(ac, ev.modifiers()) if index.isValid() and index != self.currentIndex(): m = self.selectionModel()