Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.0.3, 2.0.4, and 2.0.5

stable repoview: optimised resizeEvent code

- There is no need to save the view port width in settings because we can gather that information from the event parameter

Changeset 32955094541f

Parent 0e1c5396d7f5

by Michael De Wildt

Changes to one file · Browse files at 32955094541f Showing diff from parent 0e1c5396d7f5 Diff from another changeset...

 
249
250
251
252
253
254
255
256
 
 
 
257
258
259
260
261
 
 
 
 
 
 
 
262
263
264
265
266
267
268
269
270
271
272
273
 
 
274
275
276
 
249
250
251
 
 
 
 
 
252
253
254
255
 
 
 
 
256
257
258
259
260
261
262
263
 
 
 
 
 
 
 
 
 
 
 
264
265
266
267
268
@@ -249,28 +249,20 @@
  def resizeEvent(self, e):   # re-size columns the smart way: the column holding Description   # is re-sized according to the total widget size. - if e.oldSize().width() != e.size().width(): - key = '%s/widget_width' % self.cfgname - widget_width, ok = QSettings().value(key).toInt() - if not ok: - widget_width = 0 + if self.resized and e.oldSize().width() != e.size().width(): + model = self.model() + total_width = stretch_col = 0   - if self.resized: - model = self.model() - vp_width = self.viewport().width() - total_width = stretch_col = 0 + for c in range(model.columnCount(QModelIndex())): + if model._columns[c] in model._stretchs: + #save the description column + stretch_col = c + else: + #total the other widths + total_width += self.columnWidth(c)   - if vp_width != widget_width: - for c in range(model.columnCount(QModelIndex())): - if model._columns[c] in model._stretchs: - #save the description column - stretch_col = c - else: - #total the other widths - total_width += self.columnWidth(c) - - width = max(vp_width - total_width, 100) - self.setColumnWidth(stretch_col, width) + width = max(self.viewport().width() - total_width, 100) + self.setColumnWidth(stretch_col, width)     super(HgRepoView, self).resizeEvent(e)