Skip to content
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
28 changes: 16 additions & 12 deletions src/petab_gui/views/find_replace_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@

import qtawesome as qta
from PySide6.QtCore import Qt
from PySide6.QtGui import QAction
from PySide6.QtGui import QAction, QHideEvent, QShowEvent
from PySide6.QtWidgets import (
QCheckBox,
QHBoxLayout,
QLabel,
QLineEdit,
Expand All @@ -27,7 +26,7 @@ def __init__(self, controller, parent=None):
"Parameter Table": self.controller.parameter_controller,
"Measurement Table": self.controller.measurement_controller,
}
self.selected_controllers = set()
self.selected_controllers = self.controller_map.values()
self.only_search = False
self.matches = None

Expand Down Expand Up @@ -128,19 +127,24 @@ def __init__(self, controller, parent=None):
def run_find(self):
"""Triggered when the search text changes."""
search_text = self.find_input.text()
if not search_text:
for controller in self.controller_map.values():
controller.cleanse_highlighted_cells()
self.matches = []
self.current_match_ind = -1
self.update_result_label()
return
case_sensitive = self.case_sensitive_button.isChecked()
regex = self.regex_button.isChecked()
whole_cell = self.word_match_button.isChecked()

self.matches = []
self.current_match_ind = -1

for controller in [
self.controller.observable_controller,
self.controller.condition_controller,
self.controller.parameter_controller,
self.controller.measurement_controller,
]:
for controller in self.controller_map.values():
if controller not in self.selected_controllers:
controller.cleanse_highlighted_cells()
continue
matches = controller.find_text(
search_text, case_sensitive, regex, whole_cell
)
Expand Down Expand Up @@ -277,13 +281,13 @@ def keyPressEvent(self, event):
else:
super().keyPressEvent(event)

def hideEvent(self, event):
def hideEvent(self, event: QHideEvent):
"""Reset highlights when the Find/Replace bar is hidden."""
for controller in self.selected_controllers:
for controller in self.controller_map.values():
controller.cleanse_highlighted_cells()
super().hideEvent(event)

def showEvent(self, event):
def showEvent(self, event: QShowEvent):
"""Reset highlights when the Find/Replace bar is shown."""
# group matches by controller
if not self.matches:
Expand Down