--- a/Debugger/VariablesViewer.py Tue Sep 13 18:33:44 2016 +0200 +++ b/Debugger/VariablesViewer.py Tue Sep 13 19:27:42 2016 +0200 @@ -130,7 +130,7 @@ These special variable nodes are generated for classes, lists, tuples and dictionaries. """ - def __init__(self, parent, dvar, dvalue, dtype, frmnr, scope): + def __init__(self, parent, dvar, dvalue, dtype, frmnr, globalScope): """ Constructor @@ -139,14 +139,15 @@ @param dvalue value string (string) @param dtype type string (string) @param frmnr frame number (0 is the current frame) (int) - @param scope flag indicating global (1) or local (0) variables + @param globalScope flag indicating global (True) or local (False) + variables """ VariableItem.__init__(self, parent, dvar, dvalue, dtype) self.attachDummy() self.populated = False self.framenr = frmnr - self.scope = scope + self.globalScope = globalScope def expand(self): """ @@ -164,9 +165,9 @@ par = par.parent() # step 2: request the variable from the debugger - filter = e5App().getObject("DebugUI").variablesFilter(self.scope) + filter = e5App().getObject("DebugUI").variablesFilter(self.globalScope) e5App().getObject("DebugServer").remoteClientVariable( - self.scope, filter, pathlist, self.framenr) + self.globalScope, filter, pathlist, self.framenr) class ArrayElementVarItem(VariableItem): @@ -199,7 +200,7 @@ Class implementing a QTreeWidgetItem that represents a special array variable node. """ - def __init__(self, parent, dvar, dvalue, dtype, frmnr, scope): + def __init__(self, parent, dvar, dvalue, dtype, frmnr, globalScope): """ Constructor @@ -208,10 +209,11 @@ @param dvalue value string (string) @param dtype type string (string) @param frmnr frame number (0 is the current frame) (int) - @param scope flag indicating global (1) or local (0) variables + @param globalScope flag indicating global (True) or local (False) + variables """ SpecialVarItem.__init__(self, parent, dvar, dvalue, dtype, frmnr, - scope) + globalScope) """ Array elements have numbers as names, but the key must be @@ -238,20 +240,27 @@ This widget has two modes for displaying the global and the local variables. """ - def __init__(self, parent=None, scope=1): + def __init__(self, viewer, globalScope, parent=None): """ Constructor + @param viewer reference to the debug viewer object (DebugViewer) + @param globalScope flag indicating global (True) or local (False) + variables @param parent the parent (QWidget) - @param scope flag indicating global (1) or local (0) variables """ super(VariablesViewer, self).__init__(parent) - self.indicators = {'list': '[]', 'tuple': '()', 'dict': '{}', # __IGNORE_WARNING__ - # Python types - 'Array': '[]', 'Hash': '{}' # __IGNORE_WARNING__ - # Ruby types - } + self.__debugViewer = viewer + self.__globalScope = globalScope + + self.indicators = { + # Python types + 'list': '[]', + 'tuple': '()', + 'dict': '{}', # __IGNORE_WARNING__ + + } self.rx_class = QRegExp('<.*(instance|object) at 0x.*>') self.rx_class2 = QRegExp('class .*') @@ -273,8 +282,7 @@ self.setAlternatingRowColors(True) self.setSelectionBehavior(QAbstractItemView.SelectRows) - self.scope = scope - if scope: + if self.__globalScope: self.setWindowTitle(self.tr("Global Variables")) self.setHeaderLabels([ self.tr("Globals"), @@ -323,10 +331,13 @@ """ self.menu = QMenu() self.menu.addAction(self.tr("Show Details..."), self.__showDetails) + self.menu.addAction(self.tr("Refresh"), self.__refreshView) self.menu.addSeparator() self.menu.addAction(self.tr("Configure..."), self.__configure) self.backMenu = QMenu() + self.backMenu.addAction(self.tr("Refresh"), self.__refreshView) + self.backMenu.addSeparator() self.backMenu.addAction(self.tr("Configure..."), self.__configure) def __showContextMenu(self, coord): @@ -493,18 +504,20 @@ isSpecial = False if self.rx_class2.exactMatch(dtype): - return SpecialVarItem(parent, dvar, dvalue, dtype[7:-1], - self.framenr, self.scope) + return SpecialVarItem( + parent, dvar, dvalue, dtype[7:-1], self.framenr, + self.__globalScope) elif dtype != "void *" and \ (self.rx_class.exactMatch(dvalue) or self.rx_class3.exactMatch(dvalue) or isSpecial): if self.dvar_rx_special_array_element.exactMatch(dvar): - return SpecialArrayElementVarItem(parent, dvar, dvalue, dtype, - self.framenr, self.scope) + return SpecialArrayElementVarItem( + parent, dvar, dvalue, dtype, self.framenr, + self.__globalScope) else: return SpecialVarItem(parent, dvar, dvalue, dtype, - self.framenr, self.scope) + self.framenr, self.__globalScope) else: if self.dvar_rx_array_element.exactMatch(dvar): return ArrayElementVarItem(parent, dvar, dvalue, dtype) @@ -571,7 +584,16 @@ else: dvtype = vtype return dvtype - + + def __refreshView(self): + """ + Private slot to refresh the view. + """ + if self.__globalScope: + self.__debugViewer.setGlobalsFilter() + else: + self.__debugViewer.setLocalsFilter() + def mouseDoubleClickEvent(self, mouseEvent): """ Protected method of QAbstractItemView.