Skip to content

Commit

Permalink
Fix for #63 Add QFilterProxy to the elements table (#941)
Browse files Browse the repository at this point in the history
Fix for #63
  • Loading branch information
Shark-y authored May 22, 2023
1 parent 99811f1 commit 3e03a52
Showing 1 changed file with 24 additions and 0 deletions.
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

0 comments on commit 3e03a52

Please sign in to comment.