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
index = self.model().index(row, i) h.isSectionHidden(x)]
self.setCurrentIndex(index) pairs = [(x, h.visualIndex(x)) for x in logical_indices if
if select: h.visualIndex(x) > -1]
sm = self.selectionModel() if not pairs:
sm.select(index, sm.ClearAndSelect|sm.Rows) pairs = [(0, 0)]
break pairs.sort(cmp=lambda x,y:cmp(x[1], y[1]))
i = pairs[0][0]
index = self.model().index(row, i)
self.setCurrentIndex(index)
if select:
sm = self.selectionModel()
sm.select(index, sm.ClearAndSelect|sm.Rows)
def close(self): def close(self):
self._model.close() self._model.close()