Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 45 q components sort filter #939

Merged
merged 6 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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