73 self.methodCount = 0 |
73 self.methodCount = 0 |
74 self.childCount = 0 |
74 self.childCount = 0 |
75 self.currentCount = -1 # -1 indicates to (re)load childs |
75 self.currentCount = -1 # -1 indicates to (re)load childs |
76 # Indicator that there are childs |
76 # Indicator that there are childs |
77 self.hasChilds = False |
77 self.hasChilds = False |
|
78 # Indicator that item was at least once fully populated |
|
79 self.wasPopulated = False |
78 |
80 |
79 self.childs = [] |
81 self.childs = [] |
80 # Flag to prevent endless reloading of current item while waiting on |
82 # Flag to prevent endless reloading of current item while waiting on |
81 # a response from debugger |
83 # a response from debugger |
82 self.pendigFetch = False |
84 self.pendigFetch = False |
83 |
85 |
84 # Set of childs items, which are displayed the first time or changed |
86 # Set of childs items, which are displayed the first time or changed |
85 self.newItems = set() |
87 self.newItems = set() |
|
88 self.changedItems = set() |
86 # Name including its ID if it's a dict, set, etc. |
89 # Name including its ID if it's a dict, set, etc. |
87 self.nameWithId = dvar |
90 self.nameWithId = dvar |
88 |
91 |
89 self.name = '' |
92 self.name = '' |
90 self.sort = '' |
93 self.sort = '' |
358 self.endRemoveRows() |
363 self.endRemoveRows() |
359 parent.parent.childCount -= 1 |
364 parent.parent.childCount -= 1 |
360 return |
365 return |
361 |
366 |
362 elif itemStartIndex == -2: |
367 elif itemStartIndex == -2: |
|
368 parent.wasPopulated = True |
363 parent.currentCount = parent.absolutCount |
369 parent.currentCount = parent.absolutCount |
364 # Remove items which are left over at the end of child list |
370 # Remove items which are left over at the end of child list |
365 self.__cleanupParentList(parent, parentIdx) |
371 self.__cleanupParentList(parent, parentIdx) |
366 return |
372 return |
367 |
373 |
376 # Sort items for Python versions where dict doesn't retain order |
382 # Sort items for Python versions where dict doesn't retain order |
377 vlist.sort(key=lambda x: x[0]) |
383 vlist.sort(key=lambda x: x[0]) |
378 # Now update the table |
384 # Now update the table |
379 endIndex = idx + len(vlist) |
385 endIndex = idx + len(vlist) |
380 newChild = None |
386 newChild = None |
|
387 knownChildsCount = len(parent.childs) |
381 while idx < endIndex: |
388 while idx < endIndex: |
382 # Fetch next old item from last cycle |
389 # Fetch next old item from last cycle |
383 try: |
390 try: |
384 child = parent.childs[idx] |
391 child = parent.childs[idx] |
385 except IndexError: |
392 except IndexError: |
395 |
402 |
396 # Append or insert before already existing item |
403 # Append or insert before already existing item |
397 if child is None or newChild and sort < child.sort: |
404 if child is None or newChild and sort < child.sort: |
398 self.beginInsertRows(parentIdx, idx, idx) |
405 self.beginInsertRows(parentIdx, idx, idx) |
399 parent.childs.insert(idx, newItem) |
406 parent.childs.insert(idx, newItem) |
400 parent.newItems.add(newItem) |
407 if knownChildsCount <= idx and not parent.wasPopulated: |
|
408 parent.newItems.add(newItem) |
|
409 knownChildsCount += 1 |
|
410 else: |
|
411 parent.changedItems.add(newItem) |
401 self.endInsertRows() |
412 self.endInsertRows() |
|
413 |
402 idx += 1 |
414 idx += 1 |
403 newChild = None |
415 newChild = None |
404 continue |
416 continue |
405 |
417 |
406 # Check if same name, type and afterwards value |
418 # Check if same name, type and afterwards value |
413 |
425 |
414 child.currentCount = -1 |
426 child.currentCount = -1 |
415 child.childCount = newItem.childCount |
427 child.childCount = newItem.childCount |
416 |
428 |
417 # Highlight item because it has changed |
429 # Highlight item because it has changed |
418 parent.newItems.add(child) |
430 parent.changedItems.add(child) |
419 |
431 |
420 changedIndexStart = self.index(idx, 0, parentIdx) |
432 changedIndexStart = self.index(idx, 0, parentIdx) |
421 changedIndexEnd = self.index(idx, 2, parentIdx) |
433 changedIndexEnd = self.index(idx, 2, parentIdx) |
422 self.dataChanged.emit(changedIndexStart, changedIndexEnd) |
434 self.dataChanged.emit(changedIndexStart, changedIndexEnd) |
423 |
435 |
428 # Remove obsolete item |
440 # Remove obsolete item |
429 self.beginRemoveRows(parentIdx, idx, idx) |
441 self.beginRemoveRows(parentIdx, idx, idx) |
430 parent.childs.remove(child) |
442 parent.childs.remove(child) |
431 self.endRemoveRows() |
443 self.endRemoveRows() |
432 # idx stay unchanged |
444 # idx stay unchanged |
|
445 knownChildsCount -= 1 |
433 |
446 |
434 # Remove items which are left over at the end of child list |
447 # Remove items which are left over at the end of child list |
435 if itemStartIndex == -1: |
448 if itemStartIndex == -1: |
|
449 parent.wasPopulated = True |
436 self.__cleanupParentList(parent, parentIdx) |
450 self.__cleanupParentList(parent, parentIdx) |
437 |
451 |
438 # Request data for any expanded node |
452 # Request data for any expanded node |
439 self.getMore() |
453 self.getMore() |
440 |
454 |
466 if parentIdx.isValid(): |
480 if parentIdx.isValid(): |
467 parent = parentIdx.internalPointer() |
481 parent = parentIdx.internalPointer() |
468 else: |
482 else: |
469 parent = self.rootNode |
483 parent = self.rootNode |
470 |
484 |
471 if parent.newItems: |
485 parent.newItems.clear() |
472 parent.newItems.clear() |
486 parent.changedItems.clear() |
473 |
487 |
474 pll = len(pathlist) |
488 pll = len(pathlist) |
475 posPaths = {x for x in self.openItems if len(x) > pll} |
489 posPaths = {x for x in self.openItems if len(x) > pll} |
476 posPaths |= {x for x in self.closedItems if len(x) > pll} |
490 posPaths |= {x for x in self.closedItems if len(x) > pll} |
477 posPaths = {x[pll] for x in posPaths if x[:pll] == pathlist} |
491 posPaths = {x[pll] for x in posPaths if x[:pll] == pathlist} |
632 return None |
646 return None |
633 except AttributeError: |
647 except AttributeError: |
634 return ['None', '', '', ''][column] |
648 return ['None', '', '', ''][column] |
635 |
649 |
636 elif role == Qt.BackgroundRole: |
650 elif role == Qt.BackgroundRole: |
637 if node in node.parent.newItems: |
651 if node in node.parent.changedItems: |
638 color = QColor('#70FF66') |
652 color = QColor('#70FF66') |
|
653 # Set Alpha chanel to get alternating row colors done by Qt |
|
654 color.setAlpha(40) |
|
655 return QBrush(color) |
|
656 elif node in node.parent.newItems: |
|
657 color = QColor('#FFEEAA') |
639 # Set Alpha chanel to get alternating row colors done by Qt |
658 # Set Alpha chanel to get alternating row colors done by Qt |
640 color.setAlpha(40) |
659 color.setAlpha(40) |
641 return QBrush(color) |
660 return QBrush(color) |
642 |
661 |
643 elif role == Qt.ToolTipRole: |
662 elif role == Qt.ToolTipRole: |