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

status: make rows checkable

Only sensitive to row activation (dbl-click, or enter). Clicking
on the checkbox or hitting space do not yet work.

Changeset 154aa9dbd1a7

Parent 45469bf20d70

by Steve Borho

Changes to one file · Browse files at 154aa9dbd1a7 Showing diff from parent 45469bf20d70 Diff from another changeset...

 
98
99
100
 
101
102
103
 
147
148
149
 
150
151
152
 
155
156
157
158
 
159
160
161
162
163
164
 
 
 
 
 
 
 
 
 
165
166
167
 
170
171
172
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
175
176
 
98
99
100
101
102
103
104
 
148
149
150
151
152
153
154
 
157
158
159
 
160
161
 
 
 
 
 
162
163
164
165
166
167
168
169
170
171
172
173
 
176
177
178
 
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@@ -98,6 +98,7 @@
  self.tv.setModel(tm)   self.tv.resizeColumnToContents(0)   self.tv.resizeColumnToContents(1) + self.connect(self.tv, SIGNAL('activated(QModelIndex)'), tm.toggleRow)     def rowSelected(self, index):   pfile = index.model().getPath(index) @@ -147,6 +148,7 @@
  self.status_error = str(e)   self.rows = rows   self.headers = (_('Stat'), _('Filename')) + self.checked = [False,] * len(rows)     def rowCount(self, parent):   return len(self.rows) @@ -155,13 +157,17 @@
  return len(self.headers)     def data(self, index, role): - if not index.isValid() or role != Qt.DisplayRole: + if not index.isValid():   return QVariant() - return QVariant(self.rows[index.row()][index.column()]) - - def getPath(self, index): - assert index.isValid() - return self.rows[index.row()][COL_PATH] + if role == Qt.DisplayRole: + return QVariant(self.rows[index.row()][index.column()]) + if role == Qt.CheckStateRole and index.column() == COL_STATUS: + # also Qt.PartiallyChecked + if self.checked[index.row()]: + return Qt.Checked + else: + return Qt.Unchecked + return QVariant()     def headerData(self, col, orientation, role):   if role != Qt.DisplayRole or orientation != Qt.Horizontal: @@ -170,7 +176,21 @@
  return QVariant(self.headers[col])     def flags(self, index): - return Qt.ItemIsSelectable | Qt.ItemIsEnabled + flags = Qt.ItemIsSelectable | Qt.ItemIsEnabled + if index.column() == COL_STATUS: + flags |= Qt.ItemIsUserCheckable + return flags + + # Custom methods + + def getPath(self, index): + assert index.isValid() + return self.rows[index.row()][COL_PATH] + + def toggleRow(self, index): + assert index.isValid() + self.checked[index.row()] = not self.checked[index.row()] + self.emit(SIGNAL("layoutChanged()"))      def run(ui, *pats, **opts):