5 |
5 |
6 """ |
6 """ |
7 Module implementing the variables filter dialog. |
7 Module implementing the variables filter dialog. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt6.QtCore import Qt |
10 from PyQt6.QtCore import pyqtSignal, Qt |
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem |
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem |
12 |
12 |
13 from Debugger.Config import ConfigVarTypeDispStrings |
13 from Debugger.Config import ConfigVarTypeDispStrings |
14 import Preferences |
14 import Preferences |
15 |
15 |
16 from .Ui_VariablesFilterDialog import Ui_VariablesFilterDialog |
16 from .Ui_VariablesFilterDialog import Ui_VariablesFilterDialog |
17 |
17 |
18 |
18 |
19 # TODO: add an Apply button to see effect of currently set filters |
|
20 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog): |
19 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog): |
21 """ |
20 """ |
22 Class implementing the variables filter dialog. |
21 Class implementing the variables filter dialog. |
23 |
22 |
24 It opens a dialog window for the configuration of the variables type |
23 It opens a dialog window for the configuration of the variables type |
25 filter to be applied during a debugging session. |
24 filters to be applied during a debugging session. Pressing 'Apply' will |
|
25 show the effect of the current selection on the currently shown variables. |
|
26 'Reset' will reset the selection to the one the dialog was opened with. |
|
27 |
|
28 @signal applyFilterLists(list of str, list of str) emitted to apply the given |
|
29 locals and globals filters to the currently shown variables |
26 """ |
30 """ |
|
31 |
|
32 applyFilterLists = pyqtSignal(list, list) |
27 |
33 |
28 def __init__(self, parent=None, name=None, modal=False): |
34 def __init__(self, parent=None, name=None, modal=False): |
29 """ |
35 """ |
30 Constructor |
36 Constructor |
31 |
37 |
37 if name: |
43 if name: |
38 self.setObjectName(name) |
44 self.setObjectName(name) |
39 self.setModal(modal) |
45 self.setModal(modal) |
40 self.setupUi(self) |
46 self.setupUi(self) |
41 |
47 |
42 self.defaultButton = self.buttonBox.addButton( |
48 self.__defaultButton = self.buttonBox.addButton( |
43 self.tr("Save Default"), QDialogButtonBox.ButtonRole.ActionRole |
49 self.tr("Save Default"), QDialogButtonBox.ButtonRole.ActionRole |
44 ) |
50 ) |
|
51 |
|
52 self.__localsFilters = [] |
|
53 self.__globalsFilters = [] |
45 |
54 |
46 # populate the list widgets and set the default selection |
55 # populate the list widgets and set the default selection |
47 for widget in self.localsList, self.globalsList: |
56 for widget in self.localsList, self.globalsList: |
48 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
57 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
49 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
58 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
86 @param lList local variables filter |
95 @param lList local variables filter |
87 @type list of str |
96 @type list of str |
88 @param gList global variables filter |
97 @param gList global variables filter |
89 @type list of str |
98 @type list of str |
90 """ |
99 """ |
|
100 self.__localsFilters = lList |
|
101 self.__globalsFilters = gList |
|
102 |
91 for row in range(self.localsList.count()): |
103 for row in range(self.localsList.count()): |
92 itm = self.localsList.item(row) |
104 itm = self.localsList.item(row) |
93 if itm.data(Qt.ItemDataRole.UserRole) in lList: |
105 if itm.data(Qt.ItemDataRole.UserRole) in lList: |
94 itm.setCheckState(Qt.CheckState.Unchecked) |
106 itm.setCheckState(Qt.CheckState.Unchecked) |
95 else: |
107 else: |
106 """ |
118 """ |
107 Private slot called by a button of the button box clicked. |
119 Private slot called by a button of the button box clicked. |
108 |
120 |
109 @param button button that was clicked (QAbstractButton) |
121 @param button button that was clicked (QAbstractButton) |
110 """ |
122 """ |
111 if button == self.defaultButton: |
123 if button == self.__defaultButton: |
112 Preferences.setVarFilters(self.getSelection()) |
124 Preferences.setVarFilters(self.getSelection()) |
|
125 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Reset): |
|
126 self.setSelection(self.__localsFilters, self.__globalsFilters) |
|
127 elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Apply): |
|
128 self.applyFilterLists.emit(*self.getSelection()) |