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

logcolumns: introduce a configuration dialog for log columns

Tries to be future-proof. The list of 'all' columns is passed to the
dialog. If columns are added or removed, it just works. Columns are
enabled by checking them, re-ordered by dragging them (Qt makes this
stupid easy).

The dialog is connected to 'thg test', until someone connects it to the
workbench in an appropriate fashion.

Changeset a807b8c1b49d

Parent 8e207458d4d6

by Steve Borho

Changes to 2 files · Browse files at a807b8c1b49d Showing diff from parent 8e207458d4d6 Diff from another changeset...

Change 1 of 1 Show Entire File tortoisehg/​hgqt/​logcolumns.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
@@ -0,0 +1,81 @@
+# logcolumns.py - select and reorder columns in log model +# +# Copyright 2010 Steve Borho <steve@borho.org> +# +# This software may be used and distributed according to the terms of the +# GNU General Public License version 2, incorporated herein by reference. + +import os + +from tortoisehg.hgqt import qtlib +from tortoisehg.util import hglib +from tortoisehg.hgqt.i18n import _ + +from PyQt4.QtCore import * +from PyQt4.QtGui import * + +class ColumnSelectDialog(QDialog): + def __init__(self, all, parent=None): + QDialog.__init__(self, parent) + + self.setWindowTitle(_('Workbench Log Columns')) + s = QSettings() + cols = s.value('workbench/columns').toStringList() + if cols: + self.curcolumns = [c for c in cols if c in all] + else: + self.curcolumns = all + self.disabled = [c for c in all if c not in self.curcolumns] + + layout = QVBoxLayout() + layout.setMargin(0) + self.setLayout(layout) + + list = QListWidget() + # enabled cols are listed in sorted order + for c in self.curcolumns: + item = QListWidgetItem(c) + item.setFlags(Qt.ItemIsSelectable | + Qt.ItemIsEnabled | + Qt.ItemIsDragEnabled | + Qt.ItemIsUserCheckable) + item.setCheckState(Qt.Checked) + list.addItem(item) + # disabled cols are listed last + for c in self.disabled: + item = QListWidgetItem(c) + item.setFlags(Qt.ItemIsSelectable | + Qt.ItemIsEnabled | + Qt.ItemIsDragEnabled | + Qt.ItemIsUserCheckable) + item.setCheckState(Qt.Unchecked) + list.addItem(item) + list.setDragDropMode(QListView.InternalMove) + layout.addWidget(list) + self.list = list + + # dialog buttons + BB = QDialogButtonBox + bb = QDialogButtonBox(BB.Ok|BB.Cancel) + self.apply_button = bb.button(BB.Apply) + self.connect(bb, SIGNAL("accepted()"), self, SLOT("accept()")) + self.connect(bb, SIGNAL("rejected()"), self, SLOT("reject()")) + bb.button(BB.Ok).setDefault(True) + layout.addWidget(bb) + + def accept(self): + s = QSettings() + cols = [] + for i in xrange(self.list.count()): + item = self.list.item(i) + if item.checkState() == Qt.Checked: + cols.append(str(item.text())) + s.setValue('workbench/columns', cols) + QDialog.accept(self) + + def reject(self): + QDialog.reject(self) + +def run(ui, *pats, **opts): + _allcolumns = ('ID', 'Branch', 'Graph', 'Log', 'Author', 'Date', 'Tags',) + return ColumnSelectDialog(_allcolumns)
 
396
397
398
399
 
 
400
401
402
 
396
397
398
 
399
400
401
402
403
@@ -396,7 +396,8 @@
   def test(ui, *pats, **opts):   """test arbitrary widgets""" - from tortoisehg.hgqt.chunkselect import run + from tortoisehg.hgqt.logcolumns import run + #from tortoisehg.hgqt.chunkselect import run   qtrun(run, ui, *pats, **opts)    def remove(ui, *pats, **opts):