@@ -18,6 +18,7 @@ class Category:
1818 label : str
1919 items : List [Item ]
2020 widget : QComboBox
21+ selected_item_text : str = ""
2122
2223
2324class FilterManager (QObject ):
@@ -26,6 +27,7 @@ class FilterManager(QObject):
2627 itemSelectionChanged = pyqtSignal (QComboBox , int )
2728 itemeSelected = pyqtSignal ()
2829 filteredItemsUpdated = pyqtSignal (QComboBox , list )
30+ filterCleaned = pyqtSignal (QComboBox , str )
2931 searchQueryUpdated = pyqtSignal (str )
3032
3133 def __init__ (self ):
@@ -43,7 +45,7 @@ def change_category_items(self, id: int, new_items: List[Item]) -> None:
4345 for category in self .categories :
4446 if category .id == id :
4547 category .items = new_items
46-
48+
4749 def toggle_filter_mode (self ) -> None :
4850 """Toggle filter mode."""
4951 self .active = not self .active
@@ -66,6 +68,7 @@ def navigate_items(self, direction: int) -> None:
6668 current_index = combo_box .currentIndex ()
6769 new_index = max (0 , min (combo_box .count () - 1 , current_index + direction ))
6870 self .itemSelectionChanged .emit (combo_box , new_index )
71+ active_category .selected_item_text = combo_box .currentText ()
6972
7073 def filter_items (self , char : str ):
7174 """Filter items in the active category based on the search query."""
@@ -94,14 +97,14 @@ def clear_filters(self):
9497 for category in self .categories :
9598 combo_box = category .widget
9699 self .filteredItemsUpdated .emit (combo_box , category .items )
100+ self .filterCleaned .emit (combo_box , category .selected_item_text )
97101
98102 def handle_key_press (self , event : QKeyEvent ) -> bool :
99103 """Handle key press events."""
100104 if event .modifiers () == Qt .ControlModifier and event .key () == Qt .Key_F :
101105 self .toggle_filter_mode ()
102106 return True
103107 elif self .active :
104- print (event .key () == Qt .Key .Key_Up )
105108 if event .key () == Qt .Key .Key_Left :
106109 self .switch_category (- 1 )
107110 return True
@@ -132,6 +135,7 @@ def handle_key_press(self, event: QKeyEvent) -> bool:
132135 elif event .key () in (Qt .Key .Key_Return , Qt .Key .Key_Enter ):
133136 self .itemeSelected .emit ()
134137 self .toggle_filter_mode ()
138+ return True
135139 elif event .key () == Qt .Key .Key_Escape :
136140 self .toggle_filter_mode ()
137141 return True
0 commit comments