From 82ed396924b535ad9676ee1224c684671a98ef8d Mon Sep 17 00:00:00 2001 From: Shark-y <38670127+Shark-y@users.noreply.github.com> Date: Thu, 11 May 2023 21:42:21 -0400 Subject: [PATCH] Fix for #63 Add QFilterProxy to the elements table Fix for https://github.com/Qiskit/qiskit-metal/issues/63 --- qiskit_metal/_gui/main_window.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/qiskit_metal/_gui/main_window.py b/qiskit_metal/_gui/main_window.py index 9ae011d7d..e9d4814b1 100644 --- a/qiskit_metal/_gui/main_window.py +++ b/qiskit_metal/_gui/main_window.py @@ -560,16 +560,40 @@ def _setup_elements_widget(self): """Create main Window Elements Widget.""" self.elements_win = ElementsWindow(self, self.main_window) + # Component filter self.ui.tabQGeometry.sort_model = QSortFilterProxyModel() self.ui.tabQGeometry.sort_model.setSourceModel(self.elements_win.model) + self.ui.tabQGeometry.sort_model.setFilterKeyColumn(1) self.elements_win.ui.tableElements.setModel( self.ui.tabQGeometry.sort_model) self.elements_win.ui.tableElements.setSortingEnabled(True) + # Add a text changed event to the QGeometry/Component/Layer text boxes + self.elements_win.ui.lineEdit.textChanged.connect( + self.elements_lineEdit_onChanged) + self.elements_win.ui.lineEdit_2.textChanged.connect( + self.elements_lineEdit_2_onChanged) + # Add to the tabbed main view self.ui.tabQGeometry.layout().addWidget(self.elements_win) + def elements_lineEdit_onChanged(self, text): + """ Text changed event for QGeometry/Component text box + Args: + text: Text typed in the filter box. + """ + self.ui.tabQGeometry.sort_model.setFilterKeyColumn(1) + self.ui.tabQGeometry.sort_model.setFilterWildcard(text) + + def elements_lineEdit_2_onChanged(self, text): + """ Text changed event for QGeometry/Layer text box + Args: + text: Text typed in the filter box. + """ + self.ui.tabQGeometry.sort_model.setFilterKeyColumn(3) + self.ui.tabQGeometry.sort_model.setFilterWildcard(text) + def _setup_net_list_widget(self): """Create main Window Elements Widget.""" self.net_list_win = NetListWindow(self, self.main_window)