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

reporegistry: fixed addRepo() implementation

According to the QAbstractItemModel subclassing reference [1], beginInsertRows()
and endInsertRows() must be called when inserting nodes.

No wonder the tree view wasn't updated (Qt doesn't yet have psychic powers).

This allowed to remove that tview.reset() call hack.

[1] http://doc.qt.nokia.com/4.6/model-view-model-subclassing.html

Changeset cfd9888f6356

Parent 468ccb8a17b8

by Adrian Buehlmann

Changes to one file · Browse files at cfd9888f6356 Showing diff from parent 468ccb8a17b8 Diff from another changeset...

 
81
82
83
 
 
84
85
86
 
138
139
140
 
 
 
 
 
141
142
 
 
143
 
144
145
146
 
175
176
177
178
179
 
81
82
83
84
85
86
87
88
 
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
 
185
186
187
 
 
@@ -81,6 +81,8 @@
  self.allrepos = all = RepoGroupItem(_('All Repositories'))   root.appendChild(all)   + # see http://doc.qt.nokia.com/4.6/model-view-model-subclassing.html +   def index(self, row, column, parent):   if not self.hasIndex(row, column, parent):   return QModelIndex() @@ -138,9 +140,17 @@
  return 0   return Qt.ItemIsEnabled | Qt.ItemIsSelectable   + # functions not defined in QAbstractItemModel + + def allreposIndex(self): + return self.createIndex(0, 0, self.allrepos) +   def addRepo(self, reporoot):   all = self.allrepos + cc = all.childCount() + self.beginInsertRows(self.allreposIndex(), cc, cc + 1)   all.appendChild(RepoItem(reporoot)) + self.endInsertRows()     def getRepoItem(self, reporoot):   for c in self.allrepos.childs: @@ -175,5 +185,3 @@
  m = self.tmodel   if m.getRepoItem(reporoot) == None:   m.addRepo(reporoot) - self.tview.reset() - QtCore.QTimer.singleShot(0, self.expand)