17 |
17 |
18 |
18 |
19 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog): |
19 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog): |
20 """ |
20 """ |
21 Class implementing the variables filter dialog. |
21 Class implementing the variables filter dialog. |
22 |
22 |
23 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 |
24 filter to be applied during a debugging session. |
24 filter to be applied during a debugging session. |
25 """ |
25 """ |
|
26 |
26 def __init__(self, parent=None, name=None, modal=False): |
27 def __init__(self, parent=None, name=None, modal=False): |
27 """ |
28 """ |
28 Constructor |
29 Constructor |
29 |
30 |
30 @param parent parent widget of this dialog (QWidget) |
31 @param parent parent widget of this dialog (QWidget) |
31 @param name name of this dialog (string) |
32 @param name name of this dialog (string) |
32 @param modal flag to indicate a modal dialog (boolean) |
33 @param modal flag to indicate a modal dialog (boolean) |
33 """ |
34 """ |
34 super().__init__(parent) |
35 super().__init__(parent) |
36 self.setObjectName(name) |
37 self.setObjectName(name) |
37 self.setModal(modal) |
38 self.setModal(modal) |
38 self.setupUi(self) |
39 self.setupUi(self) |
39 |
40 |
40 self.defaultButton = self.buttonBox.addButton( |
41 self.defaultButton = self.buttonBox.addButton( |
41 self.tr("Save Default"), QDialogButtonBox.ButtonRole.ActionRole) |
42 self.tr("Save Default"), QDialogButtonBox.ButtonRole.ActionRole |
42 |
43 ) |
43 #populate the list widgets and set the default selection |
44 |
|
45 # populate the list widgets and set the default selection |
44 for widget in self.localsList, self.globalsList: |
46 for widget in self.localsList, self.globalsList: |
45 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
47 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
46 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
48 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
47 itm.setData(Qt.ItemDataRole.UserRole, varType) |
49 itm.setData(Qt.ItemDataRole.UserRole, varType) |
48 itm.setFlags(Qt.ItemFlag.ItemIsEnabled | |
50 itm.setFlags( |
49 Qt.ItemFlag.ItemIsUserCheckable) |
51 Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsUserCheckable |
|
52 ) |
50 itm.setCheckState(Qt.CheckState.Unchecked) |
53 itm.setCheckState(Qt.CheckState.Unchecked) |
51 widget.addItem(itm) |
54 widget.addItem(itm) |
52 |
55 |
53 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters() |
56 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters() |
54 self.setSelection(lDefaultFilter, gDefaultFilter) |
57 self.setSelection(lDefaultFilter, gDefaultFilter) |
55 |
58 |
56 def getSelection(self): |
59 def getSelection(self): |
57 """ |
60 """ |
58 Public slot to retrieve the current selections. |
61 Public slot to retrieve the current selections. |
59 |
62 |
60 @return tuple of lists containing the variable filters. The first list |
63 @return tuple of lists containing the variable filters. The first list |
61 is the locals variables filter, the second the globals variables |
64 is the locals variables filter, the second the globals variables |
62 filter. |
65 filter. |
63 @rtype tuple of (list of str, list of str) |
66 @rtype tuple of (list of str, list of str) |
64 """ |
67 """ |
65 lList = [] |
68 lList = [] |
66 for row in range(self.localsList.count()): |
69 for row in range(self.localsList.count()): |
67 itm = self.localsList.item(row) |
70 itm = self.localsList.item(row) |
68 if itm.checkState() == Qt.CheckState.Unchecked: |
71 if itm.checkState() == Qt.CheckState.Unchecked: |
69 lList.append(itm.data(Qt.ItemDataRole.UserRole)) |
72 lList.append(itm.data(Qt.ItemDataRole.UserRole)) |
70 |
73 |
71 gList = [] |
74 gList = [] |
72 for row in range(self.globalsList.count()): |
75 for row in range(self.globalsList.count()): |
73 itm = self.globalsList.item(row) |
76 itm = self.globalsList.item(row) |
74 if itm.checkState() == Qt.CheckState.Unchecked: |
77 if itm.checkState() == Qt.CheckState.Unchecked: |
75 gList.append(itm.data(Qt.ItemDataRole.UserRole)) |
78 gList.append(itm.data(Qt.ItemDataRole.UserRole)) |
76 return (lList, gList) |
79 return (lList, gList) |
77 |
80 |
78 def setSelection(self, lList, gList): |
81 def setSelection(self, lList, gList): |
79 """ |
82 """ |
80 Public slot to set the current selection. |
83 Public slot to set the current selection. |
81 |
84 |
82 @param lList local variables filter |
85 @param lList local variables filter |
83 @type list of str |
86 @type list of str |
84 @param gList global variables filter |
87 @param gList global variables filter |
85 @type list of str |
88 @type list of str |
86 """ |
89 """ |
88 itm = self.localsList.item(row) |
91 itm = self.localsList.item(row) |
89 if itm.data(Qt.ItemDataRole.UserRole) in lList: |
92 if itm.data(Qt.ItemDataRole.UserRole) in lList: |
90 itm.setCheckState(Qt.CheckState.Unchecked) |
93 itm.setCheckState(Qt.CheckState.Unchecked) |
91 else: |
94 else: |
92 itm.setCheckState(Qt.CheckState.Checked) |
95 itm.setCheckState(Qt.CheckState.Checked) |
93 |
96 |
94 for row in range(self.globalsList.count()): |
97 for row in range(self.globalsList.count()): |
95 itm = self.globalsList.item(row) |
98 itm = self.globalsList.item(row) |
96 if itm.data(Qt.ItemDataRole.UserRole) in gList: |
99 if itm.data(Qt.ItemDataRole.UserRole) in gList: |
97 itm.setCheckState(Qt.CheckState.Unchecked) |
100 itm.setCheckState(Qt.CheckState.Unchecked) |
98 else: |
101 else: |
99 itm.setCheckState(Qt.CheckState.Checked) |
102 itm.setCheckState(Qt.CheckState.Checked) |
100 |
103 |
101 def on_buttonBox_clicked(self, button): |
104 def on_buttonBox_clicked(self, button): |
102 """ |
105 """ |
103 Private slot called by a button of the button box clicked. |
106 Private slot called by a button of the button box clicked. |
104 |
107 |
105 @param button button that was clicked (QAbstractButton) |
108 @param button button that was clicked (QAbstractButton) |
106 """ |
109 """ |
107 if button == self.defaultButton: |
110 if button == self.defaultButton: |
108 Preferences.setVarFilters(self.getSelection()) |
111 Preferences.setVarFilters(self.getSelection()) |