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

repomodel, repoview: reverting George's patches

Accroding to Steve, these are overcomplicated. At least we have it documented.

Changeset e95a4b3b7940

Parent 814b5175e85d

by Adrian Buehlmann

Changes to 2 files · Browse files at e95a4b3b7940 Showing diff from parent 814b5175e85d Diff from another changeset...

 
20
21
22
23
24
25
26
27
 
59
60
61
62
 
63
64
65
 
67
68
69
70
 
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 
 
107
108
109
 
 
110
111
112
 
 
113
114
115
 
400
401
402
403
 
404
405
406
 
20
21
22
 
 
23
24
25
 
57
58
59
 
60
61
62
63
 
65
66
67
 
68
69
70
71
72
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
75
76
77
78
 
 
79
80
81
 
 
82
83
84
 
 
85
86
87
88
89
 
374
375
376
 
377
378
379
380
@@ -20,8 +20,6 @@
 from tortoisehg.hgqt.graph import Graph  from tortoisehg.hgqt.graph import revision_grapher  from tortoisehg.hgqt.qtlib import geticon -from tortoisehg.hgqt import qtlib -    from tortoisehg.hgqt.i18n import _   @@ -59,7 +57,7 @@
  date, tzdelay = date   return QDateTime.fromTime_t(int(date)).toString(Qt.LocaleDate)   -def gettags(ctx, gnode, repo): +def gettags(ctx, gnode):   if ctx.rev() is None:   return ""   mqtags = ['qbase', 'qtip', 'qparent'] @@ -67,49 +65,25 @@
  tags = [t for t in tags if t not in mqtags]   return tounicode(",".join(tags))   -def getlog(ctx, gnode, repo): +def getlog(ctx, gnode):   # TODO: add branch name / tag markups   if ctx.rev() is not None:   msg = tounicode(ctx.description())   if msg:   msg = msg.splitlines()[0] - - node = ctx.node() - tags = repo.nodetags(node) - tstr = '' - for tag in tags: - # FIXME if tag not in self.hidetags: - bg = "yellow" - #if tag == self.curbookmark: - # bg = "orange" - #elif tag in self.mqpatches: - # bg = "blue" - style = {'fg': "black", 'bg': bg} - tstr += qtlib.markup(' %s ' % tag, **style) + ' ' - - branch = ctx.branch() - bstr = '' - #if self.branchtags.get(branch) == node: - # bstr += gtklib.markup(' %s ' % branch, color=gtklib.BLACK, - # background=gtklib.PGREEN) + ' ' - #if revid in self.wcparents: - # sumstr = bstr + tstr + '<b><u>' + summary + '</u></b>' - #else: - msg = bstr + tstr + msg -   else:   msg = '** ' + _('Working copy changes') + ' **'   return msg    # XXX maybe it's time to make these methods of the model... -_columnmap = {'ID': lambda ctx, gnode, repo: ctx.rev() is not None and str(ctx.rev()) or "", - 'Graph': lambda ctx, gnode, repo: "", +_columnmap = {'ID': lambda ctx, gnode: ctx.rev() is not None and str(ctx.rev()) or "", + 'Graph': lambda ctx, gnode: "",   'Log': getlog, - 'Author': lambda ctx, gnode, repo: templatefilters.person(ctx.user()), - 'Date': lambda ctx, gnode, repo: cvrt_date(ctx.date()), + 'Author': lambda ctx, gnode: templatefilters.person(ctx.user()), + 'Date': lambda ctx, gnode: cvrt_date(ctx.date()),   'Tags': gettags, - 'Branch': lambda ctx, gnode, repo: ctx.branch(), - 'Filename': lambda ctx, gnode, repo: gnode.extra[0], + 'Branch': lambda ctx, gnode: ctx.branch(), + 'Filename': lambda ctx, gnode: gnode.extra[0],   }    # in following lambdas, r is a hg repo @@ -400,7 +374,7 @@
  gnode = self.graph[row]   ctx = self.repo.changectx(gnode.rev)   if role == Qt.DisplayRole: - text = _columnmap[column](ctx, gnode, self.repo) + text = _columnmap[column](ctx, gnode)   if not isinstance(text, (QString, unicode)):   text = tounicode(text)   return QVariant(text)
 
23
24
25
26
27
28
29
30
 
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
 
131
132
133
134
135
136
137
138
139
 
23
24
25
 
 
26
27
28
 
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66
67
 
76
77
78
 
 
 
79
80
81
@@ -23,8 +23,6 @@
 from PyQt4.QtCore import *  from PyQt4.QtGui import *   -from tortoisehg.hgqt import qtlib -  connect = QObject.connect     @@ -64,59 +62,6 @@
  # QObject::startTimer: QTimer can only be used with threads started with QThread   self.entry.setCompleter(None)   -class HgItemDelegate(QStyledItemDelegate): - - # Possibly also useful: - # http://discussion.forum.nokia.com/forum/showthread.php?199279-qt-listview-problems - # http://talk.maemo.org/showthread.php?s=1b81e1a45eca6837ecc70e91f904b5ce&p=629592#post629592 - # http://stackoverflow.com/questions/2434004/how-does-one-paint-the-entire-rows-background-in-a-qstyleditemdelegate - - # This approach taken from - # http://stackoverflow.com/questions/2959850/how-to-make-item-view-render-rich-html-text-in-pyqt - def __init__(self, parent = None): - super(HgItemDelegate, self).__init__(parent) - - def paint(self, painter, styleOption, index): - # calculate index of log column - model = index.model() - logidx = -1 - for i, v in enumerate(model._columns): - if v == 'Log': - logidx = i - break - - if index.column() <> logidx: - QStyledItemDelegate.paint(self, painter, styleOption, index) - return - option = QStyleOptionViewItemV4(styleOption) - #option.text = "blah" - - self.parent().style().drawControl(QStyle.CE_ItemViewItem, option, painter) - - record = model.data(index, Qt.DisplayRole) - doc = QTextDocument(self) - #opts = dict(fg='black', bg='#ffffaa') # FIXME expect this from the model - doc.setHtml(str(record.toString())) - doc.setTextWidth(option.rect.width()) - painter.save() - painter.translate(option.rect.topLeft()); - painter.setClipRect(option.rect.translated(-option.rect.topLeft())) - ctx = QAbstractTextDocumentLayout.PaintContext() - dl = doc.documentLayout() - dl.draw(painter, ctx) - painter.restore() - - """ - This was in the original example but perhaps not needed by thg? - def sizeHint(self, option, index): - model = index.model() - record = model.data[index.row()] - doc = QTextDocument(self) - doc.setHtml(get_html_box(record)) - doc.setTextWidth(option.rect.width()) - return QSize(doc.idealWidth(), doc.size().height()) - """ -  class HgRepoView(QTableView):   """   A QTableView for displaying a HgRepoListModel, @@ -131,9 +76,6 @@
  self.horizontalHeader().setHighlightSections(False)   self.setSelectionMode(QAbstractItemView.SingleSelection)   self.setSelectionBehavior(QAbstractItemView.SelectRows) - - # FIXME use setItemDelegateForColumn - self.setItemDelegate(HgItemDelegate(self))     self.createActions()   self.createToolbars()