mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix tabbing in the book list and pin view going to wrong columns.
This commit is contained in:
parent
3ae73fd563
commit
0fe39c3dea
@ -31,7 +31,6 @@ class TableView(QTableView):
|
|||||||
|
|
||||||
def closeEditor(self, editor, hint):
|
def closeEditor(self, editor, hint):
|
||||||
# We want to implement our own go to next/previous cell behavior
|
# We want to implement our own go to next/previous cell behavior
|
||||||
orig = self.currentIndex()
|
|
||||||
delta = 0
|
delta = 0
|
||||||
if hint is QAbstractItemDelegate.EndEditHint.EditNextItem:
|
if hint is QAbstractItemDelegate.EndEditHint.EditNextItem:
|
||||||
delta = 1
|
delta = 1
|
||||||
@ -41,25 +40,27 @@ class TableView(QTableView):
|
|||||||
if not delta:
|
if not delta:
|
||||||
return
|
return
|
||||||
current = self.currentIndex()
|
current = self.currentIndex()
|
||||||
|
hdr = self.horizontalHeader()
|
||||||
m = self.model()
|
m = self.model()
|
||||||
row = current.row()
|
row = current.row()
|
||||||
idx = m.index(row, current.column(), current.parent())
|
vdx = hdr.visualIndex(current.column()) # must work with visual indices, not logical indices
|
||||||
while True:
|
while True:
|
||||||
col = idx.column() + delta
|
vdx = vdx + delta
|
||||||
if col < 0:
|
if vdx < 0:
|
||||||
if row <= 0:
|
if row <= 0:
|
||||||
return
|
return
|
||||||
row -= 1
|
row -= 1
|
||||||
col += len(self.column_map)
|
vdx += len(self.column_map)
|
||||||
if col >= len(self.column_map):
|
if vdx >= len(self.column_map):
|
||||||
if row >= m.rowCount(QModelIndex()) - 1:
|
if row >= m.rowCount(QModelIndex()) - 1:
|
||||||
return
|
return
|
||||||
row += 1
|
row += 1
|
||||||
col -= len(self.column_map)
|
vdx -= len(self.column_map)
|
||||||
if col < 0 or col >= len(self.column_map):
|
if vdx < 0 or vdx >= len(self.column_map):
|
||||||
return
|
return
|
||||||
colname = self.column_map[col]
|
ldx = hdr.logicalIndex(vdx) # We need the logical index for the model
|
||||||
idx = m.index(row, col, current.parent())
|
colname = self.column_map[ldx]
|
||||||
|
idx = m.index(row, ldx, current.parent())
|
||||||
if m.is_custom_column(colname):
|
if m.is_custom_column(colname):
|
||||||
if self.itemDelegateForIndex(idx).is_editable_with_tab:
|
if self.itemDelegateForIndex(idx).is_editable_with_tab:
|
||||||
# Don't try to open editors implemented by dialogs such as
|
# Don't try to open editors implemented by dialogs such as
|
||||||
|
Loading…
x
Reference in New Issue
Block a user