Fix #6176 (Custom Columns = Column Orientation Issue)

This commit is contained in:
Kovid Goyal 2010-07-21 12:59:52 -06:00
parent f1dd2c4370
commit cef3b69a8a

View File

@ -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()