9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 import bisect |
12 import bisect |
13 |
13 |
14 from PyQt4.QtCore import Qt, QModelIndex, QDate |
14 from PyQt5.QtCore import Qt, QModelIndex, QDate, QAbstractProxyModel |
15 from PyQt4.QtGui import QAbstractProxyModel |
|
16 |
15 |
17 from .HistoryModel import HistoryModel |
16 from .HistoryModel import HistoryModel |
18 |
17 |
19 import UI.PixmapCache |
18 import UI.PixmapCache |
20 |
19 |
237 self.sourceModel().modelReset.connect(self.__sourceReset) |
236 self.sourceModel().modelReset.connect(self.__sourceReset) |
238 self.sourceModel().layoutChanged.connect(self.__sourceReset) |
237 self.sourceModel().layoutChanged.connect(self.__sourceReset) |
239 self.sourceModel().rowsInserted.connect(self.__sourceRowsInserted) |
238 self.sourceModel().rowsInserted.connect(self.__sourceRowsInserted) |
240 self.sourceModel().rowsRemoved.connect(self.__sourceRowsRemoved) |
239 self.sourceModel().rowsRemoved.connect(self.__sourceRowsRemoved) |
241 |
240 |
242 self.reset() |
241 self.beginResetModel() |
|
242 self.endResetModel() |
243 |
243 |
244 def __sourceReset(self): |
244 def __sourceReset(self): |
245 """ |
245 """ |
246 Private slot to handle a reset of the source model. |
246 Private slot to handle a reset of the source model. |
247 """ |
247 """ |
|
248 self.beginResetModel() |
248 self.__sourceRowCache = [] |
249 self.__sourceRowCache = [] |
249 self.reset() |
250 self.endResetModel() |
250 |
251 |
251 def __sourceRowsInserted(self, parent, start, end): |
252 def __sourceRowsInserted(self, parent, start, end): |
252 """ |
253 """ |
253 Private slot to handle the insertion of data in the source model. |
254 Private slot to handle the insertion of data in the source model. |
254 |
255 |
256 @param start start row (integer) |
257 @param start start row (integer) |
257 @param end end row (integer) |
258 @param end end row (integer) |
258 """ |
259 """ |
259 if not parent.isValid(): |
260 if not parent.isValid(): |
260 if start != 0 or start != end: |
261 if start != 0 or start != end: |
|
262 self.beginResetModel() |
261 self.__sourceRowCache = [] |
263 self.__sourceRowCache = [] |
262 self.reset() |
264 self.endResetModel() |
263 return |
265 return |
264 |
266 |
265 self.__sourceRowCache = [] |
267 self.__sourceRowCache = [] |
266 treeIndex = self.mapFromSource(self.sourceModel().index(start, 0)) |
268 treeIndex = self.mapFromSource(self.sourceModel().index(start, 0)) |
267 treeParent = treeIndex.parent() |
269 treeParent = treeIndex.parent() |
337 @param parent reference to the parent index (QModelIndex) |
339 @param parent reference to the parent index (QModelIndex) |
338 @param start start row (integer) |
340 @param start start row (integer) |
339 @param end end row (integer) |
341 @param end end row (integer) |
340 """ |
342 """ |
341 if not self.__removingDown: |
343 if not self.__removingDown: |
|
344 self.beginResetModel() |
342 self.__sourceRowCache = [] |
345 self.__sourceRowCache = [] |
343 self.reset() |
346 self.endResetModel() |
344 return |
347 return |
345 |
348 |
346 if not parent.isValid(): |
349 if not parent.isValid(): |
347 if self.__sourceRowCache: |
350 if self.__sourceRowCache: |
348 i = end |
351 i = end |