eric6/Debugger/VariablesViewer.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8043
0acf98cd089a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

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