Fix tabbing over hidden columns

This commit is contained in:
Kovid Goyal 2025-02-14 19:08:07 +05:30
parent 7142173460
commit 59289e67cd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -44,21 +44,27 @@ class TableView(QTableView):
m = self.model() m = self.model()
row = current.row() row = current.row()
vdx = hdr.visualIndex(current.column()) # must work with visual indices, not logical indices vdx = hdr.visualIndex(current.column()) # must work with visual indices, not logical indices
if vdx < 0:
return
num_columns = hdr.count()
idx = QModelIndex()
while True: while True:
vdx = vdx + delta vdx = vdx + delta
if vdx < 0: if vdx < 0:
if row <= 0: if row <= 0:
return return
row -= 1 row -= 1
vdx += len(self.column_map) vdx += num_columns
if vdx >= len(self.column_map): if vdx >= num_columns:
if row >= m.rowCount(QModelIndex()) - 1: if row >= m.rowCount(QModelIndex()) - 1:
return return
row += 1 row += 1
vdx -= len(self.column_map) vdx -= num_columns
if vdx < 0 or vdx >= len(self.column_map): if vdx < 0 or vdx >= num_columns:
return return
ldx = hdr.logicalIndex(vdx) # We need the logical index for the model ldx = hdr.logicalIndex(vdx) # We need the logical index for the model
if hdr.isSectionHidden(ldx):
continue
colname = self.column_map[ldx] colname = self.column_map[ldx]
idx = m.index(row, ldx, current.parent()) idx = m.index(row, ldx, current.parent())
if m.is_custom_column(colname): if m.is_custom_column(colname):