mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-12-29 10:21:18 +01:00
feat(dm): apply shared selection signal util to view
This commit is contained in:
@@ -26,6 +26,7 @@ from bec_widgets.widgets.control.device_manager.components import (
|
||||
DMOphydTest,
|
||||
DocstringView,
|
||||
)
|
||||
from bec_widgets.widgets.control.device_manager.components._util import SharedSelectionSignal
|
||||
from bec_widgets.widgets.control.device_manager.components.available_device_resources.available_device_resources import (
|
||||
AvailableDeviceResources,
|
||||
)
|
||||
@@ -75,6 +76,8 @@ class DeviceManagerView(BECWidget, QWidget):
|
||||
def __init__(self, parent=None, *args, **kwargs):
|
||||
super().__init__(parent=parent, client=None, *args, **kwargs)
|
||||
|
||||
self._shared_selection = SharedSelectionSignal()
|
||||
|
||||
# Top-level layout hosting a toolbar and the dock manager
|
||||
self._root_layout = QVBoxLayout(self)
|
||||
self._root_layout.setContentsMargins(0, 0, 0, 0)
|
||||
@@ -83,12 +86,16 @@ class DeviceManagerView(BECWidget, QWidget):
|
||||
self._root_layout.addWidget(self.dock_manager)
|
||||
|
||||
# Available Resources Widget
|
||||
self.available_devices = AvailableDeviceResources(self)
|
||||
self.available_devices = AvailableDeviceResources(
|
||||
self, shared_selection_signal=self._shared_selection
|
||||
)
|
||||
self.available_devices_dock = QtAds.CDockWidget("Available Devices", self)
|
||||
self.available_devices_dock.setWidget(self.available_devices)
|
||||
|
||||
# Device Table View widget
|
||||
self.device_table_view = DeviceTableView(self)
|
||||
self.device_table_view = DeviceTableView(
|
||||
self, shared_selection_signal=self._shared_selection
|
||||
)
|
||||
self.device_table_view_dock = QtAds.CDockWidget("Device Table", self)
|
||||
self.device_table_view_dock.setWidget(self.device_table_view)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import copy
|
||||
import json
|
||||
from typing import List
|
||||
from uuid import uuid4
|
||||
|
||||
from bec_lib.logger import bec_logger
|
||||
from bec_qthemes import material_icon
|
||||
@@ -15,6 +16,7 @@ from bec_widgets.utils.bec_signal_proxy import BECSignalProxy
|
||||
from bec_widgets.utils.bec_widget import BECWidget
|
||||
from bec_widgets.utils.colors import get_accent_colors
|
||||
from bec_widgets.utils.error_popups import SafeSlot
|
||||
from bec_widgets.widgets.control.device_manager.components._util import SharedSelectionSignal
|
||||
from bec_widgets.widgets.control.device_manager.components.constants import MIME_DEVICE_CONFIG
|
||||
from bec_widgets.widgets.control.device_manager.components.dm_ophyd_test import ValidationStatus
|
||||
|
||||
@@ -598,9 +600,13 @@ class DeviceTableView(BECWidget, QtWidgets.QWidget):
|
||||
RPC = False
|
||||
PLUGIN = False
|
||||
|
||||
def __init__(self, parent=None, client=None):
|
||||
def __init__(self, parent=None, client=None, shared_selection_signal=SharedSelectionSignal()):
|
||||
super().__init__(client=client, parent=parent, theme_update=True)
|
||||
|
||||
self._shared_selection_signal = shared_selection_signal
|
||||
self._shared_selection_uuid = str(uuid4())
|
||||
self._shared_selection_signal.proc.connect(self._handle_shared_selection_signal)
|
||||
|
||||
self.layout = QtWidgets.QVBoxLayout(self)
|
||||
self.layout.setContentsMargins(0, 0, 0, 0)
|
||||
self.layout.setSpacing(4)
|
||||
@@ -731,6 +737,11 @@ class DeviceTableView(BECWidget, QtWidgets.QWidget):
|
||||
height = self.wrap_delegate.sizeHint(option, index).height()
|
||||
self.table.setRowHeight(row, height)
|
||||
|
||||
@SafeSlot(str)
|
||||
def _handle_shared_selection_signal(self, uuid: str):
|
||||
if uuid != self._shared_selection_uuid:
|
||||
self.table.clearSelection()
|
||||
|
||||
@SafeSlot(QtCore.QItemSelection, QtCore.QItemSelection)
|
||||
def _on_selection_changed(
|
||||
self, selected: QtCore.QItemSelection, deselected: QtCore.QItemSelection
|
||||
@@ -742,6 +753,9 @@ class DeviceTableView(BECWidget, QtWidgets.QWidget):
|
||||
selected (QtCore.QItemSelection): The selected items.
|
||||
deselected (QtCore.QItemSelection): The deselected items.
|
||||
"""
|
||||
|
||||
self._shared_selection_signal.proc.emit(self._shared_selection_uuid)
|
||||
|
||||
# TODO also hook up logic if a config update is propagated from somewhere!
|
||||
# selected_indexes = selected.indexes()
|
||||
selected_indexes = self.table.selectionModel().selectedIndexes()
|
||||
|
||||
Reference in New Issue
Block a user