5 |
5 |
6 """ |
6 """ |
7 Module implementing the variables viewer view based on QTreeView. |
7 Module implementing the variables viewer view based on QTreeView. |
8 """ |
8 """ |
9 |
9 |
10 |
|
11 import ast |
10 import ast |
12 |
11 import re |
13 from PyQt5.QtCore import (Qt, QAbstractItemModel, QModelIndex, QRegExp, |
12 |
14 QCoreApplication, QSortFilterProxyModel, pyqtSignal) |
13 from PyQt5.QtCore import ( |
|
14 Qt, QAbstractItemModel, QModelIndex, QCoreApplication, |
|
15 QSortFilterProxyModel, pyqtSignal |
|
16 ) |
15 from PyQt5.QtGui import QBrush, QFontMetrics |
17 from PyQt5.QtGui import QBrush, QFontMetrics |
16 from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu |
18 from PyQt5.QtWidgets import QTreeView, QAbstractItemView, QToolTip, QMenu |
17 |
19 |
18 from E5Gui.E5Application import e5App |
20 from E5Gui.E5Application import e5App |
19 |
21 |
39 'frozenset': '{}', # __IGNORE_WARNING_M613__ |
41 'frozenset': '{}', # __IGNORE_WARNING_M613__ |
40 'numpy.ndarray': '[ndarray]', # __IGNORE_WARNING_M613__ |
42 'numpy.ndarray': '[ndarray]', # __IGNORE_WARNING_M613__ |
41 } |
43 } |
42 |
44 |
43 # Initialize regular expression for unprintable strings |
45 # Initialize regular expression for unprintable strings |
44 rx_nonprintable = QRegExp(r"""(\\x\d\d)+""") |
46 rx_nonprintable = re.compile(r"""(\\x\d\d)+""") |
45 |
47 |
46 noOfItemsStr = QCoreApplication.translate("VariablesViewer", "{0} items") |
48 noOfItemsStr = QCoreApplication.translate("VariablesViewer", "{0} items") |
47 unsized = QCoreApplication.translate("VariablesViewer", "unsized") |
49 unsized = QCoreApplication.translate("VariablesViewer", "unsized") |
48 |
50 |
49 arrayTypes = { |
51 arrayTypes = { |
192 |
194 |
193 elif dtype == "Shiboken.EnumType": |
195 elif dtype == "Shiboken.EnumType": |
194 self.hasChildren = True |
196 self.hasChildren = True |
195 |
197 |
196 elif dtype in ['str', 'unicode']: |
198 elif dtype in ['str', 'unicode']: |
197 if VariableItem.rx_nonprintable.indexIn(dvalue) == -1: |
199 if VariableItem.rx_nonprintable.search(dvalue) is None: |
198 try: |
200 try: |
199 dvalue = ast.literal_eval(dvalue) |
201 dvalue = ast.literal_eval(dvalue) |
200 except Exception: # secok |
202 except Exception: # secok |
201 pass |
203 pass |
202 dvalue = str(dvalue) |
204 dvalue = str(dvalue) |