eric6/Debugger/VariablesViewer.py

Sun, 02 Feb 2020 11:04:32 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 02 Feb 2020 11:04:32 +0100
changeset 7380
c99320e859ca
parent 7366
bd743eacfbca
child 7379
72a72fd56494
child 7628
f904d0eef264
permissions
-rw-r--r--

Fixed an issue related to showing the application name in the menu bar of Gnome desktop under Wayland.

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