Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

status: use Qt.DecorationRole to show status icons

This is mostly an example of what's possible. We need a real icon
set or import the overlay icons from the shell extension.

Changeset 6441845063cf

Parent a7cec95938d2

by Steve Borho

Changes to one file · Browse files at 6441845063cf Showing diff from parent a7cec95938d2 Diff from another changeset...

 
17
18
19
 
20
21
22
23
24
25
 
26
27
28
 
34
35
36
37
38
39
40
 
181
182
183
 
 
 
184
185
186
187
188
189
190
 
326
327
328
 
 
 
 
 
 
 
 
 
 
 
 
329
330
331
 
395
396
397
 
 
 
 
 
 
398
399
400
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
36
37
38
 
39
40
41
 
182
183
184
185
186
187
188
189
 
 
190
191
192
 
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
 
409
410
411
412
413
414
415
416
417
418
419
420
@@ -17,12 +17,14 @@
 from PyQt4.QtGui import QWidget, QVBoxLayout, QSplitter, QTreeView, QLineEdit  from PyQt4.QtGui import QTextEdit, QFont, QColor, QDrag, QSortFilterProxyModel  from PyQt4.QtGui import QFrame, QHBoxLayout, QLabel, QPushButton, QMenu +from PyQt4.QtGui import QIcon, QPixmap    # This widget can be used as the basis of the commit tool or any other  # working copy browser.    # Technical Debt  # Selections are not surviving refresh +# We need a real icon set for file status types  # Refresh can be too expensive; probably need to disable some signals  # Add some initial drag distance before starting QDrag  # (it interferes with selection the way it is now) @@ -34,7 +36,6 @@
 # Save splitter position to parent's QSetting  # Chunk selection  # tri-state checkboxes for commit -# Investigate Qt.DecorationRole and possible use of overlay icons  # Investigate folding/nesting of files  # Maybe, Maybe Not  # Toolbar @@ -181,10 +182,11 @@
  tm = WctxModel(self.wctx, self.ms, self.opts)   self.rawmodel = tm   self.proxy.setSourceModel(tm) + self.tv.sortByColumn(COL_PATH_DISPLAY) + self.tv.setColumnHidden(COL_CHECK, self.isMerge()) + self.tv.setColumnHidden(COL_MERGE_STATE, not tm.anyMerge())   for col in xrange(COL_PATH):   self.tv.resizeColumnToContents(col) - self.tv.setColumnHidden(COL_CHECK, self.isMerge()) - self.tv.setColumnHidden(COL_MERGE_STATE, not tm.anyMerge())   self.connect(self.tv, SIGNAL('activated(QModelIndex)'), tm.toggleRow)   self.connect(self.tv, SIGNAL('pressed(QModelIndex)'), tm.pressedRow)   @@ -326,6 +328,18 @@
  'S': _('%s is a dirty subrepo'),  }   +# TODO: We need real icons here +icons = { + 'M': 'menucommit.ico', + 'A': 'fileadd.ico', + 'R': 'filedelete.ico', + '?': 'shelve.ico', + '!': 'menudelete.ico', + 'I': 'ignore.ico', + 'C': '', + 'S': 'hg.ico', +} +  color_labels = {   'M': 'status.modified',   'A': 'status.added', @@ -395,6 +409,12 @@
  return Qt.Checked   else:   return Qt.Unchecked + elif role == Qt.DecorationRole and index.column() == COL_STATUS: + status = self.rows[index.row()][COL_STATUS] + if status in icons: + ico = QIcon() + ico.addPixmap(QPixmap('icons/' + icons[status])) + return QVariant(ico)   elif role == Qt.DisplayRole:   return QVariant(self.rows[index.row()][index.column()])