eric6/Debugger/VariablesViewer.py

Wed, 29 May 2019 22:14:02 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Wed, 29 May 2019 22:14:02 +0200
changeset 7031
6fafe9ed04b5
parent 7019
a1b25790bc5c
child 7192
a22eee00b052
permissions
-rw-r--r--

Bugfix displaying to many characters as default_factory type.
(grafted from 73779c4c135a011cd3b9600651cc1149009178b6)

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