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

extract class HgFileListModel into new filelistmodel.py

Changeset 0deeb72fb685

Parent 119a82833074

by Adrian Buehlmann

Changes to 3 files · Browse files at 0deeb72fb685 Showing diff from parent 119a82833074 Diff from another changeset...

Change 1 of 1 Show Entire File tortoisehg/​hgqt/​filelistmodel.py Stacked
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
@@ -0,0 +1,306 @@
+# Copyright (c) 2009-2010 LOGILAB S.A. (Paris, FRANCE). +# http://www.logilab.fr/ -- mailto:contact@logilab.fr +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +import re + +from mercurial.revlog import LookupError + +from tortoisehg.util.util import isbfile, Curry + +from tortoisehg.hgqt.graph import ismerge, diff as revdiff +from tortoisehg.hgqt.config import HgConfig +from tortoisehg.hgqt import icon as geticon + +from PyQt4 import QtCore, QtGui +connect = QtCore.QObject.connect +SIGNAL = QtCore.SIGNAL +nullvariant = QtCore.QVariant() + + +replus = re.compile(r'^[+][^+].*', re.M) +reminus = re.compile(r'^[-][^-].*', re.M) + +class HgFileListModel(QtCore.QAbstractTableModel): + """ + Model used for listing (modified) files of a given Hg revision + """ + def __init__(self, repo, parent=None): + """ + data is a HgHLRepo instance + """ + QtCore.QAbstractTableModel.__init__(self, parent) + self.repo = repo + self._datacache = {} + self.load_config() + self.current_ctx = None + self._files = [] + self._filesdict = {} + self.diffwidth = 100 + self._fulllist = False + self._fill_iter = None + + def toggleFullFileList(self): + self._fulllist = not self._fulllist + self.loadFiles() + self.emit(SIGNAL('layoutChanged()')) + + def load_config(self): + cfg = HgConfig(self.repo.ui) + self._flagcolor = {} + self._flagcolor['='] = cfg.getFileModifiedColor(default='blue') + self._flagcolor['-'] = cfg.getFileRemovedColor(default='red') + self._flagcolor['-'] = cfg.getFileDeletedColor(default='red') + self._flagcolor['+'] = cfg.getFileAddedColor(default='green') + self._displaydiff = cfg.getDisplayDiffStats() + + def setDiffWidth(self, w): + if w != self.diffwidth: + self.diffwidth = w + self._datacache = {} + self.emit(SIGNAL('dataChanged(const QModelIndex &, const QModelIndex & )'), + self.index(1, 0), + self.index(1, self.rowCount())) + + def __len__(self): + return len(self._files) + + def rowCount(self, parent=None): + return len(self) + + def columnCount(self, parent=None): + return 1 + self._displaydiff + + def file(self, row): + return self._files[row]['path'] + + def fileflag(self, fn): + return self._filesdict[fn]['flag'] + + def fileparentctx(self, fn, ctx=None): + if ctx is None: + return self._filesdict[fn]['parent'] + return ctx.parents()[0] + + def fileFromIndex(self, index): + if not index.isValid() or index.row()>=len(self) or not self.current_ctx: + return None + row = index.row() + return self._files[row]['path'] + + def revFromIndex(self, index): + if self._fulllist and ismerge(self.current_ctx): + if not index.isValid() or index.row()>=len(self) or not self.current_ctx: + return None + row = index.row() + current_file_desc = self._files[row] + if current_file_desc['fromside'] == 'right': + return self.current_ctx.parents()[1].rev() + else: + return self.current_ctx.parents()[0].rev() + return None + + def indexFromFile(self, filename): + if filename in self._filesdict: + row = self._files.index(self._filesdict[filename]) + return self.index(row, 0) + return QtCore.QModelIndex() + + def _filterFile(self, filename, ctxfiles): + if self._fulllist: + return True + return filename in ctxfiles #self.current_ctx.files() + + def _buildDesc(self, parent, fromside): + _files = [] + ctx = self.current_ctx + ctxfiles = ctx.files() + changes = self.repo.status(parent.node(), ctx.node())[:3] + modified, added, removed = changes + for lst, flag in ((added, '+'), (modified, '='), (removed, '-')): + for f in [x for x in lst if self._filterFile(x, ctxfiles)]: + _files.append({'path': f, 'flag': flag, 'desc': f, + 'parent': parent, 'fromside': fromside, + 'infiles': f in ctxfiles}) + # renamed/copied files are handled by background + # filling process since it can be a bit long + for fdesc in _files: + bfile = isbfile(fdesc['path']) + fdesc['bfile'] = bfile + if bfile: + fdesc['desc'] = fdesc['desc'].replace('.hgbfiles'+os.sep, '') + + return _files + + def loadFiles(self): + self._fill_iter = None + self._files = [] + self._datacache = {} + self._files = self._buildDesc(self.current_ctx.parents()[0], 'left') + if ismerge(self.current_ctx): + _paths = [x['path'] for x in self._files] + _files = self._buildDesc(self.current_ctx.parents()[1], 'right') + self._files += [x for x in _files if x['path'] not in _paths] + self._filesdict = dict([(f['path'], f) for f in self._files]) + self.fillFileStats() + + def setSelectedRev(self, ctx): + if ctx != self.current_ctx: + self.current_ctx = ctx + self._datacache = {} + self.loadFiles() + self.emit(SIGNAL("layoutChanged()")) + + def fillFileStats(self): + """ + Method called to start the background process of computing + file stats, which are to be displayed in the 'Stats' column + """ + self._fill_iter = self._fill() + self._fill_one_step() + + def _fill_one_step(self): + if self._fill_iter is None: + return + try: + nextfill = self._fill_iter.next() + if nextfill is not None: + row, col = nextfill + idx = self.index(row, col) + self.emit(SIGNAL('dataChanged(const QModelIndex &, const QModelIndex &)'), + idx, idx) + QtCore.QTimer.singleShot(10, lambda self=self: self._fill_one_step()) + + except StopIteration: + self._fill_iter = None + + def _fill(self): + # the generator used to fill file stats as a background process + for row, desc in enumerate(self._files): + filename = desc['path'] + if desc['flag'] == '=' and self._displaydiff: + diff = revdiff(self.repo, self.current_ctx, desc['parent'], + files=[filename]) + try: + tot = self.current_ctx.filectx(filename).data().count('\n') + except LookupError: + tot = 0 + add = len(replus.findall(diff)) + rem = len(reminus.findall(diff)) + if tot == 0: + tot = max(add + rem, 1) + desc['stats'] = (tot, add, rem) + yield row, 1 + + if desc['flag'] == '+': + m = self.current_ctx.filectx(filename).renamed() + if m: + removed = self.repo.status(desc['parent'].node(), + self.current_ctx.node())[2] + oldname, node = m + if oldname in removed: + # removed.remove(oldname) XXX + desc['renamedfrom'] = (oldname, node) + desc['flag'] = '=' + desc['desc'] += '\n (was %s)' % oldname + else: + desc['copiedfrom'] = (oldname, node) + desc['flag'] = '=' + desc['desc'] += '\n (copy of %s)' % oldname + yield row, 0 + yield None + + def data(self, index, role): + if not index.isValid() or index.row()>len(self) or not self.current_ctx: + return nullvariant + row = index.row() + column = index.column() + + current_file_desc = self._files[row] + current_file = current_file_desc['path'] + stats = current_file_desc.get('stats') + if column == 1: + if stats is not None: + if role == QtCore.Qt.DecorationRole: + tot, add, rem = stats + w = self.diffwidth - 20 + h = 20 + + np = int(w*add/tot) + nm = int(w*rem/tot) + nd = w-np-nm + + pix = QtGui.QPixmap(w+10, h) + pix.fill(QtGui.QColor(0,0,0,0)) + painter = QtGui.QPainter(pix) + + for x0,w0, color in ((0, nm, 'red'), + (nm, np, 'green'), + (nm+np, nd, 'gray')): + color = QtGui.QColor(color) + painter.setBrush(color) + painter.setPen(color) + painter.drawRect(x0+5, 0, w0, h-3) + painter.setBrush(QtGui.QColor(0,0,0,0)) + pen = QtGui.QPen(QtCore.Qt.black) + pen.setWidth(0) + painter.setPen(pen) + painter.drawRect(5, 0, w+1, h-3) + painter.end() + return QtCore.QVariant(pix) + elif role == QtCore.Qt.ToolTipRole: + tot, add, rem = stats + msg = "Diff stats:<br>" + msg += "&nbsp;<b>File:&nbsp;</b>%s lines<br>" % tot + msg += "&nbsp;<b>added lines:&nbsp;</b> %s<br>" % add + msg += "&nbsp;<b>removed lines:&nbsp;</b> %s" % rem + return QtCore.QVariant(msg) + + elif column == 0: + if role in (QtCore.Qt.DisplayRole, QtCore.Qt.ToolTipRole): + return QtCore.QVariant(current_file_desc['desc']) + elif role == QtCore.Qt.DecorationRole: + if self._fulllist and ismerge(self.current_ctx): + if current_file_desc['infiles']: + icn = geticon('leftright') + elif current_file_desc['fromside'] == 'left': + icn = geticon('left') + elif current_file_desc['fromside'] == 'right': + icn = geticon('right') + return QtCore.QVariant(icn.pixmap(20,20)) + elif role == QtCore.Qt.FontRole: + if self._fulllist and current_file_desc['infiles']: + font = QtGui.QFont() + font.setBold(True) + return QtCore.QVariant(font) + elif role == QtCore.Qt.ForegroundRole: + color = self._flagcolor.get(current_file_desc['flag'], 'black') + if color is not None: + return QtCore.QVariant(QtGui.QColor(color)) + return nullvariant + + def headerData(self, section, orientation, role): + if ismerge(self.current_ctx): + if self._fulllist: + header = ('File (all)', 'Diff') + else: + header = ('File (merged only)', 'Diff') + else: + header = ('File', 'Diff') + + if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole: + return QtCore.QVariant(header[section]) + + return nullvariant
 
14
15
16
17
18
19
20
21
22
23
 
24
25
 
26
27
28
 
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
 
14
15
16
 
 
 
 
17
18
 
19
20
 
21
22
23
24
 
420
421
422
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
@@ -14,15 +14,11 @@
 # this program; if not, write to the Free Software Foundation, Inc.,  # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.   -import sys -import re - -from mercurial.revlog import LookupError  from mercurial import error   -from tortoisehg.util.util import tounicode, isbfile, Curry +from tortoisehg.util.util import tounicode, Curry   -from tortoisehg.hgqt.graph import Graph, ismerge, diff as revdiff +from tortoisehg.hgqt.graph import Graph  from tortoisehg.hgqt.graph import revision_grapher  from tortoisehg.hgqt.config import HgConfig  from tortoisehg.hgqt import icon as geticon @@ -424,278 +420,3 @@
    def notify_data_changed(self):   self.emit(SIGNAL("layoutChanged()")) - -replus = re.compile(r'^[+][^+].*', re.M) -reminus = re.compile(r'^[-][^-].*', re.M) - -class HgFileListModel(QtCore.QAbstractTableModel): - """ - Model used for listing (modified) files of a given Hg revision - """ - def __init__(self, repo, parent=None): - """ - data is a HgHLRepo instance - """ - QtCore.QAbstractTableModel.__init__(self, parent) - self.repo = repo - self._datacache = {} - self.load_config() - self.current_ctx = None - self._files = [] - self._filesdict = {} - self.diffwidth = 100 - self._fulllist = False - self._fill_iter = None - - def toggleFullFileList(self): - self._fulllist = not self._fulllist - self.loadFiles() - self.emit(SIGNAL('layoutChanged()')) - - def load_config(self): - cfg = HgConfig(self.repo.ui) - self._flagcolor = {} - self._flagcolor['='] = cfg.getFileModifiedColor(default='blue') - self._flagcolor['-'] = cfg.getFileRemovedColor(default='red') - self._flagcolor['-'] = cfg.getFileDeletedColor(default='red') - self._flagcolor['+'] = cfg.getFileAddedColor(default='green') - self._displaydiff = cfg.getDisplayDiffStats() - - def setDiffWidth(self, w): - if w != self.diffwidth: - self.diffwidth = w - self._datacache = {} - self.emit(SIGNAL('dataChanged(const QModelIndex &, const QModelIndex & )'), - self.index(1, 0), - self.index(1, self.rowCount())) - - def __len__(self): - return len(self._files) - - def rowCount(self, parent=None): - return len(self) - - def columnCount(self, parent=None): - return 1 + self._displaydiff - - def file(self, row): - return self._files[row]['path'] - - def fileflag(self, fn): - return self._filesdict[fn]['flag'] - - def fileparentctx(self, fn, ctx=None): - if ctx is None: - return self._filesdict[fn]['parent'] - return ctx.parents()[0] - - def fileFromIndex(self, index): - if not index.isValid() or index.row()>=len(self) or not self.current_ctx: - return None - row = index.row() - return self._files[row]['path'] - - def revFromIndex(self, index): - if self._fulllist and ismerge(self.current_ctx): - if not index.isValid() or index.row()>=len(self) or not self.current_ctx: - return None - row = index.row() - current_file_desc = self._files[row] - if current_file_desc['fromside'] == 'right': - return self.current_ctx.parents()[1].rev() - else: - return self.current_ctx.parents()[0].rev() - return None - - def indexFromFile(self, filename): - if filename in self._filesdict: - row = self._files.index(self._filesdict[filename]) - return self.index(row, 0) - return QtCore.QModelIndex() - - def _filterFile(self, filename, ctxfiles): - if self._fulllist: - return True - return filename in ctxfiles #self.current_ctx.files() - - def _buildDesc(self, parent, fromside): - _files = [] - ctx = self.current_ctx - ctxfiles = ctx.files() - changes = self.repo.status(parent.node(), ctx.node())[:3] - modified, added, removed = changes - for lst, flag in ((added, '+'), (modified, '='), (removed, '-')): - for f in [x for x in lst if self._filterFile(x, ctxfiles)]: - _files.append({'path': f, 'flag': flag, 'desc': f, - 'parent': parent, 'fromside': fromside, - 'infiles': f in ctxfiles}) - # renamed/copied files are handled by background - # filling process since it can be a bit long - for fdesc in _files: - bfile = isbfile(fdesc['path']) - fdesc['bfile'] = bfile - if bfile: - fdesc['desc'] = fdesc['desc'].replace('.hgbfiles'+os.sep, '') - - return _files - - def loadFiles(self): - self._fill_iter = None - self._files = [] - self._datacache = {} - self._files = self._buildDesc(self.current_ctx.parents()[0], 'left') - if ismerge(self.current_ctx): - _paths = [x['path'] for x in self._files] - _files = self._buildDesc(self.current_ctx.parents()[1], 'right') - self._files += [x for x in _files if x['path'] not in _paths] - self._filesdict = dict([(f['path'], f) for f in self._files]) - self.fillFileStats() - - def setSelectedRev(self, ctx): - if ctx != self.current_ctx: - self.current_ctx = ctx - self._datacache = {} - self.loadFiles() - self.emit(SIGNAL("layoutChanged()")) - - def fillFileStats(self): - """ - Method called to start the background process of computing - file stats, which are to be displayed in the 'Stats' column - """ - self._fill_iter = self._fill() - self._fill_one_step() - - def _fill_one_step(self): - if self._fill_iter is None: - return - try: - nextfill = self._fill_iter.next() - if nextfill is not None: - row, col = nextfill - idx = self.index(row, col) - self.emit(SIGNAL('dataChanged(const QModelIndex &, const QModelIndex &)'), - idx, idx) - QtCore.QTimer.singleShot(10, lambda self=self: self._fill_one_step()) - - except StopIteration: - self._fill_iter = None - - def _fill(self): - # the generator used to fill file stats as a background process - for row, desc in enumerate(self._files): - filename = desc['path'] - if desc['flag'] == '=' and self._displaydiff: - diff = revdiff(self.repo, self.current_ctx, desc['parent'], - files=[filename]) - try: - tot = self.current_ctx.filectx(filename).data().count('\n') - except LookupError: - tot = 0 - add = len(replus.findall(diff)) - rem = len(reminus.findall(diff)) - if tot == 0: - tot = max(add + rem, 1) - desc['stats'] = (tot, add, rem) - yield row, 1 - - if desc['flag'] == '+': - m = self.current_ctx.filectx(filename).renamed() - if m: - removed = self.repo.status(desc['parent'].node(), - self.current_ctx.node())[2] - oldname, node = m - if oldname in removed: - # removed.remove(oldname) XXX - desc['renamedfrom'] = (oldname, node) - desc['flag'] = '=' - desc['desc'] += '\n (was %s)' % oldname - else: - desc['copiedfrom'] = (oldname, node) - desc['flag'] = '=' - desc['desc'] += '\n (copy of %s)' % oldname - yield row, 0 - yield None - - def data(self, index, role): - if not index.isValid() or index.row()>len(self) or not self.current_ctx: - return nullvariant - row = index.row() - column = index.column() - - current_file_desc = self._files[row] - current_file = current_file_desc['path'] - stats = current_file_desc.get('stats') - if column == 1: - if stats is not None: - if role == QtCore.Qt.DecorationRole: - tot, add, rem = stats - w = self.diffwidth - 20 - h = 20 - - np = int(w*add/tot) - nm = int(w*rem/tot) - nd = w-np-nm - - pix = QtGui.QPixmap(w+10, h) - pix.fill(QtGui.QColor(0,0,0,0)) - painter = QtGui.QPainter(pix) - - for x0,w0, color in ((0, nm, 'red'), - (nm, np, 'green'), - (nm+np, nd, 'gray')): - color = QtGui.QColor(color) - painter.setBrush(color) - painter.setPen(color) - painter.drawRect(x0+5, 0, w0, h-3) - painter.setBrush(QtGui.QColor(0,0,0,0)) - pen = QtGui.QPen(QtCore.Qt.black) - pen.setWidth(0) - painter.setPen(pen) - painter.drawRect(5, 0, w+1, h-3) - painter.end() - return QtCore.QVariant(pix) - elif role == QtCore.Qt.ToolTipRole: - tot, add, rem = stats - msg = "Diff stats:<br>" - msg += "&nbsp;<b>File:&nbsp;</b>%s lines<br>" % tot - msg += "&nbsp;<b>added lines:&nbsp;</b> %s<br>" % add - msg += "&nbsp;<b>removed lines:&nbsp;</b> %s" % rem - return QtCore.QVariant(msg) - - elif column == 0: - if role in (QtCore.Qt.DisplayRole, QtCore.Qt.ToolTipRole): - return QtCore.QVariant(current_file_desc['desc']) - elif role == QtCore.Qt.DecorationRole: - if self._fulllist and ismerge(self.current_ctx): - if current_file_desc['infiles']: - icn = geticon('leftright') - elif current_file_desc['fromside'] == 'left': - icn = geticon('left') - elif current_file_desc['fromside'] == 'right': - icn = geticon('right') - return QtCore.QVariant(icn.pixmap(20,20)) - elif role == QtCore.Qt.FontRole: - if self._fulllist and current_file_desc['infiles']: - font = QtGui.QFont() - font.setBold(True) - return QtCore.QVariant(font) - elif role == QtCore.Qt.ForegroundRole: - color = self._flagcolor.get(current_file_desc['flag'], 'black') - if color is not None: - return QtCore.QVariant(QtGui.QColor(color)) - return nullvariant - - def headerData(self, section, orientation, role): - if ismerge(self.current_ctx): - if self._fulllist: - header = ('File (all)', 'Diff') - else: - header = ('File (merged only)', 'Diff') - else: - header = ('File', 'Diff') - - if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole: - return QtCore.QVariant(header[section]) - - return nullvariant
 
24
25
26
27
 
 
28
29
30
 
24
25
26
 
27
28
29
30
31
@@ -24,7 +24,8 @@
 from tortoisehg.hgqt.decorators import timeit    from tortoisehg.hgqt import icon as geticon -from tortoisehg.hgqt.repomodel import HgRepoListModel, HgFileListModel +from tortoisehg.hgqt.repomodel import HgRepoListModel +from tortoisehg.hgqt.filelistmodel import HgFileListModel  from tortoisehg.hgqt.filedialogs import FileLogDialog, FileDiffDialog  from tortoisehg.hgqt.manifestdialog import ManifestDialog  from tortoisehg.hgqt.dialogmixin import HgDialogMixin