Skip to content

Commit

Permalink
Issue 45 q components sort filter (#939)
Browse files Browse the repository at this point in the history
* Fix for layout of the GDS/Q3D export window in the gui

Issue #549
#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.

#45

* Revert "Fix for layout of the GDS/Q3D export window in the gui"

This reverts commit a25450a.

* 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>
  • Loading branch information
Shark-y and priti-ashvin-shah-ibm authored May 8, 2023
1 parent 9342453 commit c813968
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
22 changes: 20 additions & 2 deletions qiskit_metal/_gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c813968

Please sign in to comment.