167 """ |
167 """ |
168 self.beginResetModel() |
168 self.beginResetModel() |
169 self.__loaded = False |
169 self.__loaded = False |
170 self.endResetModel() |
170 self.endResetModel() |
171 |
171 |
172 def rowCount(self, parent=QModelIndex()): |
172 def rowCount(self, parent=None): |
173 """ |
173 """ |
174 Public method to determine the number of rows. |
174 Public method to determine the number of rows. |
175 |
175 |
176 @param parent index of parent (QModelIndex) |
176 @param parent index of parent (QModelIndex) |
177 @return number of rows (integer) |
177 @return number of rows (integer) |
178 """ |
178 """ |
|
179 if parent is None: |
|
180 parent = QModelIndex() |
|
181 |
179 self.__load() |
182 self.__load() |
180 if parent.isValid(): |
183 if parent.isValid(): |
181 return 0 |
184 return 0 |
182 return len(self.__historyDict) |
185 return len(self.__historyDict) |
183 |
186 |
184 def columnCount(self, parent=QModelIndex()): |
187 def columnCount(self, parent=None): |
185 """ |
188 """ |
186 Public method to get the number of columns. |
189 Public method to get the number of columns. |
187 |
190 |
188 @param parent index of parent (QModelIndex) |
191 @param parent index of parent (QModelIndex) |
189 @return number of columns (integer) |
192 @return number of columns (integer) |
190 """ |
193 """ |
|
194 if parent is None: |
|
195 parent = QModelIndex() |
|
196 |
191 return self.sourceModel().columnCount(self.mapToSource(parent)) |
197 return self.sourceModel().columnCount(self.mapToSource(parent)) |
192 |
198 |
193 def mapToSource(self, proxyIndex): |
199 def mapToSource(self, proxyIndex): |
194 """ |
200 """ |
195 Public method to map an index to the source model index. |
201 Public method to map an index to the source model index. |
220 except ValueError: |
226 except ValueError: |
221 return QModelIndex() |
227 return QModelIndex() |
222 |
228 |
223 return self.createIndex(row, sourceIndex.column(), sourceOffset) |
229 return self.createIndex(row, sourceIndex.column(), sourceOffset) |
224 |
230 |
225 def index(self, row, column, parent=QModelIndex()): |
231 def index(self, row, column, parent=None): |
226 """ |
232 """ |
227 Public method to create an index. |
233 Public method to create an index. |
228 |
234 |
229 @param row row number for the index (integer) |
235 @param row row number for the index (integer) |
230 @param column column number for the index (integer) |
236 @param column column number for the index (integer) |
231 @param parent index of the parent item (QModelIndex) |
237 @param parent index of the parent item (QModelIndex) |
232 @return requested index (QModelIndex) |
238 @return requested index (QModelIndex) |
233 """ |
239 """ |
|
240 if parent is None: |
|
241 parent = QModelIndex() |
|
242 |
234 self.__load() |
243 self.__load() |
235 if row < 0 or row >= self.rowCount(parent) or \ |
244 if row < 0 or row >= self.rowCount(parent) or \ |
236 column < 0 or column >= self.columnCount(parent): |
245 column < 0 or column >= self.columnCount(parent): |
237 return QModelIndex() |
246 return QModelIndex() |
238 |
247 |
316 @param start start row (integer) |
325 @param start start row (integer) |
317 @param end end row (integer) |
326 @param end end row (integer) |
318 """ |
327 """ |
319 self.__sourceReset() |
328 self.__sourceReset() |
320 |
329 |
321 def removeRows(self, row, count, parent=QModelIndex()): |
330 def removeRows(self, row, count, parent=None): |
322 """ |
331 """ |
323 Public method to remove entries from the model. |
332 Public method to remove entries from the model. |
324 |
333 |
325 @param row row of the first entry to remove (integer) |
334 @param row row of the first entry to remove (integer) |
326 @param count number of entries to remove (integer) |
335 @param count number of entries to remove (integer) |
327 @param parent index of the parent entry (QModelIndex) |
336 @param parent index of the parent entry (QModelIndex) |
328 @return flag indicating successful removal (boolean) |
337 @return flag indicating successful removal (boolean) |
329 """ |
338 """ |
|
339 if parent is None: |
|
340 parent = QModelIndex() |
|
341 |
330 if row < 0 or \ |
342 if row < 0 or \ |
331 count <= 0 or \ |
343 count <= 0 or \ |
332 row + count > self.rowCount(parent) or \ |
344 row + count > self.rowCount(parent) or \ |
333 parent.isValid(): |
345 parent.isValid(): |
334 return False |
346 return False |