eric6/Debugger/VariablesFilterDialog.py

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

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

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

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7862
diff changeset
3 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing the variables filter dialog.
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
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
10 from PyQt5.QtCore import Qt
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
7862
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
13 from Debugger.Config import ConfigVarTypeDispStrings
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
16 from .Ui_VariablesFilterDialog import Ui_VariablesFilterDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 Class implementing the variables filter dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 It opens a dialog window for the configuration of the variables type
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 filter to be applied during a debugging session.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
26 def __init__(self, parent=None, name=None, modal=False):
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 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @param parent parent widget of this dialog (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param name name of this dialog (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param modal flag to indicate a modal dialog (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
34 super(VariablesFilterDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 if name:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setObjectName(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setModal(modal)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
40 self.defaultButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
41 self.tr("Save Default"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
43 #populate the list widgets and set the default selection
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
44 for widget in self.localsList, self.globalsList:
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
45 for varType, varTypeStr in ConfigVarTypeDispStrings.items():
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
46 itm = QListWidgetItem(self.tr(varTypeStr), widget)
7862
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
47 itm.setData(Qt.UserRole, varType)
5479
c7d8a0cdc731 Fixed an issue in the variables filter dialog related to Qt 4.8.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5461
diff changeset
48 itm.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
5461
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
49 itm.setCheckState(Qt.Unchecked)
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
50 widget.addItem(itm)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
52 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters()
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
53 self.setSelection(lDefaultFilter, gDefaultFilter)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 def getSelection(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 Public slot to retrieve the current selections.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58
7862
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
59 @return tuple of lists containing the variable filters. The first list
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
60 is the locals variables filter, the second the globals variables
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
61 filter.
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
62 @rtype tuple of (list of str, list of str)
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 lList = []
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
65 for row in range(self.localsList.count()):
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
66 itm = self.localsList.item(row)
5461
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
67 if itm.checkState() == Qt.Unchecked:
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
68 lList.append(itm.data(Qt.UserRole))
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
69
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
70 gList = []
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
71 for row in range(self.globalsList.count()):
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
72 itm = self.globalsList.item(row)
5461
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
73 if itm.checkState() == Qt.Unchecked:
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
74 gList.append(itm.data(Qt.UserRole))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 return (lList, gList)
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
76
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 def setSelection(self, lList, gList):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
79 Public slot to set the current selection.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80
7862
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
81 @param lList local variables filter
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
82 @type list of str
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
83 @param gList global variables filter
817ef8e0fa66 Debugger: changed the handling of variable type filters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7780
diff changeset
84 @type list of str
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85 """
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
86 for row in range(self.localsList.count()):
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
87 itm = self.localsList.item(row)
5461
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
88 if itm.data(Qt.UserRole) in lList:
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
89 itm.setCheckState(Qt.Unchecked)
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
90 else:
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
91 itm.setCheckState(Qt.Checked)
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
92
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
93 for row in range(self.globalsList.count()):
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
94 itm = self.globalsList.item(row)
5461
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
95 if itm.data(Qt.UserRole) in gList:
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
96 itm.setCheckState(Qt.Unchecked)
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
97 else:
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
98 itm.setCheckState(Qt.Checked)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 Private slot called by a button of the button box clicked.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 if button == self.defaultButton:
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
107 Preferences.setVarFilters(self.getSelection())

eric ide

mercurial