mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #6176 (Custom Columns = Column Orientation Issue)
This commit is contained in:
parent
f1dd2c4370
commit
cef3b69a8a
@ -478,14 +478,20 @@ class BooksView(QTableView): # {{{
|
|||||||
def set_current_row(self, row, select=True):
|
def set_current_row(self, row, select=True):
|
||||||
if row > -1:
|
if row > -1:
|
||||||
h = self.horizontalHeader()
|
h = self.horizontalHeader()
|
||||||
for i in range(h.count()):
|
logical_indices = list(range(h.count()))
|
||||||
if not h.isSectionHidden(i):
|
logical_indices = [x for x in logical_indices if not
|
||||||
|
h.isSectionHidden(x)]
|
||||||
|
pairs = [(x, h.visualIndex(x)) for x in logical_indices if
|
||||||
|
h.visualIndex(x) > -1]
|
||||||
|
if not pairs:
|
||||||
|
pairs = [(0, 0)]
|
||||||
|
pairs.sort(cmp=lambda x,y:cmp(x[1], y[1]))
|
||||||
|
i = pairs[0][0]
|
||||||
index = self.model().index(row, i)
|
index = self.model().index(row, i)
|
||||||
self.setCurrentIndex(index)
|
self.setCurrentIndex(index)
|
||||||
if select:
|
if select:
|
||||||
sm = self.selectionModel()
|
sm = self.selectionModel()
|
||||||
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
sm.select(index, sm.ClearAndSelect|sm.Rows)
|
||||||
break
|
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._model.close()
|
self._model.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user