mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added quick filter input for items
This commit is contained in:
parent
c34e3bb15e
commit
93c2e1ad90
1 changed files with 25 additions and 0 deletions
|
|
@ -300,6 +300,12 @@ class FilterValueItemsView(QtWidgets.QWidget):
|
|||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
|
||||
filter_input = QtWidgets.QLineEdit(self)
|
||||
|
||||
filter_timeout = QtCore.QTimer(self)
|
||||
filter_timeout.setSingleShot(True)
|
||||
filter_timeout.setInterval(20)
|
||||
|
||||
scroll_area = QtWidgets.QScrollArea(self)
|
||||
scroll_area.setObjectName("ScrollArea")
|
||||
srcoll_viewport = scroll_area.viewport()
|
||||
|
|
@ -310,6 +316,7 @@ class FilterValueItemsView(QtWidgets.QWidget):
|
|||
|
||||
content_widget = QtWidgets.QWidget(scroll_area)
|
||||
content_widget.setObjectName("ContentWidget")
|
||||
|
||||
content_layout = QtWidgets.QVBoxLayout(content_widget)
|
||||
content_layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
|
|
@ -331,19 +338,31 @@ class FilterValueItemsView(QtWidgets.QWidget):
|
|||
|
||||
main_layout = QtWidgets.QVBoxLayout(self)
|
||||
main_layout.setContentsMargins(0, 0, 0, 0)
|
||||
main_layout.addWidget(filter_input, 0)
|
||||
main_layout.addWidget(scroll_area)
|
||||
main_layout.addWidget(btns_widget, 0)
|
||||
|
||||
filter_timeout.timeout.connect(self._on_filter_timeout)
|
||||
filter_input.textChanged.connect(self._on_filter_change)
|
||||
select_all_btn.clicked.connect(self._on_select_all)
|
||||
clear_btn.clicked.connect(self._on_clear_selection)
|
||||
swap_btn.clicked.connect(self._on_swap_selection)
|
||||
|
||||
self._filter_timeout = filter_timeout
|
||||
self._filter_input = filter_input
|
||||
self._btns_widget = btns_widget
|
||||
self._multiselection = False
|
||||
self._content_layout = content_layout
|
||||
self._last_selected_widget = None
|
||||
self._widgets_by_id = {}
|
||||
|
||||
def showEvent(self, event):
|
||||
super().showEvent(event)
|
||||
self._filter_timeout.start()
|
||||
|
||||
def _on_filter_timeout(self):
|
||||
self._filter_input.setFocus()
|
||||
|
||||
def set_value(self, value):
|
||||
current_value = self.get_value()
|
||||
if self._multiselection:
|
||||
|
|
@ -453,6 +472,12 @@ class FilterValueItemsView(QtWidgets.QWidget):
|
|||
self._btns_widget.setVisible(self._multiselection)
|
||||
self._content_layout.addStretch(1)
|
||||
|
||||
def _on_filter_change(self, text):
|
||||
text = text.lower()
|
||||
for widget in self._widgets_by_id.values():
|
||||
visible = not text or text in widget.get_value().lower()
|
||||
widget.setVisible(visible)
|
||||
|
||||
def _on_select_all(self):
|
||||
changed = False
|
||||
for widget in self._widgets_by_id.values():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue