Skip to content

Commit

Permalink
catalogue: refresh/reload catalogue upon predicate change
Browse files Browse the repository at this point in the history
  • Loading branch information
pboettch authored and jeandet committed May 28, 2024
1 parent 3074d52 commit f16fef1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tscat_gui/tscat_driver/catalog_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from PySide6.QtCore import QAbstractTableModel, QMimeData, QModelIndex, QPersistentModelIndex, Qt
from PySide6.QtGui import QColor

from tscat import _Event
from tscat import _Event, _Catalogue
from .actions import Action, AddEventsToCatalogueAction, DeleteAttributeAction, DeletePermanentlyAction, \
GetCatalogueAction, MoveToTrashAction, RemoveEntitiesAction, RemoveEventsFromCatalogueAction, \
RestoreFromTrashAction, RestorePermanentlyDeletedAction, SetAttributeAction
Expand Down Expand Up @@ -46,6 +46,11 @@ def _driver_action_done(self, action: Action) -> None:
index_right = self.index(row, self.columnCount() - 1, QModelIndex())
self.dataChanged.emit(index_left, index_right) # type: ignore

if action.name == 'predicate':
for c in filter(lambda x: isinstance(x, _Catalogue), action.entities):
if c.uuid == self._root.uuid:
self.refresh()

elif isinstance(action, AddEventsToCatalogueAction):
if action.catalogue_uuid == self._root.uuid:
nodes = list(map(lambda x: EventNode(x, True), map(tscat_driver.event_from_uuid, action.uuids)))
Expand Down Expand Up @@ -120,6 +125,9 @@ def _driver_action_done(self, action: Action) -> None:
self._root.append_children(nodes)
self.endInsertRows()

def refresh(self):
tscat_driver.do(GetCatalogueAction(None, self._root.uuid))

def headerData(self, section: int, orientation: Qt.Orientation,
role: int = Qt.DisplayRole) -> Any: # type: ignore
if orientation == Qt.Orientation.Horizontal:
Expand Down

0 comments on commit f16fef1

Please sign in to comment.