Skip to content

Commit f299d3d

Browse files
Find Highlighting (#168)
* Empty Find highlights nothing! * - Fixed bug in hideEvent - Fixed error that led to no updated when selecting specific controller
1 parent 7d6b106 commit f299d3d

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

src/petab_gui/views/find_replace_bar.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
import qtawesome as qta
55
from PySide6.QtCore import Qt
6-
from PySide6.QtGui import QAction
6+
from PySide6.QtGui import QAction, QHideEvent, QShowEvent
77
from PySide6.QtWidgets import (
8-
QCheckBox,
98
QHBoxLayout,
109
QLabel,
1110
QLineEdit,
@@ -27,7 +26,7 @@ def __init__(self, controller, parent=None):
2726
"Parameter Table": self.controller.parameter_controller,
2827
"Measurement Table": self.controller.measurement_controller,
2928
}
30-
self.selected_controllers = set()
29+
self.selected_controllers = self.controller_map.values()
3130
self.only_search = False
3231
self.matches = None
3332

@@ -128,19 +127,24 @@ def __init__(self, controller, parent=None):
128127
def run_find(self):
129128
"""Triggered when the search text changes."""
130129
search_text = self.find_input.text()
130+
if not search_text:
131+
for controller in self.controller_map.values():
132+
controller.cleanse_highlighted_cells()
133+
self.matches = []
134+
self.current_match_ind = -1
135+
self.update_result_label()
136+
return
131137
case_sensitive = self.case_sensitive_button.isChecked()
132138
regex = self.regex_button.isChecked()
133139
whole_cell = self.word_match_button.isChecked()
134140

135141
self.matches = []
136142
self.current_match_ind = -1
137143

138-
for controller in [
139-
self.controller.observable_controller,
140-
self.controller.condition_controller,
141-
self.controller.parameter_controller,
142-
self.controller.measurement_controller,
143-
]:
144+
for controller in self.controller_map.values():
145+
if controller not in self.selected_controllers:
146+
controller.cleanse_highlighted_cells()
147+
continue
144148
matches = controller.find_text(
145149
search_text, case_sensitive, regex, whole_cell
146150
)
@@ -277,13 +281,13 @@ def keyPressEvent(self, event):
277281
else:
278282
super().keyPressEvent(event)
279283

280-
def hideEvent(self, event):
284+
def hideEvent(self, event: QHideEvent):
281285
"""Reset highlights when the Find/Replace bar is hidden."""
282-
for controller in self.selected_controllers:
286+
for controller in self.controller_map.values():
283287
controller.cleanse_highlighted_cells()
284288
super().hideEvent(event)
285289

286-
def showEvent(self, event):
290+
def showEvent(self, event: QShowEvent):
287291
"""Reset highlights when the Find/Replace bar is shown."""
288292
# group matches by controller
289293
if not self.matches:

0 commit comments

Comments
 (0)