77 self.methodCount = 0 |
77 self.methodCount = 0 |
78 self.childCount = 0 |
78 self.childCount = 0 |
79 self.currentCount = -1 # -1 indicates to (re)load children |
79 self.currentCount = -1 # -1 indicates to (re)load children |
80 # Indicator that there are children |
80 # Indicator that there are children |
81 self.hasChildren = False |
81 self.hasChildren = False |
|
82 self.populated = False |
82 # Indicator that item was at least once fully populated |
83 # Indicator that item was at least once fully populated |
83 self.wasPopulated = False |
84 self.wasPopulated = False |
84 |
85 |
85 self.children = [] |
86 self.children = [] |
86 # Flag to prevent endless reloading of current item while waiting on |
87 # Flag to prevent endless reloading of current item while waiting on |
237 |
241 |
238 @return total number of children |
242 @return total number of children |
239 @rtype int |
243 @rtype int |
240 """ |
244 """ |
241 return self.childCount + self.methodCount |
245 return self.childCount + self.methodCount |
242 |
|
243 @property |
|
244 def populated(self): |
|
245 """ |
|
246 Public property returning a flag indicating if item is fully populated. |
|
247 |
|
248 @return item is fully populated |
|
249 @rtype bool |
|
250 """ |
|
251 return self.currentCount >= (self.childCount + self.methodCount) |
|
252 |
246 |
253 |
247 |
254 class VariablesModel(QAbstractItemModel): |
248 class VariablesModel(QAbstractItemModel): |
255 """ |
249 """ |
256 Class implementing the data model for QTreeView. |
250 Class implementing the data model for QTreeView. |
373 return |
367 return |
374 |
368 |
375 elif itemStartIndex == -2: |
369 elif itemStartIndex == -2: |
376 parent.wasPopulated = True |
370 parent.wasPopulated = True |
377 parent.currentCount = parent.absolutCount |
371 parent.currentCount = parent.absolutCount |
|
372 parent.populated = True |
378 # Remove items which are left over at the end of child list |
373 # Remove items which are left over at the end of child list |
379 self.__cleanupParentList(parent, parentIdx) |
374 self.__cleanupParentList(parent, parentIdx) |
380 return |
375 return |
381 |
376 |
382 elif itemStartIndex == -1: |
377 elif itemStartIndex == -1: |
383 parent.methodCount = len(vlist) |
378 parent.methodCount = len(vlist) |
384 idx = parent.childCount = parent.currentCount + 1 |
379 idx = max(parent.currentCount, 0) |
385 parent.currentCount += 1 + len(vlist) |
380 parent.currentCount = idx + len(vlist) |
386 else: |
381 parent.populated = True |
387 idx = parent.currentCount + 1 |
382 else: |
388 parent.currentCount += len(vlist) |
383 idx = itemStartIndex |
|
384 parent.currentCount = idx + len(vlist) |
389 |
385 |
390 # Sort items for Python versions where dict doesn't retain order |
386 # Sort items for Python versions where dict doesn't retain order |
391 vlist.sort(key=lambda x: x[0]) |
387 vlist.sort(key=lambda x: x[0]) |
392 # Now update the table |
388 # Now update the table |
393 endIndex = idx + len(vlist) |
389 endIndex = idx + len(vlist) |
430 child.value = newItem.value |
426 child.value = newItem.value |
431 child.valueShort = newItem.valueShort |
427 child.valueShort = newItem.valueShort |
432 child.tooltip = newItem.tooltip |
428 child.tooltip = newItem.tooltip |
433 |
429 |
434 child.currentCount = -1 |
430 child.currentCount = -1 |
|
431 child.populated = False |
435 child.childCount = newItem.childCount |
432 child.childCount = newItem.childCount |
436 |
433 |
437 # Highlight item because it has changed |
434 # Highlight item because it has changed |
438 parent.changedItems.add(child) |
435 parent.changedItems.add(child) |
439 |
436 |
502 for child in parent.children: |
499 for child in parent.children: |
503 if child.hasChildren and child.nameWithId in posPaths: |
500 if child.hasChildren and child.nameWithId in posPaths: |
504 if child.currentCount >= 0: |
501 if child.currentCount >= 0: |
505 # Discard loaded elements and refresh if still expanded |
502 # Discard loaded elements and refresh if still expanded |
506 child.currentCount = -1 |
503 child.currentCount = -1 |
|
504 child.populated = False |
507 row = parent.children.index(child) |
505 row = parent.children.index(child) |
508 newParentIdx = self.index(row, 0, parentIdx) |
506 newParentIdx = self.index(row, 0, parentIdx) |
509 self.resetModifiedMarker( |
507 self.resetModifiedMarker( |
510 newParentIdx, pathlist + (child.nameWithId,)) |
508 newParentIdx, pathlist + (child.nameWithId,)) |
511 |
509 |
512 self.closedItems = [] |
510 self.closedItems = [] |
513 |
511 |
514 # Little quirk: Refresh all visible items to clear the changed marker |
512 # Little quirk: Refresh all visible items to clear the changed marker |
515 if parentIdx == QModelIndex(): |
513 if parentIdx == QModelIndex(): |
516 self.rootNode.currentCount = -1 |
514 self.rootNode.currentCount = -1 |
|
515 self.rootNode.populated = False |
517 idxStart = self.index(0, 0, QModelIndex()) |
516 idxStart = self.index(0, 0, QModelIndex()) |
518 idxEnd = self.index(0, 2, QModelIndex()) |
517 idxEnd = self.index(0, 2, QModelIndex()) |
519 self.dataChanged.emit(idxStart, idxEnd) |
518 self.dataChanged.emit(idxStart, idxEnd) |
520 |
519 |
521 def columnCount(self, parent=QModelIndex()): |
520 def columnCount(self, parent=QModelIndex()): |