# eric6.Debugger.VariablesViewer

Module implementing the variables viewer view based on QTreeView.

### Global Attributes

SORT_ROLE

### Classes

VariableItem | Class implementing the data structure for all variable items.
VariablesModel | Class implementing the data model for QTreeView.
VariablesProxyModel | Class for handling the sort operations.
VariablesViewer | Class implementing the variables viewer view.

### Functions

None

## VariableItem

Class implementing the data structure for all variable items.

### Derived from

object

### Class Attributes

Type2Indicators
arrayTypes
noOfItemsStr
nonExpandableTypes
rx_nonprintable
unsized

### Class Methods

None

### Methods

VariableItem | Constructor
__getName | Private method to extract the variable name.
__getType | Private method to process the type of the variable.
__getValue | Private method to process the variables value.
absolutCount | Public property to get the total number of children.
populated | Public property returning a flag indicating if item is fully populated.

### Static Methods

None

#### VariableItem (Constructor)

VariableItem(parent, dvar, dtype, dvalue)

Constructor

parent (VariableItem)
  reference to the parent item
dvar (str)
  variable name
dtype (str)
  type string
dvalue (str)
  value string

#### VariableItem.__getName

__getName(dvar)

Private method to extract the variable name.

dvar (str)
  name of variable maybe with ID

#### VariableItem.__getType

__getType(dtype)

Private method to process the type of the variable.

If type is known to have children, the corresponding flag is set.

dtype (str)
  type string

#### VariableItem.__getValue

__getValue(dtype, dvalue)

Private method to process the variables value.

Define and limit value, set tooltip text. If type is known to have children, the corresponding flag is set.

dtype (str)
  type string
dvalue (str)
  value of variable encoded as utf-8

#### VariableItem.absolutCount

absolutCount()

Public property to get the total number of children.

Returns:
  total number of children

Return Type:
  int

#### VariableItem.populated

populated()

Public property returning a flag indicating if item is fully populated.

Returns:
  item is fully populated

Return Type:
  bool

Up

## VariablesModel

Class implementing the data model for QTreeView.

### Signals

expand
  trigger QTreeView to expand given index

### Derived from

QAbstractItemModel

### Class Attributes

None

### Class Methods

None

### Methods

VariablesModel | Constructor
__buildTreePath | Private method to build up a path from the root to parent.
__cleanupParentList | Private method to remove items which are left over at the end of the child list.
__findPendingItem | Private method to find the next item to request data from debugger.
__findVariable | Private method to get to the given variable.
clear | Public method to clear the complete data model.
columnCount | Public method to get the column count.
data | Public method get the role data of item.
flags | Public method to get the item flags.
getMore | Public method to fetch the next variable from debugger.
handlePreferencesChanged | Public slot to handle the preferencesChanged signal.
hasChildren | Public method to get a flag if parent has children.
headerData | Public method get the header names.
index | Public method to get the index of item at row:column of parent.
parent | Public method to get the parent of the given child.
resetModifiedMarker | Public method to remove the modified marker from changed items.
rowCount | Public method to get the row count.
setExpanded | Public method to set the expanded state of item.
showVariables | Public method to update the data model of variable in pathlist.

### Static Methods

None

#### VariablesModel (Constructor)

VariablesModel(treeView, globalScope)

Constructor

treeView (VariablesViewer)
  QTreeView showing the data
globalScope (bool)
  flag indicating global (True) or local (False) variables

#### VariablesModel.__buildTreePath

__buildTreePath(parent)

Private method to build up a path from the root to parent.

parent (VariableItem)
  item to build the path for

Returns:
  list of names denoting the path from the root

Return Type:
  tuple of str

#### VariablesModel.__cleanupParentList

__cleanupParentList(parent, parentIdx)

Private method to remove items which are left over at the end of the child list.

parent (VariableItem)
  to clean up
parentIdx (QModelIndex)
  the parent index as QModelIndex

#### VariablesModel.__findPendingItem

__findPendingItem(parent=None, pathlist=())

Private method to find the next item to request data from debugger.

parent (VariableItem)
  the model parent
pathlist (list of str)
  full path to the variable

Returns:
  next item index to request data from debugger

Return Type:
  QModelIndex

#### VariablesModel.__findVariable

__findVariable(pathlist)

Private method to get to the given variable.

pathlist (list of str)
  full path to the variable

Returns:
  the found variable or None if it doesn't exist

Return Type:
  VariableItem or None

#### VariablesModel.clear

clear(reset=False)

Public method to clear the complete data model.

reset (bool)
  flag to clear the expanded keys also

#### VariablesModel.columnCount

columnCount(parent=QModelIndex())

Public method to get the column count.

parent (QModelIndex)
  the model parent

Returns:
  number of columns

Return Type:
  int

#### VariablesModel.data

data(index, role=Qt.DisplayRole)

Public method get the role data of item.

index (QModelIndex)
  the model index
role (QtCore.Qt.ItemDataRole)
  the requested data role

Returns:
  role data of item

Return Type:
  Any

#### VariablesModel.flags

flags(index)

Public method to get the item flags.

index (QModelIndex)
  of item

Returns:
  item flags

Return Type:
  QtCore.Qt.ItemFlag

#### VariablesModel.getMore

getMore()

Public method to fetch the next variable from debugger.

#### VariablesModel.handlePreferencesChanged

handlePreferencesChanged()

Public slot to handle the preferencesChanged signal.

#### VariablesModel.hasChildren

hasChildren(parent=QModelIndex())

Public method to get a flag if parent has children.

parent (QModelIndex)
  the model parent

Returns:
  flag indicating parent has children

Return Type:
  bool

#### VariablesModel.headerData

headerData(section, orientation, role=Qt.DisplayRole)

Public method get the header names.

section (int)
  the header section (row/coulumn)
orientation (QtCore.Qt.Orientation)
  the header's orientation
role (QtCore.Qt.ItemDataRole)
  the requested data role

Returns:
  header name

Return Type:
  str or None

#### VariablesModel.index

index(row, column, parent=QModelIndex())

Public method to get the index of item at row:column of parent.

row (int)
  number of rows
column (int)
  number of columns
parent (QModelIndex)
  the model parent

Returns:
  new model index for child

Return Type:
  QModelIndex

#### VariablesModel.parent

parent(child)

Public method to get the parent of the given child.

child (QModelIndex)
  the model child node

Returns:
  new model index for parent

Return Type:
  QModelIndex

#### VariablesModel.resetModifiedMarker

resetModifiedMarker(parentIdx=QModelIndex(), pathlist=())

Public method to remove the modified marker from changed items.

parentIdx (QModelIndex)
  item to reset marker
pathlist (list of str)
  full path to the variable

#### VariablesModel.rowCount

rowCount(parent=QModelIndex())

Public method to get the row count.

parent (QModelIndex)
  the model parent

Returns:
  number of rows

Return Type:
  int

#### VariablesModel.setExpanded

setExpanded(index, state)

Public method to set the expanded state of item.

index (QModelIndex)
  item to change expanded state
state (bool)
  state of the item

#### VariablesModel.showVariables

showVariables(vlist, frmnr, pathlist=None)

Public method to update the data model of variable in pathlist.

vlist (list of str)
  the list of variables to be displayed. Each list entry is a tuple of three values.
  - the variable name (string)
  - the variables type (string)
  - the variables value (string)
frmnr (int)
  frame number (0 is the current frame)
pathlist (list of str)
  full path to the variable

Up

## VariablesProxyModel

Class for handling the sort operations.

### Derived from

QSortFilterProxyModel

### Class Attributes

None

### Class Methods

None

### Methods

VariablesProxyModel | Constructor
hasChildren | Public method to get a flag if parent has children.
setExpanded | Public slot to get a flag if parent has children.

### Static Methods

None

#### VariablesProxyModel (Constructor)

VariablesProxyModel(parent=None)

Constructor

parent (QModelIndex)
  the parent model index

#### VariablesProxyModel.hasChildren

hasChildren(parent)

Public method to get a flag if parent has children.

The given model index has to be transformed to the underlying source model to get the correct result.

parent (QModelIndex)
  the model parent

Returns:
  flag if parent has children

Return Type:
  bool

#### VariablesProxyModel.setExpanded

setExpanded(index, state)

Public slot to get a flag if parent has children.

The given model index has to be transformed to the underlying source model to get the correct result.

index (QModelIndex)
  item to change expanded state
state (bool)
  state of the item

Up

## VariablesViewer

Class implementing the variables viewer view.

This view is used to display the variables of the program being debugged in a tree. Compound types will be shown with their main entry first. Once the subtree has been expanded, the individual entries will be shown. Double clicking an entry will expand or collapse the item, if it has children and the double click was performed on the first column of the tree, otherwise it'll popup a dialog showing the variables parameters in a more readable form. This is especially useful for lengthy strings.

This view has two modes for displaying the global and the local variables.

### Signals

preferencesChanged()
  to inform model about new background colours

### Derived from

QTreeView

### Class Attributes

None

### Class Methods

None

### Methods

VariablesViewer | Constructor
__collapseChildren | Private slot to collapse all child items of current parent.
__configure | Private method to open the configuration dialog.
__configureFilter | Private method to open the variables filter dialog.
__createPopupMenus | Private method to generate the popup menus.
__expandChildren | Private slot to expand all child items of current parent.
__itemDoubleClicked | Private method called if an item was double clicked.
__mdlRequestExpand | Private method to inform the view about items to be expand.
__refreshView | Private slot to refresh the view.
__showContextMenu | Private slot to show the context menu.
__showDetails | Private slot to show details about the selected variable.
__showVariableDetails | Private method to show details about a variable.
handleResetUI | Public method to reset the VariablesViewer.
resizeEvent | Protected slot informing about the widget size change.
showVariable | Public method to show variables in a list.
showVariables | Public method to show variables in a list.
verticalScrollbarValueChanged | Public slot informing about the scrollbar change.

### Static Methods

None

#### VariablesViewer (Constructor)

VariablesViewer(viewer, globalScope, parent=None)

Constructor

viewer (DebugViewer)
  reference to the debug viewer object
globalScope (bool)
  flag indicating global (True) or local (False) variables
parent (QWidget)
  the parent

#### VariablesViewer.__collapseChildren

__collapseChildren()

Private slot to collapse all child items of current parent.

#### VariablesViewer.__configure

__configure()

Private method to open the configuration dialog.

#### VariablesViewer.__configureFilter

__configureFilter()

Private method to open the variables filter dialog.

#### VariablesViewer.__createPopupMenus

__createPopupMenus()

Private method to generate the popup menus.

#### VariablesViewer.__expandChildren

__expandChildren()

Private slot to expand all child items of current parent.

#### VariablesViewer.__itemDoubleClicked

__itemDoubleClicked(index)

Private method called if an item was double clicked.

index (QModelIndex)
  the double clicked item

#### VariablesViewer.__mdlRequestExpand

__mdlRequestExpand(modelIndex)

Private method to inform the view about items to be expand.

modelIndex (QModelIndex)
  the model index

#### VariablesViewer.__refreshView

__refreshView()

Private slot to refresh the view.

#### VariablesViewer.__showContextMenu

__showContextMenu(coord)

Private slot to show the context menu.

coord (QPoint)
  the position of the mouse pointer

#### VariablesViewer.__showDetails

__showDetails()

Private slot to show details about the selected variable.

#### VariablesViewer.__showVariableDetails

__showVariableDetails(index)

Private method to show details about a variable.

index (QModelIndex)
  reference to the variable item

#### VariablesViewer.handleResetUI

handleResetUI()

Public method to reset the VariablesViewer.

#### VariablesViewer.resizeEvent

resizeEvent(event)

Protected slot informing about the widget size change.

event (QResizeEvent)
  information

#### VariablesViewer.showVariable

showVariable(vlist)

Public method to show variables in a list.

vlist (list)
  the list of subitems to be displayed. The first element gives the path of the parent variable. Each other list entry is a tuple of three values.
  - the variable name (string)
  - the variables type (string)
  - the variables value (string)

#### VariablesViewer.showVariables

showVariables(vlist, frmnr)

Public method to show variables in a list.

vlist (list)
  the list of variables to be displayed. Each list entry is a tuple of three values.
  - the variable name (string)
  - the variables type (string)
  - the variables value (string)
frmnr (int)
  frame number (0 is the current frame)

#### VariablesViewer.verticalScrollbarValueChanged

verticalScrollbarValueChanged(value)

Public slot informing about the scrollbar change.

value (int)
  current value of the vertical scrollbar

Up