Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0, 2.0.1, and 2.0.2

stable repoview: use a separate function to calculate recommended column widths

Changeset 4268fec8a0ff

Parent 3c1919f35bea

by Yuya Nishihara

Changes to one file · Browse files at 4268fec8a0ff Showing diff from parent 3c1919f35bea Diff from another changeset...

 
112
113
114
 
 
 
 
 
115
116
117
118
 
119
120
121
122
123
124
125
 
126
127
128
 
129
130
131
132
 
 
133
134
135
136
137
 
 
138
139
140
 
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 
131
132
133
 
134
135
136
 
 
137
138
139
140
141
142
 
143
144
145
146
147
@@ -112,29 +112,36 @@
    def _resizeColumns(self):   # _resizeColumns misbehaves if called with last section streched + for c, w in enumerate(self._columnWidthHints()): + self.setColumnWidth(c, w) + + def _columnWidthHints(self): + """Return list of recommended widths of all columns"""   model = self.model()   col1_width = self.viewport().width()   fontm = QFontMetrics(self.font())   tot_stretch = 0.0 + widths = [-1 for _i in xrange(model.columnCount(QModelIndex()))]   for c in range(model.columnCount(QModelIndex())):   if model._columns[c] in model._stretchs:   tot_stretch += model._stretchs[model._columns[c]]   continue   w = model.maxWidthValueForColumn(c)   if isinstance(w, int): - self.setColumnWidth(c, w) + widths[c] = w   elif w is not None:   w = fontm.width(hglib.tounicode(str(w)) + 'w') - self.setColumnWidth(c, w) + widths[c] = w   else:   w = self.sizeHintForColumn(c) - self.setColumnWidth(c, w) - col1_width -= self.columnWidth(c) + widths[c] = w + col1_width -= widths[c]   col1_width = max(col1_width, 600)   for c in range(model.columnCount(QModelIndex())):   if model._columns[c] in model._stretchs:   w = model._stretchs[model._columns[c]] / tot_stretch - self.setColumnWidth(c, col1_width * w) + widths[c] = col1_width * w + return widths     def revFromindex(self, index):   if not index.isValid():