Fix infinite loop when tabbing past last cell

This commit is contained in:
Kovid Goyal 2025-02-10 10:20:25 +05:30
parent 0ff4424a64
commit f68bc23853
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 8 deletions

View File

@ -1679,8 +1679,4 @@ class DeviceBooksView(BooksView): # {{{
h = self.horizontalHeader() h = self.horizontalHeader()
h.setSortIndicator( h.setSortIndicator(
h.sortIndicatorSection(), Qt.SortOrder.AscendingOrder if h.sortIndicatorOrder() == Qt.SortOrder.DescendingOrder else Qt.SortOrder.DescendingOrder) h.sortIndicatorSection(), Qt.SortOrder.AscendingOrder if h.sortIndicatorOrder() == Qt.SortOrder.DescendingOrder else Qt.SortOrder.DescendingOrder)
def closeEditor(self, editor, hint):
return super().closeEditor(editor, hint)
# }}} # }}}

View File

@ -2,7 +2,7 @@
# License: GPLv3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net> # License: GPLv3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
from qt.core import QAbstractItemDelegate, QSplitter, Qt, QTableView from qt.core import QAbstractItemDelegate, QModelIndex, QSplitter, Qt, QTableView
from calibre.gui2 import gprefs from calibre.gui2 import gprefs
from calibre.gui2.library import DEFAULT_SORT from calibre.gui2.library import DEFAULT_SORT
@ -52,7 +52,7 @@ class TableView(QTableView):
row -= 1 row -= 1
col += len(self.column_map) col += len(self.column_map)
if col >= len(self.column_map): if col >= len(self.column_map):
if row >= len(self.column_map) - 1: if row >= m.rowCount(QModelIndex()) - 1:
return return
row += 1 row += 1
col -= len(self.column_map) col -= len(self.column_map)
@ -71,8 +71,7 @@ class TableView(QTableView):
if idx.isValid(): if idx.isValid():
# Tell the delegate to ignore keyboard modifiers in case # Tell the delegate to ignore keyboard modifiers in case
# Shift-Tab is being used to move the cell. # Shift-Tab is being used to move the cell.
d = self.itemDelegateForIndex(idx) if (d := self.itemDelegateForIndex(idx)) is not None:
if d is not None:
d.ignore_kb_mods_on_edit = True d.ignore_kb_mods_on_edit = True
self.setCurrentIndex(idx) self.setCurrentIndex(idx)
self.edit(idx) self.edit(idx)