mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More stupid PyQt enums
This commit is contained in:
parent
dec3f403f0
commit
1a3ca21b18
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user