src/eric7/Debugger/VariablesViewer.py

branch
eric7
changeset 10703
120b22aaec31
parent 10683
779cda568acb
child 10928
46651e194fbe
equal deleted inserted replaced
10702:b0d4e74b8f55 10703:120b22aaec31
1029 1029
1030 @param index the double clicked item 1030 @param index the double clicked item
1031 @type QModelIndex 1031 @type QModelIndex
1032 """ 1032 """
1033 node = self.proxyModel.mapToSource(index).internalPointer() 1033 node = self.proxyModel.mapToSource(index).internalPointer()
1034 if node.hasChildren and index.column() == 0: 1034 if node:
1035 state = self.isExpanded(index) 1035 if node.hasChildren and index.column() == 0:
1036 self.setExpanded(index, not state) 1036 state = self.isExpanded(index)
1037 else: 1037 self.setExpanded(index, not state)
1038 self.__showVariableDetails(index) 1038 else:
1039 self.__showVariableDetails(index)
1039 1040
1040 def __mdlRequestExpand(self, modelIndex): 1041 def __mdlRequestExpand(self, modelIndex):
1041 """ 1042 """
1042 Private method to inform the view about items to be expand. 1043 Private method to inform the view about items to be expand.
1043 1044
1052 Private method to generate the popup menus. 1053 Private method to generate the popup menus.
1053 """ 1054 """
1054 self.menu = QMenu() 1055 self.menu = QMenu()
1055 self.menu.addAction(self.tr("Show Details..."), self.__showDetails) 1056 self.menu.addAction(self.tr("Show Details..."), self.__showDetails)
1056 self.menu.addSeparator() 1057 self.menu.addSeparator()
1057 self.menu.addAction(self.tr("Expand"), self.__expandChildren) 1058 self.__expandChildrenAct = self.menu.addAction(
1058 self.menu.addAction(self.tr("Collapse"), self.__collapseChildren) 1059 self.tr("Expand Subitems"), self.__expandChildren
1060 )
1061 self.__collapseChildrenAct = self.menu.addAction(
1062 self.tr("Collapse Subitems"), self.__collapseChildren
1063 )
1059 self.menu.addAction(self.tr("Collapse All"), self.collapseAll) 1064 self.menu.addAction(self.tr("Collapse All"), self.collapseAll)
1060 self.menu.addSeparator() 1065 self.menu.addSeparator()
1061 self.menu.addAction(self.tr("Refresh"), self.__refreshView) 1066 self.menu.addAction(self.tr("Refresh"), self.__refreshView)
1062 self.menu.addSeparator() 1067 self.menu.addSeparator()
1063 self.menu.addAction(self.tr("Configure..."), self.__configure) 1068 self.menu.addAction(self.tr("Configure..."), self.__configure)
1077 1082
1078 @param coord the position of the mouse pointer 1083 @param coord the position of the mouse pointer
1079 @type QPoint 1084 @type QPoint
1080 """ 1085 """
1081 gcoord = self.mapToGlobal(coord) 1086 gcoord = self.mapToGlobal(coord)
1082 if self.indexAt(coord).isValid(): 1087 index = self.indexAt(coord)
1088 if index.isValid():
1089 expanded = self.isExpanded(index)
1090 self.__expandChildrenAct.setEnabled(expanded)
1091 self.__collapseChildrenAct.setEnabled(expanded)
1083 self.menu.popup(gcoord) 1092 self.menu.popup(gcoord)
1084 else: 1093 else:
1085 self.backMenu.popup(gcoord) 1094 self.backMenu.popup(gcoord)
1086 1095
1087 def __expandChildren(self): 1096 def __expandChildren(self):
1088 """ 1097 """
1089 Private slot to expand all child items of current parent. 1098 Private slot to expand all child items of current parent.
1090 """ 1099 """
1091 index = self.currentIndex() 1100 index = self.currentIndex()
1092 node = self.proxyModel.mapToSource(index).internalPointer() 1101 node = self.proxyModel.mapToSource(index).internalPointer()
1093 for child in node.children: 1102 if node:
1094 if child.hasChildren: 1103 for child in node.children:
1104 if child.hasChildren:
1105 row = node.children.index(child)
1106 idx = self.varModel.createIndex(row, 0, child)
1107 idx = self.proxyModel.mapFromSource(idx)
1108 self.expand(idx)
1109
1110 def __collapseChildren(self):
1111 """
1112 Private slot to collapse all child items of current parent.
1113 """
1114 index = self.currentIndex()
1115 node = self.proxyModel.mapToSource(index).internalPointer()
1116 if node:
1117 for child in node.children:
1095 row = node.children.index(child) 1118 row = node.children.index(child)
1096 idx = self.varModel.createIndex(row, 0, child) 1119 idx = self.varModel.createIndex(row, 0, child)
1097 idx = self.proxyModel.mapFromSource(idx) 1120 idx = self.proxyModel.mapFromSource(idx)
1098 self.expand(idx) 1121 if self.isExpanded(idx):
1099 1122 self.collapse(idx)
1100 def __collapseChildren(self):
1101 """
1102 Private slot to collapse all child items of current parent.
1103 """
1104 index = self.currentIndex()
1105 node = self.proxyModel.mapToSource(index).internalPointer()
1106 for child in node.children:
1107 row = node.children.index(child)
1108 idx = self.varModel.createIndex(row, 0, child)
1109 idx = self.proxyModel.mapFromSource(idx)
1110 if self.isExpanded(idx):
1111 self.collapse(idx)
1112 1123
1113 def __refreshView(self): 1124 def __refreshView(self):
1114 """ 1125 """
1115 Private slot to refresh the view. 1126 Private slot to refresh the view.
1116 """ 1127 """
1134 @type QModelIndex 1145 @type QModelIndex
1135 """ 1146 """
1136 from .VariableDetailDialog import VariableDetailDialog 1147 from .VariableDetailDialog import VariableDetailDialog
1137 1148
1138 node = self.proxyModel.mapToSource(index).internalPointer() 1149 node = self.proxyModel.mapToSource(index).internalPointer()
1150 if node is None:
1151 return
1139 1152
1140 val = node.value 1153 val = node.value
1141 vtype = node.type 1154 vtype = node.type
1142 name = node.name 1155 name = node.name
1143 1156

eric ide

mercurial