Source code for schrodinger.application.livedesign.maestro_sync
from schrodinger.maestro_utils import maestro_sync
from schrodinger.project import utils as proj_utils
from schrodinger.Qt import QtCore
[docs]class EntrySelectionMaestroSync(maestro_sync.BaseMaestroSync, QtCore.QObject):
"""
Keep track of the project entry selection state. If it changes, emit a
signal.
"""
entrySelectionChanged = QtCore.pyqtSignal()
[docs] def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._selected_eids = set()
[docs] def onProjectUpdated(self):
super().onProjectUpdated()
if self.updateSelectedEntries():
self.entrySelectionChanged.emit()
[docs] def updateSelectedEntries(self):
"""
Update the cached list of selected entry IDs with the current set of
selected entry IDs in the project.
:return: whether the cached entry ID list needed to be updated
:rtype: bool
"""
selected_eids = set(proj_utils.get_selected_entry_ids())
if self._selected_eids != selected_eids:
self._selected_eids = selected_eids
return True
return False