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

reporegistry: reduce indentation

default is 20

Changeset 4cb4f4b694b6

Parent 5865fdf593ae

by Adrian Buehlmann

Changes to one file · Browse files at 4cb4f4b694b6 Showing diff from parent 5865fdf593ae Diff from another changeset...

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
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
 # reporegistry.py - registry for a user's repositories  #  # Copyright 2010 Adrian Buehlmann <adrian@cadifra.com>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2 or any later version.    import os    from PyQt4 import QtCore, QtGui    from PyQt4.QtCore import Qt, QVariant, SIGNAL, SLOT  from PyQt4.QtCore import QModelIndex, QString    from PyQt4.QtGui import QWidget, QVBoxLayout    from tortoisehg.hgqt.i18n import _    connect = QtCore.QObject.connect    class RepoTreeItem:   def __init__(self, parent=None):   self._parent = parent   self.childs = []   self._row = 0     def appendChild(self, child):   child._row = len(self.childs)   child._parent = self   self.childs.append(child)     def child(self, row):   return self.childs[row]     def childCount(self):   return len(self.childs)     def columnCount(self):   return 2     def data(self, column):   return QVariant()     def row(self):   return self._row     def parent(self):   return self._parent      class RepoItem(RepoTreeItem):   def __init__(self, rootpath, parent=None):   RepoTreeItem.__init__(self, parent)   self.rootpath = rootpath     def columnCount(self):   return 2     def data(self, column):   if column == 0:   return QVariant(os.path.basename(self.rootpath))   elif column == 1:   return QVariant(self.rootpath)   return QVariant()      class RepoGroupItem(RepoTreeItem):   def __init__(self, name, parent=None):   RepoTreeItem.__init__(self, parent)   self.name = name     def columnCount(self):   return 2     def data(self, column):   if column == 0:   return QVariant(self.name)   return QVariant()      class RepoTreeModel(QtCore.QAbstractItemModel):   def __init__(self, parent=None):   QtCore.QAbstractItemModel.__init__(self, parent)     self.rootItem = root = RepoTreeItem()     self.allrepos = all = RepoGroupItem(_('All Repositories'))   root.appendChild(all)     def index(self, row, column, parent):   if not self.hasIndex(row, column, parent):   return QModelIndex()   if (not parent.isValid()):   parentItem = self.rootItem   else:   parentItem = parent.internalPointer()   childItem = parentItem.child(row)   if childItem:   return self.createIndex(row, column, childItem)   else:   return QModelIndex()     def parent(self, index):   if not index.isValid():   return QModelIndex()   childItem = index.internalPointer()   parentItem = childItem.parent()   if parentItem is self.rootItem:   return QModelIndex()   return self.createIndex(parentItem.row(), 0, parentItem)     def rowCount(self, parent):   if parent.column() > 0:   return 0   if not parent.isValid():   parentItem = self.rootItem;   else:   parentItem = parent.internalPointer()   return parentItem.childCount()     def columnCount(self, parent):   if parent.isValid():   return parent.internalPointer().columnCount()   else:   return self.rootItem.columnCount()     def data(self, index, role):   if not index.isValid():   return QVariant()   if role != Qt.DisplayRole:   return QVariant();   item = index.internalPointer()   return item.data(index.column())     def headerData(self, section, orientation, role):   if role == Qt.DisplayRole:   if orientation == Qt.Horizontal:   if section == 1:   return QString(_('Path'))   return QVariant()     def flags(self, index):   if not index.isValid():   return 0   return Qt.ItemIsEnabled | Qt.ItemIsSelectable     def addRepo(self, reporoot):   all = self.allrepos   all.appendChild(RepoItem(reporoot))      class RepoRegistryView(QWidget):   def __init__(self, parent=None):   QWidget.__init__(self, parent)     lay = QVBoxLayout()   lay.setContentsMargins(0, 0, 0, 0)   self.setLayout(lay)     self.tmodel = m = RepoTreeModel()     self.tview = tv = QtGui.QTreeView()   lay.addWidget(tv)   tv.setModel(m) + tv.setIndentation(10)     QtCore.QTimer.singleShot(0, self.initialized)     def initialized(self):   self.tview.expandToDepth(0)     def addRepo(self, reporoot):   self.tmodel.addRepo(reporoot)