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

Fix for #63 Add QFilterProxy to the elements table #941

Merged
merged 1 commit into from
May 22, 2023
Merged
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
24 changes: 24 additions & 0 deletions qiskit_metal/_gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down