80 idx = self.sourceModel().index(offset, 0) |
80 idx = self.sourceModel().index(offset, 0) |
81 return idx.data(HistoryModel.DateRole) |
81 return idx.data(HistoryModel.DateRole) |
82 |
82 |
83 return QAbstractProxyModel.data(self, index, role) |
83 return QAbstractProxyModel.data(self, index, role) |
84 |
84 |
85 def columnCount(self, parent=QModelIndex()): |
85 def columnCount(self, parent=None): |
86 """ |
86 """ |
87 Public method to get the number of columns. |
87 Public method to get the number of columns. |
88 |
88 |
89 @param parent index of parent (QModelIndex) |
89 @param parent index of parent (QModelIndex) |
90 @return number of columns (integer) |
90 @return number of columns (integer) |
91 """ |
91 """ |
|
92 if parent is None: |
|
93 parent = QModelIndex() |
|
94 |
92 return self.sourceModel().columnCount(self.mapToSource(parent)) |
95 return self.sourceModel().columnCount(self.mapToSource(parent)) |
93 |
96 |
94 def rowCount(self, parent=QModelIndex()): |
97 def rowCount(self, parent=None): |
95 """ |
98 """ |
96 Public method to determine the number of rows. |
99 Public method to determine the number of rows. |
97 |
100 |
98 @param parent index of parent (QModelIndex) |
101 @param parent index of parent (QModelIndex) |
99 @return number of rows (integer) |
102 @return number of rows (integer) |
100 """ |
103 """ |
|
104 if parent is None: |
|
105 parent = QModelIndex() |
|
106 |
101 if parent.internalId() != 0 or \ |
107 if parent.internalId() != 0 or \ |
102 parent.column() > 0 or \ |
108 parent.column() > 0 or \ |
103 self.sourceModel() is None: |
109 self.sourceModel() is None: |
104 return 0 |
110 return 0 |
105 |
111 |
159 return QModelIndex() |
165 return QModelIndex() |
160 startDateRow = self.__sourceDateRow(offset - 1) |
166 startDateRow = self.__sourceDateRow(offset - 1) |
161 return self.sourceModel().index( |
167 return self.sourceModel().index( |
162 startDateRow + proxyIndex.row(), proxyIndex.column()) |
168 startDateRow + proxyIndex.row(), proxyIndex.column()) |
163 |
169 |
164 def index(self, row, column, parent=QModelIndex()): |
170 def index(self, row, column, parent=None): |
165 """ |
171 """ |
166 Public method to create an index. |
172 Public method to create an index. |
167 |
173 |
168 @param row row number for the index (integer) |
174 @param row row number for the index (integer) |
169 @param column column number for the index (integer) |
175 @param column column number for the index (integer) |
170 @param parent index of the parent item (QModelIndex) |
176 @param parent index of the parent item (QModelIndex) |
171 @return requested index (QModelIndex) |
177 @return requested index (QModelIndex) |
172 """ |
178 """ |
|
179 if parent is None: |
|
180 parent = QModelIndex() |
|
181 |
173 if row < 0 or \ |
182 if row < 0 or \ |
174 column < 0 or \ |
183 column < 0 or \ |
175 column >= self.columnCount(parent) or \ |
184 column >= self.columnCount(parent) or \ |
176 parent.column() > 0: |
185 parent.column() > 0: |
177 return QModelIndex() |
186 return QModelIndex() |
190 offset = index.internalId() |
199 offset = index.internalId() |
191 if offset == 0 or not index.isValid(): |
200 if offset == 0 or not index.isValid(): |
192 return QModelIndex() |
201 return QModelIndex() |
193 return self.createIndex(offset - 1, 0, 0) |
202 return self.createIndex(offset - 1, 0, 0) |
194 |
203 |
195 def hasChildren(self, parent=QModelIndex()): |
204 def hasChildren(self, parent=None): |
196 """ |
205 """ |
197 Public method to check, if an entry has some children. |
206 Public method to check, if an entry has some children. |
198 |
207 |
199 @param parent index of the entry to check (QModelIndex) |
208 @param parent index of the entry to check (QModelIndex) |
200 @return flag indicating the presence of children (boolean) |
209 @return flag indicating the presence of children (boolean) |
201 """ |
210 """ |
|
211 if parent is None: |
|
212 parent = QModelIndex() |
|
213 |
202 grandparent = parent.parent() |
214 grandparent = parent.parent() |
203 if not grandparent.isValid(): |
215 if not grandparent.isValid(): |
204 return True |
216 return True |
205 return False |
217 return False |
206 |
218 |
297 row -= 1 |
309 row -= 1 |
298 dateRow = max(0, row) |
310 dateRow = max(0, row) |
299 row = sourceIndex.row() - self.__sourceRowCache[dateRow] |
311 row = sourceIndex.row() - self.__sourceRowCache[dateRow] |
300 return self.createIndex(row, sourceIndex.column(), dateRow + 1) |
312 return self.createIndex(row, sourceIndex.column(), dateRow + 1) |
301 |
313 |
302 def removeRows(self, row, count, parent=QModelIndex()): |
314 def removeRows(self, row, count, parent=None): |
303 """ |
315 """ |
304 Public method to remove entries from the model. |
316 Public method to remove entries from the model. |
305 |
317 |
306 @param row row of the first entry to remove (integer) |
318 @param row row of the first entry to remove (integer) |
307 @param count number of entries to remove (integer) |
319 @param count number of entries to remove (integer) |
308 @param parent index of the parent entry (QModelIndex) |
320 @param parent index of the parent entry (QModelIndex) |
309 @return flag indicating successful removal (boolean) |
321 @return flag indicating successful removal (boolean) |
310 """ |
322 """ |
|
323 if parent is None: |
|
324 parent = QModelIndex() |
|
325 |
311 if row < 0 or \ |
326 if row < 0 or \ |
312 count <= 0 or \ |
327 count <= 0 or \ |
313 row + count > self.rowCount(parent): |
328 row + count > self.rowCount(parent): |
314 return False |
329 return False |
315 |
330 |