--- a/src/eric7/Debugger/VariablesFilterDialog.py Sun Oct 02 14:46:21 2022 +0200 +++ b/src/eric7/Debugger/VariablesFilterDialog.py Mon Oct 03 12:14:28 2022 +0200 @@ -7,7 +7,7 @@ Module implementing the variables filter dialog. """ -from PyQt6.QtCore import Qt +from PyQt6.QtCore import pyqtSignal, Qt from PyQt6.QtWidgets import QDialog, QDialogButtonBox, QListWidgetItem from Debugger.Config import ConfigVarTypeDispStrings @@ -16,15 +16,21 @@ from .Ui_VariablesFilterDialog import Ui_VariablesFilterDialog -# TODO: add an Apply button to see effect of currently set filters class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog): """ Class implementing the variables filter dialog. It opens a dialog window for the configuration of the variables type - filter to be applied during a debugging session. + filters to be applied during a debugging session. Pressing 'Apply' will + show the effect of the current selection on the currently shown variables. + 'Reset' will reset the selection to the one the dialog was opened with. + + @signal applyFilterLists(list of str, list of str) emitted to apply the given + locals and globals filters to the currently shown variables """ + applyFilterLists = pyqtSignal(list, list) + def __init__(self, parent=None, name=None, modal=False): """ Constructor @@ -39,10 +45,13 @@ self.setModal(modal) self.setupUi(self) - self.defaultButton = self.buttonBox.addButton( + self.__defaultButton = self.buttonBox.addButton( self.tr("Save Default"), QDialogButtonBox.ButtonRole.ActionRole ) + self.__localsFilters = [] + self.__globalsFilters = [] + # populate the list widgets and set the default selection for widget in self.localsList, self.globalsList: for varType, varTypeStr in ConfigVarTypeDispStrings.items(): @@ -88,6 +97,9 @@ @param gList global variables filter @type list of str """ + self.__localsFilters = lList + self.__globalsFilters = gList + for row in range(self.localsList.count()): itm = self.localsList.item(row) if itm.data(Qt.ItemDataRole.UserRole) in lList: @@ -108,5 +120,9 @@ @param button button that was clicked (QAbstractButton) """ - if button == self.defaultButton: + if button == self.__defaultButton: Preferences.setVarFilters(self.getSelection()) + elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Reset): + self.setSelection(self.__localsFilters, self.__globalsFilters) + elif button == self.buttonBox.button(QDialogButtonBox.StandardButton.Apply): + self.applyFilterLists.emit(*self.getSelection())