85 } |
85 } |
86 |
86 |
87 self.__testResults = [] |
87 self.__testResults = [] |
88 self.__testResultsById = {} |
88 self.__testResultsById = {} |
89 |
89 |
90 def index(self, row, column, parent=QModelIndex()): |
90 def index(self, row, column, parent=None): |
91 """ |
91 """ |
92 Public method to generate an index for the given row and column to |
92 Public method to generate an index for the given row and column to |
93 identify the item. |
93 identify the item. |
94 |
94 |
95 @param row row for the index |
95 @param row row for the index |
96 @type int |
96 @type int |
97 @param column column for the index |
97 @param column column for the index |
98 @type int |
98 @type int |
99 @param parent index of the parent item (defaults to QModelIndex()) |
99 @param parent index of the parent item (defaults to None) |
100 @type QModelIndex (optional) |
100 @type QModelIndex (optional) |
101 @return index for the item |
101 @return index for the item |
102 @rtype QModelIndex |
102 @rtype QModelIndex |
103 """ |
103 """ |
|
104 if parent is None: |
|
105 parent = QModelIndex() |
|
106 |
104 if not self.hasIndex(row, column, parent): # check bounds etc. |
107 if not self.hasIndex(row, column, parent): # check bounds etc. |
105 return QModelIndex() |
108 return QModelIndex() |
106 |
109 |
107 if not parent.isValid(): |
110 if not parent.isValid(): |
108 # top level item |
111 # top level item |
209 if idx == TopLevelId: |
212 if idx == TopLevelId: |
210 return QModelIndex() |
213 return QModelIndex() |
211 else: |
214 else: |
212 return self.index(idx, 0) |
215 return self.index(idx, 0) |
213 |
216 |
214 def rowCount(self, parent=QModelIndex()): |
217 def rowCount(self, parent=None): |
215 """ |
218 """ |
216 Public method to get the number of row for a given parent index. |
219 Public method to get the number of row for a given parent index. |
217 |
220 |
218 @param parent index of the parent item (defaults to QModelIndex()) |
221 @param parent index of the parent item (defaults to None) |
219 @type QModelIndex (optional) |
222 @type QModelIndex (optional) |
220 @return number of rows |
223 @return number of rows |
221 @rtype int |
224 @rtype int |
222 """ |
225 """ |
223 if not parent.isValid(): |
226 if parent is None or not parent.isValid(): |
224 return len(self.__testResults) |
227 return len(self.__testResults) |
225 |
228 |
226 if ( |
229 if ( |
227 parent.internalId() == TopLevelId |
230 parent.internalId() == TopLevelId |
228 and parent.column() == 0 |
231 and parent.column() == 0 |
230 ): |
233 ): |
231 return len(self.__testResults[parent.row()].extra) |
234 return len(self.__testResults[parent.row()].extra) |
232 |
235 |
233 return 0 |
236 return 0 |
234 |
237 |
235 def columnCount(self, parent=QModelIndex()): |
238 def columnCount(self, parent=None): |
236 """ |
239 """ |
237 Public method to get the number of columns. |
240 Public method to get the number of columns. |
238 |
241 |
239 @param parent index of the parent item (defaults to QModelIndex()) |
242 @param parent index of the parent item (defaults to None) |
240 @type QModelIndex (optional) |
243 @type QModelIndex (optional) |
241 @return number of columns |
244 @return number of columns |
242 @rtype int |
245 @rtype int |
243 """ |
246 """ |
244 if not parent.isValid(): |
247 if parent is None or not parent.isValid(): |
245 return len(TestResultsModel.Headers) |
248 return len(TestResultsModel.Headers) |
246 else: |
249 else: |
247 return 1 |
250 return 1 |
248 |
251 |
249 def clear(self): |
252 def clear(self): |
539 """ |
542 """ |
540 super().rowsInserted(parent, startRow, endRow) |
543 super().rowsInserted(parent, startRow, endRow) |
541 |
544 |
542 self.spanFirstColumn(startRow, endRow) |
545 self.spanFirstColumn(startRow, endRow) |
543 |
546 |
544 def dataChanged(self, topLeft, bottomRight, roles=[]): |
547 def dataChanged(self, topLeft, bottomRight, roles=None): |
545 """ |
548 """ |
546 Public method called when the model data has changed. |
549 Public method called when the model data has changed. |
547 |
550 |
548 @param topLeft index of the top left element |
551 @param topLeft index of the top left element |
549 @type QModelIndex |
552 @type QModelIndex |
550 @param bottomRight index of the bottom right element |
553 @param bottomRight index of the bottom right element |
551 @type QModelIndex |
554 @type QModelIndex |
552 @param roles list of roles changed (defaults to []) |
555 @param roles list of roles changed (defaults to None) |
553 @type list of Qt.ItemDataRole (optional) |
556 @type list of Qt.ItemDataRole (optional) |
554 """ |
557 """ |
|
558 if roles is None: |
|
559 roles = [] |
|
560 |
555 super().dataChanged(topLeft, bottomRight, roles) |
561 super().dataChanged(topLeft, bottomRight, roles) |
556 |
562 |
557 while topLeft.parent().isValid(): |
563 while topLeft.parent().isValid(): |
558 topLeft = topLeft.parent() |
564 topLeft = topLeft.parent() |
559 while bottomRight.parent().isValid(): |
565 while bottomRight.parent().isValid(): |