mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 11:41:49 +02:00
wip fix tests fixup
This commit is contained in:
@ -147,7 +147,7 @@ class ScanHistoryDeviceViewer(BECWidget, QtWidgets.QWidget):
|
|||||||
main_layout.addWidget(widget)
|
main_layout.addWidget(widget)
|
||||||
main_layout.addWidget(self.request_plotting_button)
|
main_layout.addWidget(self.request_plotting_button)
|
||||||
|
|
||||||
@SafeSlot()
|
@SafeSlot(object)
|
||||||
def update_devices_from_scan_history(self, msg: ScanHistoryMessage) -> None:
|
def update_devices_from_scan_history(self, msg: ScanHistoryMessage) -> None:
|
||||||
"""Update the device combo box with the scan history message.
|
"""Update the device combo box with the scan history message.
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ class ScanHistoryDeviceViewer(BECWidget, QtWidgets.QWidget):
|
|||||||
self.signal_combo.setCurrentIndex(index)
|
self.signal_combo.setCurrentIndex(index)
|
||||||
|
|
||||||
@SafeSlot()
|
@SafeSlot()
|
||||||
def clear_view(self, msg: ScanHistoryMessage | None = None) -> None:
|
def clear_view(self) -> None:
|
||||||
"""Clear the device combo box."""
|
"""Clear the device combo box."""
|
||||||
self.scan_history_msg = None
|
self.scan_history_msg = None
|
||||||
self.signal_model.signals = {}
|
self.signal_model.signals = {}
|
||||||
|
@ -113,7 +113,7 @@ class ScanHistoryMetadataViewer(BECWidget, QtWidgets.QGroupBox):
|
|||||||
)
|
)
|
||||||
layout.addWidget(copy_button, row, 2)
|
layout.addWidget(copy_button, row, 2)
|
||||||
|
|
||||||
@SafeSlot()
|
@SafeSlot(object)
|
||||||
def update_view(self, msg: ScanHistoryMessage):
|
def update_view(self, msg: ScanHistoryMessage):
|
||||||
"""
|
"""
|
||||||
Update the view with the given ScanHistoryMessage.
|
Update the view with the given ScanHistoryMessage.
|
||||||
@ -155,7 +155,7 @@ class ScanHistoryMetadataViewer(BECWidget, QtWidgets.QGroupBox):
|
|||||||
layout.itemAtPosition(row, 2).widget().setToolTip("")
|
layout.itemAtPosition(row, 2).widget().setToolTip("")
|
||||||
|
|
||||||
@SafeSlot()
|
@SafeSlot()
|
||||||
def clear_view(self, msg: ScanHistoryMessage | None = None):
|
def clear_view(self):
|
||||||
"""
|
"""
|
||||||
Clear the view by resetting the labels and values.
|
Clear the view by resetting the labels and values.
|
||||||
"""
|
"""
|
||||||
|
@ -19,7 +19,7 @@ class ScanHistoryView(BECWidget, QtWidgets.QTreeWidget):
|
|||||||
PLUGIN = False
|
PLUGIN = False
|
||||||
|
|
||||||
scan_selected = QtCore.Signal(object)
|
scan_selected = QtCore.Signal(object)
|
||||||
scan_removed = QtCore.Signal(object)
|
no_scan_selected = QtCore.Signal()
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -105,7 +105,7 @@ class ScanHistoryView(BECWidget, QtWidgets.QTreeWidget):
|
|||||||
slot=self.update_history, topics=MessageEndpoints.scan_history(), from_start=True
|
slot=self.update_history, topics=MessageEndpoints.scan_history(), from_start=True
|
||||||
)
|
)
|
||||||
|
|
||||||
@SafeSlot()
|
@SafeSlot(dict, dict)
|
||||||
def update_history(self, msg_content: dict, metdata: dict):
|
def update_history(self, msg_content: dict, metdata: dict):
|
||||||
"""Update the scan history with new scan data."""
|
"""Update the scan history with new scan data."""
|
||||||
# TODO directly receive ScanHistoryMessage through dispatcher
|
# TODO directly receive ScanHistoryMessage through dispatcher
|
||||||
@ -162,7 +162,7 @@ class ScanHistoryView(BECWidget, QtWidgets.QTreeWidget):
|
|||||||
index = len(self.scan_history) + index
|
index = len(self.scan_history) + index
|
||||||
try:
|
try:
|
||||||
msg = self.scan_history.pop(index)
|
msg = self.scan_history.pop(index)
|
||||||
self.scan_removed.emit(msg)
|
self.no_scan_selected.emit()
|
||||||
except IndexError:
|
except IndexError:
|
||||||
logger.warning(f"Invalid index {index} for removing scan entry from history.")
|
logger.warning(f"Invalid index {index} for removing scan entry from history.")
|
||||||
return
|
return
|
||||||
@ -199,8 +199,8 @@ if __name__ == "__main__": # pragma: no cover
|
|||||||
layout.addWidget(device_viewer)
|
layout.addWidget(device_viewer)
|
||||||
browser.scan_selected.connect(view.update_view)
|
browser.scan_selected.connect(view.update_view)
|
||||||
browser.scan_selected.connect(device_viewer.update_devices_from_scan_history)
|
browser.scan_selected.connect(device_viewer.update_devices_from_scan_history)
|
||||||
browser.scan_removed.connect(view.clear_view)
|
browser.no_scan_selected.connect(view.clear_view)
|
||||||
browser.scan_removed.connect(device_viewer.clear_view)
|
browser.no_scan_selected.connect(device_viewer.clear_view)
|
||||||
|
|
||||||
main_window.show()
|
main_window.show()
|
||||||
app.exec_()
|
app.exec_()
|
||||||
|
@ -85,8 +85,10 @@ class ScanHistoryBrowser(BECWidget, QtWidgets.QWidget):
|
|||||||
self.scan_history_view.scan_selected.connect(
|
self.scan_history_view.scan_selected.connect(
|
||||||
self.scan_history_device_viewer.update_devices_from_scan_history
|
self.scan_history_device_viewer.update_devices_from_scan_history
|
||||||
)
|
)
|
||||||
self.scan_history_view.scan_removed.connect(self.scan_history_metadata_viewer.clear_view)
|
self.scan_history_view.no_scan_selected.connect(
|
||||||
self.scan_history_view.scan_removed.connect(self.scan_history_device_viewer.clear_view)
|
self.scan_history_metadata_viewer.clear_view
|
||||||
|
)
|
||||||
|
self.scan_history_view.no_scan_selected.connect(self.scan_history_device_viewer.clear_view)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__": # pragma: no cover
|
if __name__ == "__main__": # pragma: no cover
|
||||||
|
@ -229,7 +229,7 @@ def test_scan_history_view_add_remove_scan(qtbot, scan_history_view, scan_histor
|
|||||||
|
|
||||||
# remove scan
|
# remove scan
|
||||||
def remove_callback(msg):
|
def remove_callback(msg):
|
||||||
"""Callback to check if the scan_removed signal is emitted."""
|
"""Callback to check if the no_scan_selected signal is emitted."""
|
||||||
assert msg == scan_history_msg
|
assert msg == scan_history_msg
|
||||||
|
|
||||||
scan_history_view.remove_scan(0)
|
scan_history_view.remove_scan(0)
|
||||||
|
Reference in New Issue
Block a user