from__future__importannotationsfromtypingimportCollection,Iterable,Protocol,runtime_checkablefromgaphas.connectionsimportConnectionsfromgaphas.itemimportItem@runtime_checkableclassView(Protocol):defrequest_update(self,items:Collection[Item],matrix_only_items:Collection[Item],removed_items:Collection[Item],)->None:"""Propagate update requests to the view. By invoking this method, the View will be made aware of state changes, that will either: 1. Cause the item to be fully updated 2. Just cause the item to move, without any further updates. """
[docs]@runtime_checkableclassModel(Protocol):"""Any class that adhere's to the Model protocol can be used as a model for GtkView."""@propertydefconnections(self)->Connections:"""The connections instance used for this model."""
[docs]defget_all_items(self)->Iterable[Item]:"""Iterate over all items in the order they need to be rendered in. Normally that will be depth-first. """
[docs]defget_parent(self,item:Item)->Item|None:"""Get the parent item of an item. Returns ``None`` if there is no parent item. """
[docs]defget_children(self,item:Item|None)->Iterable[Item]:"""Iterate all direct child items of an item."""
[docs]defsort(self,items:Collection[Item])->Iterable[Item]:"""Sort a collection of items in the order they need to be rendered in."""
[docs]defrequest_update(self,item:Item)->None:"""Request update for an item. Arguments: item (Item): The item to be updated """
[docs]defupdate_now(self,dirty_items:Collection[Item])->None:"""This method is called during the update process. It will allow the model to do some additional updating of it's own. """
[docs]defregister_view(self,view:View)->None:"""Allow a view to be registered. Registered views should receive update requests for modified items. """
[docs]defunregister_view(self,view:View)->None:"""Unregister a previously registered view. If a view is not registered, nothing should happen. """