eric6/Debugger/VariablesFilterDialog.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 7360
9190402e4505
child 7780
41420f82c0ac
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: 7229
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 """
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
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
10
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
11 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
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
14 from Debugger.Config import ConfigVarTypeDispStrings, ConfigVarTypeFilters
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 0
diff changeset
17 from .Ui_VariablesFilterDialog import Ui_VariablesFilterDialog
0
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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Class implementing the variables filter dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 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
25 filter to be applied during a debugging session.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
27 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
28 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param parent parent widget of this dialog (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @param name name of this dialog (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 @param modal flag to indicate a modal dialog (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
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
35 super(VariablesFilterDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 if name:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setObjectName(name)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setModal(modal)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 13
diff changeset
41 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
42 self.tr("Save Default"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
44 #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
45 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
46 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
47 itm = QListWidgetItem(self.tr(varTypeStr), widget)
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
48 itm.setData(Qt.UserRole, ConfigVarTypeFilters[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
49 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
50 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
51 widget.addItem(itm)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
53 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters()
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
54 self.setSelection(lDefaultFilter, gDefaultFilter)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 def getSelection(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 Public slot to retrieve the current selections.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
2988
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
60 @return A tuple of lists of integer values. The first list is the
f53c03574697 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
61 locals variables filter, the second the globals variables filter.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 lList = []
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
64 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
65 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
66 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
67 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
68
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
69 gList = []
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
70 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
71 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
72 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
73 gList.append(itm.data(Qt.UserRole))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 return (lList, gList)
5171
f1e9eebd5469 Continued improving the variable dumping of the debugger backends.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5166
diff changeset
75
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 def setSelection(self, lList, gList):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
78 Public slot to set the current selection.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 @param lList local variables filter (list of int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 @param gList global variables filter (list of int)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 """
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
83 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
84 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
85 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
86 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
87 else:
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
88 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
89
5166
5de86adef66d Fixed an issue populating the variables filter dialog properly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
90 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
91 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
92 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
93 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
94 else:
b0dc3f0133cd Changed the variables filter dialog to be more user friendly.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5389
diff changeset
95 itm.setCheckState(Qt.Checked)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 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
100
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 @param button button that was clicked (QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 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
104 Preferences.setVarFilters(self.getSelection())

eric ide

mercurial