eric6/Debugger/VariablesViewer.py

Sat, 27 Jun 2020 12:08:12 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Jun 2020 12:08:12 +0200
changeset 7639
422fd05e9c91
parent 7628
f904d0eef264
child 7646
39e3db2b4936
child 7653
d69ebd6a97bd
permissions
-rw-r--r--

Removed some more Python2 related code.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7332
diff changeset
3 # Copyright (c) 2002 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
7 Module implementing the variables viewer view based on QTreeView.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
10
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
11 import ast
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
12
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
13 from PyQt5.QtCore import (Qt, QAbstractItemModel, QModelIndex, QRegExp,
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
14 QCoreApplication, QSortFilterProxyModel, pyqtSignal)
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
15 from PyQt5.QtGui import QBrush, QFontMetrics
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
16 from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
55
b5c84934de9c Renamed E4Gui to E5Gui.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 53
diff changeset
18 from E5Gui.E5Application import e5App
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
96
9624a110667d Started to clean up the code supported by py3flakes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 55
diff changeset
20 from .Config import ConfigVarTypeDispStrings
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
21 from DebugClients.Python.DebugConfig import ConfigQtNames, ConfigKnownQtTypes
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
23 import Preferences
2511
a0ff5574e43a Changed the way multi line strings are shown in the value column of the variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2400
diff changeset
24 import Utilities
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
25
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
26 SORT_ROLE = Qt.UserRole
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
29 class VariableItem(object):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
31 Class implementing the data structure for all variable items.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
33 Type2Indicators = {
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
34 # Python types
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
35 'list': '[]',
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
36 'tuple': '()',
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
37 'dict': '{:}', # __IGNORE_WARNING_M613__
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
38 'set': '{}', # __IGNORE_WARNING_M613__
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
39 'frozenset': '{}', # __IGNORE_WARNING_M613__
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
40 'numpy.ndarray': '[ndarray]', # __IGNORE_WARNING_M613__
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
41 }
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
42
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
43 # Initialize regular expression for unprintable strings
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
44 rx_nonprintable = QRegExp(r"""(\\x\d\d)+""")
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
45
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
46 noOfItemsStr = QCoreApplication.translate("VariablesViewer", "{0} items")
7332
49076c600903 Bugfixes for displaying numpy arrays.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7251
diff changeset
47 unsized = QCoreApplication.translate("VariablesViewer", "unsized")
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
48
6994
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
49 arrayTypes = {
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
50 'list', 'tuple', 'dict', 'set', 'frozenset', 'numpy.ndarray',
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
51 'django.MultiValueDict', 'array.array', 'collections.defaultdict',
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
52 "class 'dict_items'", "class 'dict_keys'", "class 'dict_values'",
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
53 }
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
54
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
55 nonExpandableTypes = (
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
56 'method_descriptor', 'wrapper_descriptor', '', 'getset_descriptor',
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
57 'method-wrapper', 'member_descriptor',
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
58 )
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
59
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
60 def __init__(self, parent, dvar, dtype, dvalue):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
62 Constructor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 @param parent reference to the parent item
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
65 @type VariableItem
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
66 @param dvar variable name
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
67 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
68 @param dtype type string
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
69 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
70 @param dvalue value string
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
71 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
72 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
73 self.parent = parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
74 # Take the additional methods into account for childCount
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
75 self.methodCount = 0
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
76 self.childCount = 0
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
77 self.currentCount = -1 # -1 indicates to (re)load children
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
78 # Indicator that there are children
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
79 self.hasChildren = False
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
80 # Indicator that item was at least once fully populated
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
81 self.wasPopulated = False
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
82
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
83 self.children = []
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
84 # Flag to prevent endless reloading of current item while waiting on
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
85 # a response from debugger
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
86 self.pendigFetch = False
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
87
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
88 # Set of child items, which are displayed the first time or changed
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
89 self.newItems = set()
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
90 self.changedItems = set()
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
91 # Name including its ID if it's a dict, set, etc.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
92 self.nameWithId = dvar
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
93
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
94 self.name = ''
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
95 self.sort = ''
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
96 self.type = ''
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
97 self.indicator = ''
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
98 self.value = None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
99 self.valueShort = None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
100 self.tooltip = ''
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
101
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
102 self.__getName(dvar)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
103 self.__getType(dtype)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
104 self.__getValue(dtype, dvalue)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
105
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
106 def __getName(self, dvar):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
107 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
108 Private method to extract the variable name.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
109
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
110 @param dvar name of variable maybe with ID
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
111 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
112 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
113 try:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
114 idx = dvar.index(" (ID:")
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
115 dvar = dvar[:idx]
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
116 except ValueError:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
117 pass
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
118
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
119 self.name = dvar
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
120 try:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
121 # Convert numbers to strings with preceding zeros
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
122 sort = int(dvar)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
123 sort = "{0:06}".format(sort)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
124 except ValueError:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
125 sort = dvar.lower()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
126
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
127 self.sort = sort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
128
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
129 def __getType(self, dtype):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
131 Private method to process the type of the variable.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
132
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
133 If type is known to have children, the corresponding flag is set.
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
134
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
135 @param dtype type string
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
136 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
137 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
138 # Python class?
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
139 if dtype.startswith('class '):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
140 dtype = dtype[7:-1]
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
141 # Qt related stuff?
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
142 elif (dtype.startswith(ConfigQtNames) and
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
143 dtype.endswith(ConfigKnownQtTypes)):
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
144 self.hasChildren = True
6978
720247f98e1f Improved determination of expandable items including removing 'other' as selectable type.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6969
diff changeset
145
720247f98e1f Improved determination of expandable items including removing 'other' as selectable type.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6969
diff changeset
146 elif dtype in ('instance', 'class'):
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
147 self.hasChildren = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
148
7019
a1b25790bc5c Special Qt types should not be expanded infinite.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7016
diff changeset
149 # Special Qt types should not be expanded infinite
a1b25790bc5c Special Qt types should not be expanded infinite.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7016
diff changeset
150 elif ".{0}".format(dtype) in ConfigKnownQtTypes:
a1b25790bc5c Special Qt types should not be expanded infinite.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7016
diff changeset
151 self.type = dtype # It's a Qt type, so skipping translation is ok
a1b25790bc5c Special Qt types should not be expanded infinite.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7016
diff changeset
152 return
a1b25790bc5c Special Qt types should not be expanded infinite.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7016
diff changeset
153
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
154 vtype = ConfigVarTypeDispStrings.get(dtype, dtype)
6978
720247f98e1f Improved determination of expandable items including removing 'other' as selectable type.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6969
diff changeset
155 # Unkown types should be expandable by default
6994
681ed8916e69 Finetuning of non-expandable types.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6993
diff changeset
156 if vtype is dtype and dtype not in self.nonExpandableTypes:
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
157 self.hasChildren = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
158 self.type = QCoreApplication.translate("VariablesViewer", vtype)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
159
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
160 def __getValue(self, dtype, dvalue):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
161 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
162 Private method to process the variables value.
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
163
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
164 Define and limit value, set tooltip text. If type is known to have
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
165 children, the corresponding flag is set.
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
166
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
167 @param dtype type string
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
168 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
169 @param dvalue value of variable encoded as utf-8
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
170 @type str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
171 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
172 if dtype == 'collections.defaultdict':
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
173 dvalue, default_factory = dvalue.split('|')
7031
6fafe9ed04b5 Bugfix displaying to many characters as default_factory type.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7019
diff changeset
174 self.indicator = '{{:<{0}>}}'.format(default_factory)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
175 elif dtype == 'array.array':
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
176 dvalue, typecode = dvalue.split('|')
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
177 self.indicator = '[<{0}>]'.format(typecode)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
178 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
179 self.indicator = VariableItem.Type2Indicators.get(dtype, '')
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
180
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
181 if dtype == 'numpy.ndarray':
7332
49076c600903 Bugfixes for displaying numpy arrays.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7251
diff changeset
182 if dvalue:
49076c600903 Bugfixes for displaying numpy arrays.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7251
diff changeset
183 self.childCount = int(dvalue.split('x')[0])
49076c600903 Bugfixes for displaying numpy arrays.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7251
diff changeset
184 dvalue = VariableItem.noOfItemsStr.format(dvalue)
49076c600903 Bugfixes for displaying numpy arrays.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7251
diff changeset
185 else:
49076c600903 Bugfixes for displaying numpy arrays.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 7251
diff changeset
186 dvalue = VariableItem.unsized
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
187 self.hasChildren = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
188 elif dtype in VariableItem.arrayTypes:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
189 self.childCount = int(dvalue)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
190 dvalue = VariableItem.noOfItemsStr.format(dvalue)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
191 self.hasChildren = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
192
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
193 elif dtype == "Shiboken.EnumType":
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
194 self.hasChildren = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
195
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
196 elif dtype in ['str', 'unicode']:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
197 if VariableItem.rx_nonprintable.indexIn(dvalue) == -1:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
198 try:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
199 dvalue = ast.literal_eval(dvalue)
7628
f904d0eef264 Checked the reported security related issue reports generated by the new security checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7366
diff changeset
200 except Exception: # secok
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
201 pass
7639
422fd05e9c91 Removed some more Python2 related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7628
diff changeset
202 dvalue = str(dvalue)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
203
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
204 self.value = dvalue
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
205
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
206 if len(dvalue) > 2048: # 2 kB
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
207 self.tooltip = dvalue[:2048]
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
208 dvalue = QCoreApplication.translate(
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3621
diff changeset
209 "VariableItem", "<double click to show value>")
2511
a0ff5574e43a Changed the way multi line strings are shown in the value column of the variables viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2400
diff changeset
210 else:
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
211 self.tooltip = dvalue
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
213 lines = dvalue[:2048].splitlines()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
214 if len(lines) > 1:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
215 # only show the first non-empty line;
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
216 # indicate skipped lines by <...> at the
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
217 # beginning and/or end
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
218 index = 0
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
219 while index < len(lines) - 1 and lines[index].strip(' \t') == "":
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
220 index += 1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
221
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
222 dvalue = ""
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
223 if index > 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
224 dvalue += "<...>"
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
225 dvalue += lines[index]
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
226 if index < len(lines) - 1 or len(dvalue) > 2048:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
227 dvalue += "<...>"
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
228
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
229 self.valueShort = dvalue
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
230
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
231 @property
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
232 def absolutCount(self):
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5169
diff changeset
233 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
234 Public property to get the total number of children.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
235
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
236 @return total number of children
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
237 @rtype int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
239 return self.childCount + self.methodCount
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
240
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
241 @property
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
242 def populated(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
244 Public property returning a flag indicating if item is fully populated.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
246 @return item is fully populated
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
247 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
249 return self.currentCount >= (self.childCount + self.methodCount)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
251
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
252 class VariablesModel(QAbstractItemModel):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
254 Class implementing the data model for QTreeView.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
256 @signal expand trigger QTreeView to expand given index
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
258 expand = pyqtSignal(QModelIndex)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
259
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
260 def __init__(self, treeView, globalScope):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
264 @param treeView QTreeView showing the data
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
265 @type VariablesViewer
5165
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
266 @param globalScope flag indicating global (True) or local (False)
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
267 variables
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
268 @type bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
270 super(VariablesModel, self).__init__()
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
271 self.treeView = treeView
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
272 self.proxyModel = treeView.proxyModel
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
273
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
274 self.framenr = -1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
275 self.openItems = []
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
276 self.closedItems = []
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
277
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
278 if globalScope:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
279 visibility = self.tr("Globals")
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
280 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
281 visibility = self.tr("Locals")
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
282
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
283 self.rootNode = VariableItem(None, visibility, self.tr("Type"),
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
284 self.tr("Value"))
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
285
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
286 self.__globalScope = globalScope
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
287
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
288 def clear(self, reset=False):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
289 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
290 Public method to clear the complete data model.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
291
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
292 @param reset flag to clear the expanded keys also
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
293 @type bool
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
294 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
295 self.beginResetModel()
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
296 self.rootNode.children = []
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
297 self.rootNode.newItems.clear()
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
298 self.rootNode.changedItems.clear()
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
299 self.rootNode.wasPopulated = False
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
300 if reset:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
301 self.openItems = []
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
302 self.closedItems = []
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
303 self.endResetModel()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
304
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
305 def __findVariable(self, pathlist):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
306 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
307 Private method to get to the given variable.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
308
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
309 @param pathlist full path to the variable
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
310 @type list of str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
311 @return the found variable or None if it doesn't exist
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
312 @rtype VariableItem or None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
313 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
314 node = self.rootNode
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
315
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
316 for childName in pathlist or []:
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
317 for item in node.children:
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
318 if item.nameWithId == childName:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
319 node = item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
320 break
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
321 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
322 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
323
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
324 return node # __IGNORE_WARNING_M834__
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
325
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
326 def showVariables(self, vlist, frmnr, pathlist=None):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
327 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
328 Public method to update the data model of variable in pathlist.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
329
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
330 @param vlist the list of variables to be displayed. Each
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
331 list entry is a tuple of three values.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
332 <ul>
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
333 <li>the variable name (string)</li>
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
334 <li>the variables type (string)</li>
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
335 <li>the variables value (string)</li>
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
336 </ul>
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
337 @type list of str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
338 @param frmnr frame number (0 is the current frame)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
339 @type int
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
340 @param pathlist full path to the variable
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
341 @type list of str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
342 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
343 if pathlist:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
344 itemStartIndex = pathlist.pop(0)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
345 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
346 itemStartIndex = -1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
347 if self.framenr != frmnr:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
348 self.clear()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
349 self.framenr = frmnr
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
350
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
351 parent = self.__findVariable(pathlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
352 if parent is None:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
353 return
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
354
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
355 parent.pendigFetch = False
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
356
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
357 if parent == self.rootNode:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
358 parentIdx = QModelIndex()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
359 parent.methodCount = len(vlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
360 else:
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
361 row = parent.parent.children.index(parent)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
362 parentIdx = self.createIndex(row, 0, parent)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
363
6979
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
364 if itemStartIndex == -3:
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
365 # Item doesn't exist any more
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
366 parentIdx = self.parent(parentIdx)
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
367 self.beginRemoveRows(parentIdx, row, row)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
368 del parent.parent.children[row]
6979
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
369 self.endRemoveRows()
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
370 parent.parent.childCount -= 1
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
371 return
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
372
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
373 elif itemStartIndex == -2:
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
374 parent.wasPopulated = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
375 parent.currentCount = parent.absolutCount
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
376 # Remove items which are left over at the end of child list
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
377 self.__cleanupParentList(parent, parentIdx)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
378 return
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
379
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
380 elif itemStartIndex == -1:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
381 parent.methodCount = len(vlist)
6979
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
382 idx = parent.childCount = parent.currentCount + 1
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
383 parent.currentCount += 1 + len(vlist)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
384 else:
6979
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
385 idx = parent.currentCount + 1
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
386 parent.currentCount += len(vlist)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
388 # Sort items for Python versions where dict doesn't retain order
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
389 vlist.sort(key=lambda x: x[0])
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
390 # Now update the table
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
391 endIndex = idx + len(vlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
392 newChild = None
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
393 knownChildrenCount = len(parent.children)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
394 while idx < endIndex:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
395 # Fetch next old item from last cycle
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
396 try:
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
397 child = parent.children[idx]
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
398 except IndexError:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
399 child = None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
400
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
401 # Fetch possible new item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
402 if not newChild and vlist:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
403 newChild = vlist.pop(0)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
404
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
405 # Process parameters of new item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
406 newItem = VariableItem(parent, *newChild)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
407 sort = newItem.sort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
408
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
409 # Append or insert before already existing item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
410 if child is None or newChild and sort < child.sort:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
411 self.beginInsertRows(parentIdx, idx, idx)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
412 parent.children.insert(idx, newItem)
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
413 if knownChildrenCount <= idx and not parent.wasPopulated:
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
414 parent.newItems.add(newItem)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
415 knownChildrenCount += 1
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
416 else:
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
417 parent.changedItems.add(newItem)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
418 self.endInsertRows()
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
419
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
420 idx += 1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
421 newChild = None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
422 continue
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
423
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
424 # Check if same name, type and afterwards value
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
425 elif sort == child.sort and child.type == newItem.type:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
426 # Check if value has changed
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
427 if child.value != newItem.value:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
428 child.value = newItem.value
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
429 child.valueShort = newItem.valueShort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
430 child.tooltip = newItem.tooltip
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
431
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
432 child.currentCount = -1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
433 child.childCount = newItem.childCount
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
434
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
435 # Highlight item because it has changed
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
436 parent.changedItems.add(child)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
437
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
438 changedIndexStart = self.index(idx, 0, parentIdx)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
439 changedIndexEnd = self.index(idx, 2, parentIdx)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
440 self.dataChanged.emit(changedIndexStart, changedIndexEnd)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
441
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
442 newChild = None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
443 idx += 1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
444 continue
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
445
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
446 # Remove obsolete item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
447 self.beginRemoveRows(parentIdx, idx, idx)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
448 parent.children.remove(child)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
449 self.endRemoveRows()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
450 # idx stay unchanged
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
451 knownChildrenCount -= 1
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
452
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
453 # Remove items which are left over at the end of child list
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
454 if itemStartIndex == -1:
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
455 parent.wasPopulated = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
456 self.__cleanupParentList(parent, parentIdx)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
457
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
458 # Request data for any expanded node
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
459 self.getMore()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
460
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
461 def __cleanupParentList(self, parent, parentIdx):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
462 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
463 Private method to remove items which are left over at the end of the
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
464 child list.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
465
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
466 @param parent to clean up
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
467 @type VariableItem
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
468 @param parentIdx the parent index as QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
469 @type QModelIndex
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
471 end = len(parent.children)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
472 if end > parent.absolutCount:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
473 self.beginRemoveRows(parentIdx, parent.absolutCount, end)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
474 del parent.children[parent.absolutCount:]
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
475 self.endRemoveRows()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
476
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
477 def resetModifiedMarker(self, parentIdx=QModelIndex(), pathlist=()):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
478 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
479 Public method to remove the modified marker from changed items.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
480
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
481 @param parentIdx item to reset marker
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
482 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
483 @param pathlist full path to the variable
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
484 @type list of str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
485 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
486 if parentIdx.isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
487 parent = parentIdx.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
488 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
489 parent = self.rootNode
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
490
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
491 parent.newItems.clear()
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
492 parent.changedItems.clear()
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
493
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
494 pll = len(pathlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
495 posPaths = {x for x in self.openItems if len(x) > pll}
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
496 posPaths |= {x for x in self.closedItems if len(x) > pll}
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
497 posPaths = {x[pll] for x in posPaths if x[:pll] == pathlist}
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
498
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
499 if posPaths:
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
500 for child in parent.children:
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
501 if child.hasChildren and child.nameWithId in posPaths:
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
502 if child.currentCount >= 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
503 # Discard loaded elements and refresh if still expanded
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
504 child.currentCount = -1
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
505 row = parent.children.index(child)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
506 newParentIdx = self.index(row, 0, parentIdx)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
507 self.resetModifiedMarker(
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
508 newParentIdx, pathlist + (child.nameWithId,))
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
509
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
510 self.closedItems = []
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
511
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
512 # Little quirk: Refresh all visible items to clear the changed marker
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
513 if parentIdx == QModelIndex():
6979
c272ec33ea11 Handling of no more existing items improved, e.g. list items which has as last child
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6978
diff changeset
514 self.rootNode.currentCount = -1
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
515 idxStart = self.index(0, 0, QModelIndex())
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
516 idxEnd = self.index(0, 2, QModelIndex())
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
517 self.dataChanged.emit(idxStart, idxEnd)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
518
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
519 def columnCount(self, parent=QModelIndex()):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
520 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
521 Public method to get the column count.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
522
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
523 @param parent the model parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
524 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
525 @return number of columns
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
526 @rtype int
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
527 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
528 return 3
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
529
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
530 def rowCount(self, parent=QModelIndex()):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
531 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
532 Public method to get the row count.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
533
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
534 @param parent the model parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
535 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
536 @return number of rows
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
537 @rtype int
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
538 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
539 if parent.isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
540 node = parent.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
541 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
542 node = self.rootNode
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
543
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
544 return len(node.children)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
545
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
546 def flags(self, index):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
547 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
548 Public method to get the item flags.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
549
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
550 @param index of item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
551 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
552 @return item flags
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
553 @rtype QtCore.Qt.ItemFlag
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
555 if not index.isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
556 return Qt.NoItemFlags
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
557
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
558 return Qt.ItemIsEnabled | Qt.ItemIsSelectable
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
559
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
560 def hasChildren(self, parent=QModelIndex()):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
561 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
562 Public method to get a flag if parent has children.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
563
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
564 @param parent the model parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
565 @type QModelIndex
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
566 @return flag indicating parent has children
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
567 @rtype bool
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
568 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
569 if not parent.isValid():
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
570 return self.rootNode.children != []
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
571
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
572 return parent.internalPointer().hasChildren
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
573
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
574 def index(self, row, column, parent=QModelIndex()):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
575 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
576 Public method to get the index of item at row:column of parent.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
577
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
578 @param row number of rows
7015
b1a3094b33e1 Regenerated source docu after Variables Viewer merge.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7013
diff changeset
579 @type int
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
580 @param column number of columns
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
581 @type int
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
582 @param parent the model parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
583 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
584 @return new model index for child
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
585 @rtype QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
586 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
587 if not self.hasIndex(row, column, parent):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
588 return QModelIndex()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
589
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
590 if not parent.isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
591 node = self.rootNode
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
592 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
593 node = parent.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
594
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
595 return self.createIndex(row, column, node.children[row])
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
596
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
597 def parent(self, child):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
598 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
599 Public method to get the parent of the given child.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
601 @param child the model child node
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
602 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
603 @return new model index for parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
604 @rtype QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
605 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
606 if not child.isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
607 return QModelIndex()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
608
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
609 childNode = child.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
610 if childNode == self.rootNode:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
611 return QModelIndex()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
612
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
613 parentNode = childNode.parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
614
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
615 if parentNode == self.rootNode:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
616 return QModelIndex()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
617
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
618 row = parentNode.parent.children.index(parentNode)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
619 return self.createIndex(row, 0, parentNode)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
620
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
621 def data(self, index, role=Qt.DisplayRole):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
622 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
623 Public method get the role data of item.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
624
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
625 @param index the model index
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
626 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
627 @param role the requested data role
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
628 @type QtCore.Qt.ItemDataRole
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
629 @return role data of item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
630 @rtype Any
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
631 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
632 if not index.isValid() or index.row() < 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
633 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
634
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
635 node = index.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
636 column = index.column()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
637
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
638 if role in (Qt.DisplayRole, SORT_ROLE, Qt.EditRole):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
639 try:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
640 if column == 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
641 # Sort first column with values from third column
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
642 if role == SORT_ROLE:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
643 return node.sort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
644 return node.name + node.indicator
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
645 elif column == 1:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
646 return node.valueShort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
647 elif column == 2:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
648 return node.type
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
649 elif column == 3:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
650 return node.sort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
651 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
652 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
653 except AttributeError:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
654 return ['None', '', '', ''][column]
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
655
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
656 elif role == Qt.BackgroundRole:
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
657 if node in node.parent.changedItems:
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
658 return self.__bgColorChanged
6993
d375f251496a Highlight unknown variables, e.g. expanded for the first time, in yellow instead green.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6988
diff changeset
659 elif node in node.parent.newItems:
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
660 return self.__bgColorNew
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
662 elif role == Qt.ToolTipRole:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
663 if column == 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
664 tooltip = node.name + node.indicator
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
665 elif column == 1:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
666 tooltip = node.tooltip
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
667 elif column == 2:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
668 tooltip = node.type
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
669 elif column == 3:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
670 tooltip = node.sort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
671 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
672 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
673
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
674 if Qt.mightBeRichText(tooltip):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
675 tooltip = Utilities.html_encode(tooltip)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
676
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
677 if column == 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
678 indentation = self.treeView.indentation()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
679 indentCount = 0
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
680 currentNode = node
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
681 while currentNode.parent:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
682 indentCount += 1
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
683 currentNode = currentNode.parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
684
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
685 indentation *= indentCount
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
686 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
687 indentation = 0
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
688 # Check if text is longer than available space
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
689 fontMetrics = QFontMetrics(self.treeView.font())
7366
bd743eacfbca Changed code to avoid some obsoleted Qt functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
690 try:
bd743eacfbca Changed code to avoid some obsoleted Qt functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
691 textSize = fontMetrics.horizontalAdvance(tooltip)
bd743eacfbca Changed code to avoid some obsoleted Qt functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
692 except AttributeError:
bd743eacfbca Changed code to avoid some obsoleted Qt functions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
693 textSize = fontMetrics.width(tooltip)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
694 textSize += indentation + 5 # How to determine border size?
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
695 header = self.treeView.header()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
696 if textSize >= header.sectionSize(column):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
697 return tooltip
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
698 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
699 QToolTip.hideText()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
700
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
701 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
702
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
703 def headerData(self, section, orientation, role=Qt.DisplayRole):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
704 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
705 Public method get the header names.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
706
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
707 @param section the header section (row/coulumn)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
708 @type int
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
709 @param orientation the header's orientation
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
710 @type QtCore.Qt.Orientation
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
711 @param role the requested data role
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
712 @type QtCore.Qt.ItemDataRole
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
713 @return header name
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
714 @rtype str or None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
715 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
716 if role != Qt.DisplayRole or orientation != Qt.Horizontal:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
717 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
718
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
719 if section == 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
720 return self.rootNode.name
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
721 elif section == 1:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
722 return self.rootNode.value
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
723 elif section == 2:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
724 return self.rootNode.type
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
725 elif section == 3:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
726 return self.rootNode.sort
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
727
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
728 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
729
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
730 def __findPendingItem(self, parent=None, pathlist=()):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
731 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
732 Private method to find the next item to request data from debugger.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
733
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
734 @param parent the model parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
735 @type VariableItem
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
736 @param pathlist full path to the variable
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
737 @type list of str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
738 @return next item index to request data from debugger
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
739 @rtype QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
740 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
741 if parent is None:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
742 parent = self.rootNode
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
743
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
744 for child in parent.children:
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
745 if not child.hasChildren:
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
746 continue
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
747
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
748 if pathlist + (child.nameWithId,) in self.openItems:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
749 if child.populated:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
750 index = None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
751 else:
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
752 idx = parent.children.index(child)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
753 index = self.createIndex(idx, 0, child)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
754 self.expand.emit(index)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
755
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
756 if child.currentCount < 0:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
757 return index
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
758
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
759 possibleIndex = self.__findPendingItem(
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
760 child, pathlist + (child.nameWithId,))
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
761
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
762 if (possibleIndex or index) is None:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
763 continue
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
764
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
765 return possibleIndex or index
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
766
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
767 return None
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
768
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
769 def getMore(self):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
770 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
771 Public method to fetch the next variable from debugger.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
772 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
773 # step 1: find expanded but not populated items
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
774 item = self.__findPendingItem()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
775 if not item or not item.isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
776 return
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
777
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
778 # step 2: check if data has to be retrieved
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
779 node = item.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
780 lastVisibleItem = self.index(node.currentCount - 1, 0, item)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
781 lastVisibleItem = self.proxyModel.mapFromSource(lastVisibleItem)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
782 rect = self.treeView.visualRect(lastVisibleItem)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
783 if rect.y() > self.treeView.height() or node.pendigFetch:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
784 return
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
785
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
786 node.pendigFetch = True
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
787 # step 3: get a pathlist up to the requested variable
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
788 pathlist = self.__buildTreePath(node)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
789 # step 4: request the variable from the debugger
5587
ea526b78ee6c Started to fix code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
790 variablesFilter = e5App().getObject("DebugUI").variablesFilter(
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
791 self.__globalScope)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 482
diff changeset
792 e5App().getObject("DebugServer").remoteClientVariable(
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
793 self.__globalScope, variablesFilter, pathlist, self.framenr)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
794
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
795 def setExpanded(self, index, state):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
796 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
797 Public method to set the expanded state of item.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
798
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
799 @param index item to change expanded state
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
800 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
801 @param state state of the item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
802 @type bool
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
803 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
804 node = index.internalPointer()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
805 pathlist = self.__buildTreePath(node)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
806 if state:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
807 if pathlist not in self.openItems:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
808 self.openItems.append(pathlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
809 if pathlist in self.closedItems:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
810 self.closedItems.remove(pathlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
811 self.getMore()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
812 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
813 self.openItems.remove(pathlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
814 self.closedItems.append(pathlist)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
815
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
816 def __buildTreePath(self, parent):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
817 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
818 Private method to build up a path from the root to parent.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
819
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
820 @param parent item to build the path for
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
821 @type VariableItem
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
822 @return list of names denoting the path from the root
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
823 @rtype tuple of str
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
824 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
825 pathlist = []
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
826
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
827 # build up a path from the top to the item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
828 while parent.parent:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
829 pathlist.append(parent.nameWithId)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
830 parent = parent.parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
831
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
832 pathlist.reverse()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
833 return tuple(pathlist)
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
834
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
835 def handlePreferencesChanged(self):
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
836 """
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
837 Public slot to handle the preferencesChanged signal.
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
838 """
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
839 self.__bgColorNew = QBrush(Preferences.getDebugger("BgColorNew"))
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
840 self.__bgColorChanged = QBrush(
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
841 Preferences.getDebugger("BgColorChanged"))
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
842
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
843 idxStart = self.index(0, 0, QModelIndex())
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
844 idxEnd = self.index(0, 2, QModelIndex())
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
845 self.dataChanged.emit(idxStart, idxEnd)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
847
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
848 class VariablesProxyModel(QSortFilterProxyModel):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
850 Class for handling the sort operations.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
852 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
856 @param parent the parent model index
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
857 @type QModelIndex
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
859 super(VariablesProxyModel, self).__init__(parent)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
860 self.setSortRole(SORT_ROLE)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
861
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
862 def hasChildren(self, parent):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
864 Public method to get a flag if parent has children.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
865
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
866 The given model index has to be transformed to the underlying source
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
867 model to get the correct result.
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
868
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
869 @param parent the model parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
870 @type QModelIndex
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
871 @return flag if parent has children
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
872 @rtype bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
874 return self.sourceModel().hasChildren(self.mapToSource(parent))
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
875
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
876 def setExpanded(self, index, state):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
877 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
878 Public slot to get a flag if parent has children.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
879
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
880 The given model index has to be transformed to the underlying source
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
881 model to get the correct result.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
882 @param index item to change expanded state
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
883 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
884 @param state state of the item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
885 @type bool
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
886 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
887 self.sourceModel().setExpanded(self.mapToSource(index), state)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
889
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
890 class VariablesViewer(QTreeView):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
892 Class implementing the variables viewer view.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
894 This view is used to display the variables of the program being
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895 debugged in a tree. Compound types will be shown with
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
896 their main entry first. Once the subtree has been expanded, the
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897 individual entries will be shown. Double clicking an entry will
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
898 expand or collapse the item, if it has children and the double click
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
899 was performed on the first column of the tree, otherwise it'll
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 popup a dialog showing the variables parameters in a more readable
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 form. This is especially useful for lengthy strings.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
903 This view has two modes for displaying the global and the local
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 variables.
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
905
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
906 @signal preferencesChanged() to inform model about new background colours
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 """
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
908 preferencesChanged = pyqtSignal()
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
909
5165
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
910 def __init__(self, viewer, globalScope, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
914 @param viewer reference to the debug viewer object
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
915 @type DebugViewer
5165
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
916 @param globalScope flag indicating global (True) or local (False)
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
917 variables
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
918 @type bool
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
919 @param parent the parent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
920 @type QWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2511
diff changeset
922 super(VariablesViewer, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923
5165
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
924 self.__debugViewer = viewer
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
925 self.__globalScope = globalScope
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926 self.framenr = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
928 # Massive performance gain
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
929 self.setUniformRowHeights(True)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
930
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
931 # Implements sorting and filtering
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
932 self.proxyModel = VariablesProxyModel()
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
933 # Variable model implements the underlying data model
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
934 self.varModel = VariablesModel(self, globalScope)
7012
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
935 self.preferencesChanged.connect(self.varModel.handlePreferencesChanged)
cc3f83d1a605 Colors for highlighting are configurable through Debugger->General
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6994
diff changeset
936 self.preferencesChanged.emit() # Force initialization of colors
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
937 self.proxyModel.setSourceModel(self.varModel)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
938 self.setModel(self.proxyModel)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
940 self.expanded.connect(
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
941 lambda idx: self.proxyModel.setExpanded(idx, True))
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
942 self.collapsed.connect(
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
943 lambda idx: self.proxyModel.setExpanded(idx, False))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
945 self.setExpandsOnDoubleClick(False)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
946 self.doubleClicked.connect(self.__itemDoubleClicked)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
947
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
948 self.varModel.expand.connect(self.__mdlRequestExpand)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
949
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
950 self.setSortingEnabled(True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951 self.setAlternatingRowColors(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952 self.setSelectionBehavior(QAbstractItemView.SelectRows)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953
5165
37691caeec1a Added the capability to refresh the variables viewer via the context menu.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
954 if self.__globalScope:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
955 self.setWindowTitle(self.tr("Global Variables"))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
956 self.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 """<b>The Global Variables Viewer Window</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958 """<p>This window displays the global variables"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 """ of the debugged program.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 else:
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
962 self.setWindowTitle(self.tr("Local Variables"))
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
963 self.setWhatsThis(self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 """<b>The Local Variables Viewer Window</b>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 """<p>This window displays the local variables"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966 """ of the debugged program.</p>"""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 ))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
969 header = self.header()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
970 header.setSortIndicator(0, Qt.AscendingOrder)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
971 header.setSortIndicatorShown(True)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
972
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
973 try:
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
974 header.setSectionsClickable(True)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
975 except Exception:
2094
88620e11c67c Made the seventh set of Qt5 compatibility changes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
976 header.setClickable(True)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
977
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
978 header.resizeSection(0, 130) # variable column
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
979 header.resizeSection(1, 180) # value column
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
980 header.resizeSection(2, 50) # type column
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
981
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
982 header.sortIndicatorChanged.connect(lambda *x: self.varModel.getMore())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 self.__createPopupMenus()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985 self.setContextMenuPolicy(Qt.CustomContextMenu)
458
1695e7a2db54 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 447
diff changeset
986 self.customContextMenuRequested.connect(self.__showContextMenu)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 self.resortEnabled = True
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
989
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 def showVariables(self, vlist, frmnr):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 Public method to show variables in a list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 @param vlist the list of variables to be displayed. Each
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
995 list entry is a tuple of three values.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 <ul>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997 <li>the variable name (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 <li>the variables type (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 <li>the variables value (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 </ul>
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1001 @type list
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1002 @param frmnr frame number (0 is the current frame)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1003 @type int
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1004 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1005 self.varModel.resetModifiedMarker()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1006 self.varModel.showVariables(vlist, frmnr)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1007
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1008 def showVariable(self, vlist):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 Public method to show variables in a list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
1012 @param vlist the list of subitems to be displayed.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013 The first element gives the path of the
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1014 parent variable. Each other list entry is
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 a tuple of three values.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 <ul>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017 <li>the variable name (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 <li>the variables type (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 <li>the variables value (string)</li>
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 </ul>
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1021 @type list
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1023 self.varModel.showVariables(vlist[1:], 0, vlist[0])
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1024
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1025 def handleResetUI(self):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1026 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1027 Public method to reset the VariablesViewer.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1028 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1029 self.varModel.clear(True)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1030
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1031 def verticalScrollbarValueChanged(self, value):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1032 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1033 Public slot informing about the scrollbar change.
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1034
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1035 @param value current value of the vertical scrollbar
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1036 @type int
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1037 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1038 self.varModel.getMore()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1039 super(VariablesViewer, self).verticalScrollbarValueChanged(value)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1040
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1041 def resizeEvent(self, event):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1042 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1043 Protected slot informing about the widget size change.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1045 @param event information
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1046 @type QResizeEvent
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1047 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1048 self.varModel.getMore()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1049 super(VariablesViewer, self).resizeEvent(event)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1050
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1051 def __itemDoubleClicked(self, index):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1052 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1053 Private method called if an item was double clicked.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1054
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1055 @param index the double clicked item
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1056 @type QModelIndex
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1057 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1058 node = self.proxyModel.mapToSource(index).internalPointer()
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1059 if node.hasChildren and index.column() == 0:
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1060 state = self.isExpanded(index)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1061 self.setExpanded(index, not state)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1062 else:
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1063 self.__showVariableDetails(index)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1064
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1065 def __mdlRequestExpand(self, modelIndex):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1066 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1067 Private method to inform the view about items to be expand.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1068
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1069 @param modelIndex the model index
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1070 @type QModelIndex
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1071 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1072 index = self.proxyModel.mapFromSource(modelIndex)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1073 self.expand(index)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1074
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1075 def __createPopupMenus(self):
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1076 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1077 Private method to generate the popup menus.
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1078 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1079 self.menu = QMenu()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1080 self.menu.addAction(self.tr("Show Details..."), self.__showDetails)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1081 self.menu.addSeparator()
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1082 self.menu.addAction(self.tr("Expand"), self.__expandChildren)
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1083 self.menu.addAction(self.tr("Collapse"), self.__collapseChildren)
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1084 self.menu.addAction(self.tr("Collapse All"), self.collapseAll)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1085 self.menu.addSeparator()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1086 self.menu.addAction(self.tr("Refresh"), self.__refreshView)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1087 self.menu.addSeparator()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1088 self.menu.addAction(self.tr("Configure..."), self.__configure)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1089 self.menu.addAction(self.tr("Variables Type Filter..."),
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1090 self.__configureFilter)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1092 self.backMenu = QMenu()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1093 self.backMenu.addAction(self.tr("Refresh"), self.__refreshView)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1094 self.backMenu.addSeparator()
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1095 self.backMenu.addAction(self.tr("Configure..."), self.__configure)
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1096 self.backMenu.addAction(self.tr("Variables Type Filter..."),
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1097 self.__configureFilter)
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1098
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1099 def __showContextMenu(self, coord):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1100 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1101 Private slot to show the context menu.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1102
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1103 @param coord the position of the mouse pointer
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1104 @type QPoint
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1105 """
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1106 gcoord = self.mapToGlobal(coord)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1107 if self.indexAt(coord).isValid():
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1108 self.menu.popup(gcoord)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1109 else:
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1110 self.backMenu.popup(gcoord)
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1111
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1112 def __expandChildren(self):
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953
diff changeset
1113 """
7016
47f6b0c3a293 Changed some HMI strings and corrected spelling (childs -> children)
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7015
diff changeset
1114 Private slot to expand all child items of current parent.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1115 """
6969
fd7af2312383 Reimplemented Variables Viewer using QTreeView.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 6953