From c813968c0318343ddddd65c24622afd829fa582b Mon Sep 17 00:00:00 2001 From: Sharky <38670127+Shark-y@users.noreply.github.com> Date: Mon, 8 May 2023 17:24:22 -0400 Subject: [PATCH] Issue 45 q components sort filter (#939) * Fix for layout of the GDS/Q3D export window in the gui Issue #549 https://github.com/Qiskit/qiskit-metal/issues/549 The scaling for the GDS/Q3D/HFSS dialogs should be fixed now. * Fix for QComponents Widget Sort & Filter Wrapped the The components table in a QSortFilterProxyModel for sorting, filtering, plus Added a textChanged event to the filter box to display only specific items. https://github.com/Qiskit/qiskit-metal/issues/45 * Revert "Fix for layout of the GDS/Q3D export window in the gui" This reverts commit a25450a40f7033e65fd64f07de5d68c2a0eaa45a. * Update for lint test failures Run yapf on all files plus a few method updates in the filter/sort logic. --------- Co-authored-by: Priti Ashvin Shah <74020801+priti-ashvin-shah-ibm@users.noreply.github.com> --- qiskit_metal/_gui/main_window.py | 22 +++++++++++++++++-- .../table_view_all_components.py | 6 ++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/qiskit_metal/_gui/main_window.py b/qiskit_metal/_gui/main_window.py index f68c9a225..124da7a05 100644 --- a/qiskit_metal/_gui/main_window.py +++ b/qiskit_metal/_gui/main_window.py @@ -593,7 +593,25 @@ def _setup_design_components_widget(self): model = QTableModel_AllComponents(self, logger=self.logger, tableView=self.ui.tableComponents) - self.ui.tableComponents.setModel(model) + # Add Sort/Filter logic to the components table + self.ui.proxyModel = QSortFilterProxyModel() + self.ui.proxyModel.setSourceModel(model) + + # search all columns + self.ui.proxyModel.setFilterKeyColumn(-1) + self.ui.tableComponents.setSortingEnabled(True) + self.ui.tableComponents.setModel(self.ui.proxyModel) + + # Add a text changed event to the filter text box + self.ui.filter_text_design.textChanged.connect( + self.filter_text_design_onChanged) + + def filter_text_design_onChanged(self, text): + """ Text changed event for filter_text_design + Args: + text: Text typed in the filter box. + """ + self.ui.proxyModel.setFilterWildcard(text) def _create_new_component_object_from_qlibrary(self, full_path: str): """ @@ -743,7 +761,7 @@ def refresh(self): self.refresh_design() # Table models - self.ui.tableComponents.model().refresh() + self.ui.tableComponents.model().sourceModel().refresh() # Redraw plots self.refresh_plot() diff --git a/qiskit_metal/_gui/widgets/all_components/table_view_all_components.py b/qiskit_metal/_gui/widgets/all_components/table_view_all_components.py index 7a717b9db..1ca330583 100644 --- a/qiskit_metal/_gui/widgets/all_components/table_view_all_components.py +++ b/qiskit_metal/_gui/widgets/all_components/table_view_all_components.py @@ -75,17 +75,17 @@ def style2(self): @property def design(self): """Returns the design.""" - return self.model().design + return self.model().sourceModel().design @property def logger(self): """Returns the logger.""" - return self.model().logger + return self.model().sourceModel().logger @property def gui(self) -> 'MetalGUI': """Returns the GUI.""" - return self.model().gui + return self.model().sourceModel().gui # @slot_catch_error def contextMenuEvent(self, event: QContextMenuEvent):