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

reporegistry: let's try showing the path for the repos

- introduced subclasses for specific tree items
- removed hiding of header
- implemented headerData() in RepoTreeModel

Changeset 20112f5f86f6

Parent b44b75c52035

by Adrian Buehlmann

Changes to one file · Browse files at 20112f5f86f6 Showing diff from parent b44b75c52035 Diff from another changeset...

 
10
11
12
13
 
14
15
16
 
19
20
21
22
23
 
24
25
26
 
37
38
39
40
 
41
42
43
 
44
45
46
 
49
50
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
53
54
55
56
 
57
58
 
59
60
61
 
103
104
105
 
 
 
 
 
 
 
106
107
108
109
110
111
112
113
114
 
 
115
116
117
 
126
127
128
129
130
131
132
 
10
11
12
 
13
14
15
16
 
19
20
21
 
 
22
23
24
25
 
36
37
38
 
39
40
41
 
42
43
44
45
 
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
 
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
148
 
149
150
151
152
153
 
162
163
164
 
165
166
167
@@ -10,7 +10,7 @@
 from PyQt4 import QtCore, QtGui    from PyQt4.QtCore import Qt, QVariant, SIGNAL, SLOT -from PyQt4.QtCore import QModelIndex +from PyQt4.QtCore import QModelIndex, QString    from PyQt4.QtGui import QWidget, QVBoxLayout   @@ -19,8 +19,7 @@
 connect = QtCore.QObject.connect    class RepoTreeItem: - def __init__(self, name, parent=None): - self.name = name + def __init__(self, parent=None):   self._parent = parent   self.childs = []   self._row = 0 @@ -37,10 +36,10 @@
  return len(self.childs)     def columnCount(self): - return 1 + return 2     def data(self, column): - return QVariant(self.name) + return QVariant()     def row(self):   return self._row @@ -49,13 +48,43 @@
  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.rootItem = root = RepoTreeItem()   - self.allrepos = all = RepoTreeItem(_('All Repositories')) + self.allrepos = all = RepoGroupItem(_('All Repositories'))   root.appendChild(all)     def index(self, row, column, parent): @@ -103,15 +132,22 @@
  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): - reponame = os.path.basename(reporoot)   all = self.allrepos - all.appendChild(RepoTreeItem(reponame)) + all.appendChild(RepoItem(reporoot)) +    class RepoRegistryView(QWidget):   def __init__(self, parent=None): @@ -126,7 +162,6 @@
  self.tview = tv = QtGui.QTreeView()   lay.addWidget(tv)   tv.setModel(m) - tv.setHeaderHidden(True)     def addRepo(self, reporoot):   self.tmodel.addRepo(reporoot)