77 """ |
77 """ |
78 self.parent = parent |
78 self.parent = parent |
79 # Take the additional methods into account for childCount |
79 # Take the additional methods into account for childCount |
80 self.methodCount = 0 |
80 self.methodCount = 0 |
81 self.childCount = 0 |
81 self.childCount = 0 |
82 self.currentCount = -1 # -1 indicates to (re)load childs |
82 self.currentCount = -1 # -1 indicates to (re)load children |
83 # Indicator that there are childs |
83 # Indicator that there are children |
84 self.hasChilds = False |
84 self.hasChildren = False |
85 # Indicator that item was at least once fully populated |
85 # Indicator that item was at least once fully populated |
86 self.wasPopulated = False |
86 self.wasPopulated = False |
87 |
87 |
88 self.childs = [] |
88 self.children = [] |
89 # Flag to prevent endless reloading of current item while waiting on |
89 # Flag to prevent endless reloading of current item while waiting on |
90 # a response from debugger |
90 # a response from debugger |
91 self.pendigFetch = False |
91 self.pendigFetch = False |
92 |
92 |
93 # Set of childs items, which are displayed the first time or changed |
93 # Set of child items, which are displayed the first time or changed |
94 self.newItems = set() |
94 self.newItems = set() |
95 self.changedItems = set() |
95 self.changedItems = set() |
96 # Name including its ID if it's a dict, set, etc. |
96 # Name including its ID if it's a dict, set, etc. |
97 self.nameWithId = dvar |
97 self.nameWithId = dvar |
98 |
98 |
133 |
133 |
134 def __getType(self, dtype): |
134 def __getType(self, dtype): |
135 """ |
135 """ |
136 Private method to process the type of the variable. |
136 Private method to process the type of the variable. |
137 |
137 |
138 If type is known to have childs, the corresponding flag is set. |
138 If type is known to have children, the corresponding flag is set. |
|
139 |
139 @param dtype type string |
140 @param dtype type string |
140 @type str |
141 @type str |
141 """ |
142 """ |
142 # Python class? |
143 # Python class? |
143 if dtype.startswith('class '): |
144 if dtype.startswith('class '): |
144 dtype = dtype[7:-1] |
145 dtype = dtype[7:-1] |
145 # Qt related stuff? |
146 # Qt related stuff? |
146 elif (dtype.startswith(ConfigQtNames) and |
147 elif (dtype.startswith(ConfigQtNames) and |
147 dtype.endswith(ConfigKnownQtTypes)): |
148 dtype.endswith(ConfigKnownQtTypes)): |
148 self.hasChilds = True |
149 self.hasChildren = True |
149 |
150 |
150 elif dtype in ('instance', 'class'): |
151 elif dtype in ('instance', 'class'): |
151 self.hasChilds = True |
152 self.hasChildren = True |
152 |
153 |
153 vtype = ConfigVarTypeDispStrings.get(dtype, dtype) |
154 vtype = ConfigVarTypeDispStrings.get(dtype, dtype) |
154 # Unkown types should be expandable by default |
155 # Unkown types should be expandable by default |
155 if vtype is dtype and dtype not in self.nonExpandableTypes: |
156 if vtype is dtype and dtype not in self.nonExpandableTypes: |
156 self.hasChilds = True |
157 self.hasChildren = True |
157 self.type = QCoreApplication.translate("VariablesViewer", vtype) |
158 self.type = QCoreApplication.translate("VariablesViewer", vtype) |
158 |
159 |
159 def __getValue(self, dtype, dvalue): |
160 def __getValue(self, dtype, dvalue): |
160 """ |
161 """ |
161 Private method to process the variables value. |
162 Private method to process the variables value. |
162 |
163 |
163 Define and limit value, set tooltip text. |
164 Define and limit value, set tooltip text. If type is known to have |
164 If type is known to have childs, the corresponding flag is set. |
165 children, the corresponding flag is set. |
|
166 |
165 @param dtype type string |
167 @param dtype type string |
166 @type str |
168 @type str |
167 @param dvalue value of variable encoded as utf-8 |
169 @param dvalue value of variable encoded as utf-8 |
168 @type str |
170 @type str |
169 """ |
171 """ |
177 self.indicator = VariableItem.Type2Indicators.get(dtype, '') |
179 self.indicator = VariableItem.Type2Indicators.get(dtype, '') |
178 |
180 |
179 if dtype == 'numpy.ndarray': |
181 if dtype == 'numpy.ndarray': |
180 self.childCount = int(dvalue.split('x')[0]) |
182 self.childCount = int(dvalue.split('x')[0]) |
181 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
183 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
182 self.hasChilds = True |
184 self.hasChildren = True |
183 elif dtype in VariableItem.arrayTypes: |
185 elif dtype in VariableItem.arrayTypes: |
184 self.childCount = int(dvalue) |
186 self.childCount = int(dvalue) |
185 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
187 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
186 self.hasChilds = True |
188 self.hasChildren = True |
187 |
189 |
188 elif dtype == "Shiboken.EnumType": |
190 elif dtype == "Shiboken.EnumType": |
189 self.hasChilds = True |
191 self.hasChildren = True |
190 |
192 |
191 elif dtype in ['str', 'unicode']: |
193 elif dtype in ['str', 'unicode']: |
192 if VariableItem.rx_nonprintable.indexIn(dvalue) == -1: |
194 if VariableItem.rx_nonprintable.indexIn(dvalue) == -1: |
193 try: |
195 try: |
194 dvalue = ast.literal_eval(dvalue) |
196 dvalue = ast.literal_eval(dvalue) |
289 |
291 |
290 @param reset flag to clear the expanded keys also |
292 @param reset flag to clear the expanded keys also |
291 @type bool |
293 @type bool |
292 """ |
294 """ |
293 self.beginResetModel() |
295 self.beginResetModel() |
294 self.rootNode.childs = [] |
296 self.rootNode.children = [] |
295 self.rootNode.newItems.clear() |
297 self.rootNode.newItems.clear() |
296 self.rootNode.changedItems.clear() |
298 self.rootNode.changedItems.clear() |
297 self.rootNode.wasPopulated = False |
299 self.rootNode.wasPopulated = False |
298 if reset: |
300 if reset: |
299 self.openItems = [] |
301 self.openItems = [] |
354 |
356 |
355 if parent == self.rootNode: |
357 if parent == self.rootNode: |
356 parentIdx = QModelIndex() |
358 parentIdx = QModelIndex() |
357 parent.methodCount = len(vlist) |
359 parent.methodCount = len(vlist) |
358 else: |
360 else: |
359 row = parent.parent.childs.index(parent) |
361 row = parent.parent.children.index(parent) |
360 parentIdx = self.createIndex(row, 0, parent) |
362 parentIdx = self.createIndex(row, 0, parent) |
361 |
363 |
362 if itemStartIndex == -3: |
364 if itemStartIndex == -3: |
363 # Item doesn't exist any more |
365 # Item doesn't exist any more |
364 parentIdx = self.parent(parentIdx) |
366 parentIdx = self.parent(parentIdx) |
365 self.beginRemoveRows(parentIdx, row, row) |
367 self.beginRemoveRows(parentIdx, row, row) |
366 del parent.parent.childs[row] |
368 del parent.parent.children[row] |
367 self.endRemoveRows() |
369 self.endRemoveRows() |
368 parent.parent.childCount -= 1 |
370 parent.parent.childCount -= 1 |
369 return |
371 return |
370 |
372 |
371 elif itemStartIndex == -2: |
373 elif itemStartIndex == -2: |
386 # Sort items for Python versions where dict doesn't retain order |
388 # Sort items for Python versions where dict doesn't retain order |
387 vlist.sort(key=lambda x: x[0]) |
389 vlist.sort(key=lambda x: x[0]) |
388 # Now update the table |
390 # Now update the table |
389 endIndex = idx + len(vlist) |
391 endIndex = idx + len(vlist) |
390 newChild = None |
392 newChild = None |
391 knownChildsCount = len(parent.childs) |
393 knownChildrenCount = len(parent.children) |
392 while idx < endIndex: |
394 while idx < endIndex: |
393 # Fetch next old item from last cycle |
395 # Fetch next old item from last cycle |
394 try: |
396 try: |
395 child = parent.childs[idx] |
397 child = parent.children[idx] |
396 except IndexError: |
398 except IndexError: |
397 child = None |
399 child = None |
398 |
400 |
399 # Fetch possible new item |
401 # Fetch possible new item |
400 if not newChild and vlist: |
402 if not newChild and vlist: |
405 sort = newItem.sort |
407 sort = newItem.sort |
406 |
408 |
407 # Append or insert before already existing item |
409 # Append or insert before already existing item |
408 if child is None or newChild and sort < child.sort: |
410 if child is None or newChild and sort < child.sort: |
409 self.beginInsertRows(parentIdx, idx, idx) |
411 self.beginInsertRows(parentIdx, idx, idx) |
410 parent.childs.insert(idx, newItem) |
412 parent.children.insert(idx, newItem) |
411 if knownChildsCount <= idx and not parent.wasPopulated: |
413 if knownChildrenCount <= idx and not parent.wasPopulated: |
412 parent.newItems.add(newItem) |
414 parent.newItems.add(newItem) |
413 knownChildsCount += 1 |
415 knownChildrenCount += 1 |
414 else: |
416 else: |
415 parent.changedItems.add(newItem) |
417 parent.changedItems.add(newItem) |
416 self.endInsertRows() |
418 self.endInsertRows() |
417 |
419 |
418 idx += 1 |
420 idx += 1 |
441 idx += 1 |
443 idx += 1 |
442 continue |
444 continue |
443 |
445 |
444 # Remove obsolete item |
446 # Remove obsolete item |
445 self.beginRemoveRows(parentIdx, idx, idx) |
447 self.beginRemoveRows(parentIdx, idx, idx) |
446 parent.childs.remove(child) |
448 parent.children.remove(child) |
447 self.endRemoveRows() |
449 self.endRemoveRows() |
448 # idx stay unchanged |
450 # idx stay unchanged |
449 knownChildsCount -= 1 |
451 knownChildrenCount -= 1 |
450 |
452 |
451 # Remove items which are left over at the end of child list |
453 # Remove items which are left over at the end of child list |
452 if itemStartIndex == -1: |
454 if itemStartIndex == -1: |
453 parent.wasPopulated = True |
455 parent.wasPopulated = True |
454 self.__cleanupParentList(parent, parentIdx) |
456 self.__cleanupParentList(parent, parentIdx) |
464 @param parent to clean up |
466 @param parent to clean up |
465 @type VariableItem |
467 @type VariableItem |
466 @param parentIdx the parent index as QModelIndex |
468 @param parentIdx the parent index as QModelIndex |
467 @type QModelIndex |
469 @type QModelIndex |
468 """ |
470 """ |
469 end = len(parent.childs) |
471 end = len(parent.children) |
470 if end > parent.absolutCount: |
472 if end > parent.absolutCount: |
471 self.beginRemoveRows(parentIdx, parent.absolutCount, end) |
473 self.beginRemoveRows(parentIdx, parent.absolutCount, end) |
472 del parent.childs[parent.absolutCount:] |
474 del parent.children[parent.absolutCount:] |
473 self.endRemoveRows() |
475 self.endRemoveRows() |
474 |
476 |
475 def resetModifiedMarker(self, parentIdx=QModelIndex(), pathlist=()): |
477 def resetModifiedMarker(self, parentIdx=QModelIndex(), pathlist=()): |
476 """ |
478 """ |
477 Public method to remove the modified marker from changed items. |
479 Public method to remove the modified marker from changed items. |
493 posPaths = {x for x in self.openItems if len(x) > pll} |
495 posPaths = {x for x in self.openItems if len(x) > pll} |
494 posPaths |= {x for x in self.closedItems if len(x) > pll} |
496 posPaths |= {x for x in self.closedItems if len(x) > pll} |
495 posPaths = {x[pll] for x in posPaths if x[:pll] == pathlist} |
497 posPaths = {x[pll] for x in posPaths if x[:pll] == pathlist} |
496 |
498 |
497 if posPaths: |
499 if posPaths: |
498 for child in parent.childs: |
500 for child in parent.children: |
499 if child.hasChilds and child.nameWithId in posPaths: |
501 if child.hasChildren and child.nameWithId in posPaths: |
500 if child.currentCount >= 0: |
502 if child.currentCount >= 0: |
501 # Discard loaded elements and refresh if still expanded |
503 # Discard loaded elements and refresh if still expanded |
502 child.currentCount = -1 |
504 child.currentCount = -1 |
503 row = parent.childs.index(child) |
505 row = parent.children.index(child) |
504 newParentIdx = self.index(row, 0, parentIdx) |
506 newParentIdx = self.index(row, 0, parentIdx) |
505 self.resetModifiedMarker( |
507 self.resetModifiedMarker( |
506 newParentIdx, pathlist + (child.nameWithId,)) |
508 newParentIdx, pathlist + (child.nameWithId,)) |
507 |
509 |
508 self.closedItems = [] |
510 self.closedItems = [] |
514 idxEnd = self.index(0, 2, QModelIndex()) |
516 idxEnd = self.index(0, 2, QModelIndex()) |
515 self.dataChanged.emit(idxStart, idxEnd) |
517 self.dataChanged.emit(idxStart, idxEnd) |
516 |
518 |
517 def columnCount(self, parent=QModelIndex()): |
519 def columnCount(self, parent=QModelIndex()): |
518 """ |
520 """ |
519 Public Qt slot to get the column count. |
521 Public method to get the column count. |
520 |
522 |
521 @param parent the model parent |
523 @param parent the model parent |
522 @type QModelIndex |
524 @type QModelIndex |
523 @return number of columns |
525 @return number of columns |
524 @rtype int |
526 @rtype int |
525 """ |
527 """ |
526 return 3 |
528 return 3 |
527 |
529 |
528 def rowCount(self, parent=QModelIndex()): |
530 def rowCount(self, parent=QModelIndex()): |
529 """ |
531 """ |
530 Public Qt slot to get the row count. |
532 Public method to get the row count. |
531 |
533 |
532 @param parent the model parent |
534 @param parent the model parent |
533 @type QModelIndex |
535 @type QModelIndex |
534 @return number of rows |
536 @return number of rows |
535 @rtype int |
537 @rtype int |
555 |
557 |
556 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
558 return Qt.ItemIsEnabled | Qt.ItemIsSelectable |
557 |
559 |
558 def hasChildren(self, parent=QModelIndex()): |
560 def hasChildren(self, parent=QModelIndex()): |
559 """ |
561 """ |
560 Public Qt slot to get a flag if parent has childs. |
562 Public method to get a flag if parent has children. |
561 |
563 |
562 @param parent the model parent |
564 @param parent the model parent |
563 @type QModelIndex |
565 @type QModelIndex |
564 @return flag if parent has childs |
566 @return flag indicating parent has children |
565 @rtype bool |
567 @rtype bool |
566 """ |
568 """ |
567 if not parent.isValid(): |
569 if not parent.isValid(): |
568 return self.rootNode.childs != [] |
570 return self.rootNode.children != [] |
569 |
571 |
570 return parent.internalPointer().hasChilds |
572 return parent.internalPointer().hasChildren |
571 |
573 |
572 def index(self, row, column, parent=QModelIndex()): |
574 def index(self, row, column, parent=QModelIndex()): |
573 """ |
575 """ |
574 Public Qt slot to get the index of item at row:column of parent. |
576 Public method to get the index of item at row:column of parent. |
575 |
577 |
576 @param row number of rows |
578 @param row number of rows |
577 @type int |
579 @type int |
578 @param column number of columns |
580 @param column number of columns |
579 @type int |
581 @type int |
588 if not parent.isValid(): |
590 if not parent.isValid(): |
589 node = self.rootNode |
591 node = self.rootNode |
590 else: |
592 else: |
591 node = parent.internalPointer() |
593 node = parent.internalPointer() |
592 |
594 |
593 return self.createIndex(row, column, node.childs[row]) |
595 return self.createIndex(row, column, node.children[row]) |
594 |
596 |
595 def parent(self, child): |
597 def parent(self, child): |
596 """ |
598 """ |
597 Public Qt slot to get the parent of the given child. |
599 Public method to get the parent of the given child. |
598 |
600 |
599 @param child the model child node |
601 @param child the model child node |
600 @type QModelIndex |
602 @type QModelIndex |
601 @return new model index for parent |
603 @return new model index for parent |
602 @rtype QModelIndex |
604 @rtype QModelIndex |
611 parentNode = childNode.parent |
613 parentNode = childNode.parent |
612 |
614 |
613 if parentNode == self.rootNode: |
615 if parentNode == self.rootNode: |
614 return QModelIndex() |
616 return QModelIndex() |
615 |
617 |
616 row = parentNode.parent.childs.index(parentNode) |
618 row = parentNode.parent.children.index(parentNode) |
617 return self.createIndex(row, 0, parentNode) |
619 return self.createIndex(row, 0, parentNode) |
618 |
620 |
619 def data(self, index, role=Qt.DisplayRole): |
621 def data(self, index, role=Qt.DisplayRole): |
620 """ |
622 """ |
621 Public Qt slot get the role data of item. |
623 Public method get the role data of item. |
622 |
624 |
623 @param index the model index |
625 @param index the model index |
624 @type QModelIndex |
626 @type QModelIndex |
625 @param role the requested data role |
627 @param role the requested data role |
626 @type QtCore.Qt.ItemDataRole |
628 @type QtCore.Qt.ItemDataRole |
695 |
697 |
696 return None |
698 return None |
697 |
699 |
698 def headerData(self, section, orientation, role=Qt.DisplayRole): |
700 def headerData(self, section, orientation, role=Qt.DisplayRole): |
699 """ |
701 """ |
700 Public Qt slot get the header names. |
702 Public method get the header names. |
701 |
703 |
702 @param section the header section (row/coulumn) |
704 @param section the header section (row/coulumn) |
703 @type int |
705 @type int |
704 @param orientation the header's orientation |
706 @param orientation the header's orientation |
705 @type QtCore.Qt.Orientation |
707 @type QtCore.Qt.Orientation |
734 @rtype QModelIndex |
736 @rtype QModelIndex |
735 """ |
737 """ |
736 if parent is None: |
738 if parent is None: |
737 parent = self.rootNode |
739 parent = self.rootNode |
738 |
740 |
739 for child in parent.childs: |
741 for child in parent.children: |
740 if not child.hasChilds: |
742 if not child.hasChildren: |
741 continue |
743 continue |
742 |
744 |
743 if pathlist + (child.nameWithId,) in self.openItems: |
745 if pathlist + (child.nameWithId,) in self.openItems: |
744 if child.populated: |
746 if child.populated: |
745 index = None |
747 index = None |
746 else: |
748 else: |
747 idx = parent.childs.index(child) |
749 idx = parent.children.index(child) |
748 index = self.createIndex(idx, 0, child) |
750 index = self.createIndex(idx, 0, child) |
749 self.expand.emit(index) |
751 self.expand.emit(index) |
750 |
752 |
751 if child.currentCount < 0: |
753 if child.currentCount < 0: |
752 return index |
754 return index |
838 idxStart = self.index(0, 0, QModelIndex()) |
840 idxStart = self.index(0, 0, QModelIndex()) |
839 idxEnd = self.index(0, 2, QModelIndex()) |
841 idxEnd = self.index(0, 2, QModelIndex()) |
840 self.dataChanged.emit(idxStart, idxEnd) |
842 self.dataChanged.emit(idxStart, idxEnd) |
841 |
843 |
842 |
844 |
843 class ProxyModel(QSortFilterProxyModel): |
845 class VariablesProxyModel(QSortFilterProxyModel): |
844 """ |
846 """ |
845 Class for handling the sort operations. |
847 Class for handling the sort operations. |
846 """ |
848 """ |
847 def __init__(self, parent=None): |
849 def __init__(self, parent=None): |
848 """ |
850 """ |
849 Constructor |
851 Constructor |
850 |
852 |
851 @param parent the parent model index |
853 @param parent the parent model index |
852 @type QModelIndex |
854 @type QModelIndex |
853 """ |
855 """ |
854 super(ProxyModel, self).__init__(parent) |
856 super(VariablesProxyModel, self).__init__(parent) |
855 self.setSortRole(SORT_ROLE) |
857 self.setSortRole(SORT_ROLE) |
856 |
858 |
857 def hasChildren(self, parent): |
859 def hasChildren(self, parent): |
858 """ |
860 """ |
859 Public Qt slot to get a flag if parent has childs. |
861 Public method to get a flag if parent has children. |
860 |
862 |
861 The given model index has to be transformed to the underlying source |
863 The given model index has to be transformed to the underlying source |
862 model to get the correct result. |
864 model to get the correct result. |
|
865 |
863 @param parent the model parent |
866 @param parent the model parent |
864 @type QModelIndex |
867 @type QModelIndex |
865 @return flag if parent has childs |
868 @return flag if parent has children |
866 @rtype bool |
869 @rtype bool |
867 """ |
870 """ |
868 return self.sourceModel().hasChildren(self.mapToSource(parent)) |
871 return self.sourceModel().hasChildren(self.mapToSource(parent)) |
869 |
872 |
870 def setExpanded(self, index, state): |
873 def setExpanded(self, index, state): |
871 """ |
874 """ |
872 Public Qt slot to get a flag if parent has childs. |
875 Public slot to get a flag if parent has children. |
873 |
876 |
874 The given model index has to be transformed to the underlying source |
877 The given model index has to be transformed to the underlying source |
875 model to get the correct result. |
878 model to get the correct result. |
876 @param index item to change expanded state |
879 @param index item to change expanded state |
877 @type QModelIndex |
880 @type QModelIndex |
887 |
890 |
888 This view is used to display the variables of the program being |
891 This view is used to display the variables of the program being |
889 debugged in a tree. Compound types will be shown with |
892 debugged in a tree. Compound types will be shown with |
890 their main entry first. Once the subtree has been expanded, the |
893 their main entry first. Once the subtree has been expanded, the |
891 individual entries will be shown. Double clicking an entry will |
894 individual entries will be shown. Double clicking an entry will |
892 expand or collapse the item, if it has childs and the double click |
895 expand or collapse the item, if it has children and the double click |
893 was performed on the first column of the tree, otherwise it'll |
896 was performed on the first column of the tree, otherwise it'll |
894 popup a dialog showing the variables parameters in a more readable |
897 popup a dialog showing the variables parameters in a more readable |
895 form. This is especially useful for lengthy strings. |
898 form. This is especially useful for lengthy strings. |
896 |
899 |
897 This view has two modes for displaying the global and the local |
900 This view has two modes for displaying the global and the local |
921 |
924 |
922 # Massive performance gain |
925 # Massive performance gain |
923 self.setUniformRowHeights(True) |
926 self.setUniformRowHeights(True) |
924 |
927 |
925 # Implements sorting and filtering |
928 # Implements sorting and filtering |
926 self.proxyModel = ProxyModel() |
929 self.proxyModel = VariablesProxyModel() |
927 # Variable model implements the underlying data model |
930 # Variable model implements the underlying data model |
928 self.varModel = VariableModel(self, globalScope) |
931 self.varModel = VariablesModel(self, globalScope) |
929 self.preferencesChanged.connect(self.varModel.handlePreferencesChanged) |
932 self.preferencesChanged.connect(self.varModel.handlePreferencesChanged) |
930 self.preferencesChanged.emit() # Force initialization of colors |
933 self.preferencesChanged.emit() # Force initialization of colors |
931 self.proxyModel.setSourceModel(self.varModel) |
934 self.proxyModel.setSourceModel(self.varModel) |
932 self.setModel(self.proxyModel) |
935 self.setModel(self.proxyModel) |
933 |
936 |
984 def showVariables(self, vlist, frmnr): |
987 def showVariables(self, vlist, frmnr): |
985 """ |
988 """ |
986 Public method to show variables in a list. |
989 Public method to show variables in a list. |
987 |
990 |
988 @param vlist the list of variables to be displayed. Each |
991 @param vlist the list of variables to be displayed. Each |
989 listentry is a tuple of three values. |
992 list entry is a tuple of three values. |
990 <ul> |
993 <ul> |
991 <li>the variable name (string)</li> |
994 <li>the variable name (string)</li> |
992 <li>the variables type (string)</li> |
995 <li>the variables type (string)</li> |
993 <li>the variables value (string)</li> |
996 <li>the variables value (string)</li> |
994 </ul> |
997 </ul> |
1003 """ |
1006 """ |
1004 Public method to show variables in a list. |
1007 Public method to show variables in a list. |
1005 |
1008 |
1006 @param vlist the list of subitems to be displayed. |
1009 @param vlist the list of subitems to be displayed. |
1007 The first element gives the path of the |
1010 The first element gives the path of the |
1008 parent variable. Each other listentry is |
1011 parent variable. Each other list entry is |
1009 a tuple of three values. |
1012 a tuple of three values. |
1010 <ul> |
1013 <ul> |
1011 <li>the variable name (string)</li> |
1014 <li>the variable name (string)</li> |
1012 <li>the variables type (string)</li> |
1015 <li>the variables type (string)</li> |
1013 <li>the variables value (string)</li> |
1016 <li>the variables value (string)</li> |
1022 """ |
1025 """ |
1023 self.varModel.clear(True) |
1026 self.varModel.clear(True) |
1024 |
1027 |
1025 def verticalScrollbarValueChanged(self, value): |
1028 def verticalScrollbarValueChanged(self, value): |
1026 """ |
1029 """ |
1027 Public Qt slot informing about the scrollbar change. |
1030 Public slot informing about the scrollbar change. |
1028 |
1031 |
1029 @param value current value of the vertical scrollbar |
1032 @param value current value of the vertical scrollbar |
1030 @type int |
1033 @type int |
1031 """ |
1034 """ |
1032 self.varModel.getMore() |
1035 self.varModel.getMore() |
1033 super(VariablesViewer, self).verticalScrollbarValueChanged(value) |
1036 super(VariablesViewer, self).verticalScrollbarValueChanged(value) |
1034 |
1037 |
1035 def resizeEvent(self, event): |
1038 def resizeEvent(self, event): |
1036 """ |
1039 """ |
1037 Protected Qt slot informing about the widget size change. |
1040 Protected slot informing about the widget size change. |
1038 |
1041 |
1039 @param event information |
1042 @param event information |
1040 @type QResizeEvent |
1043 @type QResizeEvent |
1041 """ |
1044 """ |
1042 self.varModel.getMore() |
1045 self.varModel.getMore() |
1048 |
1051 |
1049 @param index the double clicked item |
1052 @param index the double clicked item |
1050 @type QModelIndex |
1053 @type QModelIndex |
1051 """ |
1054 """ |
1052 node = self.proxyModel.mapToSource(index).internalPointer() |
1055 node = self.proxyModel.mapToSource(index).internalPointer() |
1053 if node.hasChilds and index.column() == 0: |
1056 if node.hasChildren and index.column() == 0: |
1054 state = self.isExpanded(index) |
1057 state = self.isExpanded(index) |
1055 self.setExpanded(index, not state) |
1058 self.setExpanded(index, not state) |
1056 else: |
1059 else: |
1057 self.__showVariableDetails(index) |
1060 self.__showVariableDetails(index) |
1058 |
1061 |
1071 Private method to generate the popup menus. |
1074 Private method to generate the popup menus. |
1072 """ |
1075 """ |
1073 self.menu = QMenu() |
1076 self.menu = QMenu() |
1074 self.menu.addAction(self.tr("Show Details..."), self.__showDetails) |
1077 self.menu.addAction(self.tr("Show Details..."), self.__showDetails) |
1075 self.menu.addSeparator() |
1078 self.menu.addSeparator() |
1076 self.menu.addAction(self.tr("Expand childs"), self.__expandChilds) |
1079 self.menu.addAction(self.tr("Expand"), self.__expandChildren) |
1077 self.menu.addAction(self.tr("Collapse childs"), self.__collapseChilds) |
1080 self.menu.addAction(self.tr("Collapse"), self.__collapseChildren) |
1078 self.menu.addAction(self.tr("Collapse all"), self.collapseAll) |
1081 self.menu.addAction(self.tr("Collapse All"), self.collapseAll) |
1079 self.menu.addSeparator() |
1082 self.menu.addSeparator() |
1080 self.menu.addAction(self.tr("Refresh"), self.__refreshView) |
1083 self.menu.addAction(self.tr("Refresh"), self.__refreshView) |
1081 self.menu.addSeparator() |
1084 self.menu.addSeparator() |
1082 self.menu.addAction(self.tr("Configure..."), self.__configure) |
1085 self.menu.addAction(self.tr("Configure..."), self.__configure) |
1083 self.menu.addAction( |
1086 self.menu.addAction(self.tr("Variables Type Filter..."), |
1084 QCoreApplication.translate('DebugUI', 'Varia&bles Type Filter...'), |
1087 self.__configureFilter) |
1085 self.__configureFilter) |
|
1086 |
1088 |
1087 self.backMenu = QMenu() |
1089 self.backMenu = QMenu() |
1088 self.backMenu.addAction(self.tr("Refresh"), self.__refreshView) |
1090 self.backMenu.addAction(self.tr("Refresh"), self.__refreshView) |
1089 self.backMenu.addSeparator() |
1091 self.backMenu.addSeparator() |
1090 self.backMenu.addAction(self.tr("Configure..."), self.__configure) |
1092 self.backMenu.addAction(self.tr("Configure..."), self.__configure) |
1091 self.backMenu.addAction( |
1093 self.backMenu.addAction(self.tr("Variables Type Filter..."), |
1092 QCoreApplication.translate('DebugUI', 'Varia&bles Type Filter...'), |
1094 self.__configureFilter) |
1093 self.__configureFilter) |
|
1094 |
1095 |
1095 def __showContextMenu(self, coord): |
1096 def __showContextMenu(self, coord): |
1096 """ |
1097 """ |
1097 Private slot to show the context menu. |
1098 Private slot to show the context menu. |
1098 |
1099 |
1103 if self.indexAt(coord).isValid(): |
1104 if self.indexAt(coord).isValid(): |
1104 self.menu.popup(gcoord) |
1105 self.menu.popup(gcoord) |
1105 else: |
1106 else: |
1106 self.backMenu.popup(gcoord) |
1107 self.backMenu.popup(gcoord) |
1107 |
1108 |
1108 def __expandChilds(self): |
1109 def __expandChildren(self): |
1109 """ |
1110 """ |
1110 Private slot to expand all childs of current parent. |
1111 Private slot to expand all child items of current parent. |
1111 """ |
1112 """ |
1112 index = self.currentIndex() |
1113 index = self.currentIndex() |
1113 node = self.proxyModel.mapToSource(index).internalPointer() |
1114 node = self.proxyModel.mapToSource(index).internalPointer() |
1114 for child in node.childs: |
1115 for child in node.children: |
1115 if child.hasChilds: |
1116 if child.hasChildren: |
1116 row = node.childs.index(child) |
1117 row = node.children.index(child) |
1117 idx = self.varModel.createIndex(row, 0, child) |
1118 idx = self.varModel.createIndex(row, 0, child) |
1118 idx = self.proxyModel.mapFromSource(idx) |
1119 idx = self.proxyModel.mapFromSource(idx) |
1119 self.expand(idx) |
1120 self.expand(idx) |
1120 |
1121 |
1121 def __collapseChilds(self): |
1122 def __collapseChildren(self): |
1122 """ |
1123 """ |
1123 Private slot to collapse all childs of current parent. |
1124 Private slot to collapse all child items of current parent. |
1124 """ |
1125 """ |
1125 index = self.currentIndex() |
1126 index = self.currentIndex() |
1126 node = self.proxyModel.mapToSource(index).internalPointer() |
1127 node = self.proxyModel.mapToSource(index).internalPointer() |
1127 for child in node.childs: |
1128 for child in node.children: |
1128 row = node.childs.index(child) |
1129 row = node.children.index(child) |
1129 idx = self.varModel.createIndex(row, 0, child) |
1130 idx = self.varModel.createIndex(row, 0, child) |
1130 idx = self.proxyModel.mapFromSource(idx) |
1131 idx = self.proxyModel.mapFromSource(idx) |
1131 if self.isExpanded(idx): |
1132 if self.isExpanded(idx): |
1132 self.collapse(idx) |
1133 self.collapse(idx) |
1133 |
1134 |