Inkscape
Vector Graphics Editor
|
Interface for XML node observers. More...
#include <node-observer.h>
Public Member Functions | |
virtual | ~NodeObserver ()=default |
virtual void | notifyChildAdded (Node &node, Node &child, Node *prev) |
Child addition callback. | |
virtual void | notifyChildRemoved (Node &node, Node &child, Node *prev) |
Child removal callback. | |
virtual void | notifyChildOrderChanged (Node &node, Node &child, Node *old_prev, Node *new_prev) |
Child order change callback. | |
virtual void | notifyContentChanged (Node &node, Util::ptr_shared old_content, Util::ptr_shared new_content) |
Content change callback. | |
virtual void | notifyAttributeChanged (Node &node, GQuark name, Util::ptr_shared old_value, Util::ptr_shared new_value) |
Attribute change callback. | |
virtual void | notifyElementNameChanged (Node &node, GQuark old_name, GQuark new_name) |
Element name change callback. | |
Protected Member Functions | |
NodeObserver ()=default | |
Interface for XML node observers.
This class defines an interface for objects that can receive XML node state change notifications. The observer has to be registered using the Node::addObserver() method to be notified of changes of this node only, or using Node::addSubtreeObserver() to also receive notifications about its descendants. All observer methods are called when the operations in question have been completed, just before returning from the modifying methods.
Be careful when e.g. changing an attribute of node
in notifyAttributeChanged(). The method will be called again due to the XML modification performed in it. If you don't take special precautions to ignore the second call, it will result in infinite recursion.
The virtual methods of this class do nothing by default, so you don't need to provide stubs for things you don't use. A good idea is to make the observer register itself on construction and unregister itself on destruction. This will ensure there are no dangling references.
Definition at line 50 of file node-observer.h.
|
protecteddefault |
|
virtualdefault |
|
inlinevirtual |
Attribute change callback.
This method is called whenever one of a node's attributes is changed.
node | The changed XML node |
name | GQuark corresponding to the attribute's name |
old_value | Old value of the modified attribute. Is a nullptr when the attribute is added. |
new_value | New value of the modified attribute. Is a nullptr when the attribute is removed. |
Reimplemented in Persp3DNodeObserver, Inkscape::UI::Tools::CCToolShapeNodeObserver, LPENodeObserver, SPObject, Inkscape::UI::ShapeEditor, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, Inkscape::UI::Toolbar::SpiralToolbar, Inkscape::UI::Dialog::DocumentProperties::WatchConnection, Inkscape::UI::Toolbar::ArcToolbar, Inkscape::UI::Toolbar::Box3DToolbar, Inkscape::UI::Toolbar::ConnectorToolbar, Inkscape::UI::Toolbar::RectToolbar, Inkscape::UI::Toolbar::StarToolbar, and Inkscape::UI::Dialog::AttrDialog.
Definition at line 142 of file node-observer.h.
Referenced by Inkscape::XML::EventChgAttr::_replayOne(), Inkscape::XML::EventChgAttr::_undoOne(), and Inkscape::XML::SimpleNode::setAttributeImpl().
|
inlinevirtual |
Child addition callback.
This method is called whenever a child is added to the observed node. The prev
parameter is NULL when the newly added child is first in the sibling order.
node | The changed XML node |
child | The newly added child node |
prev | The node after which the new child was inserted into the sibling order, or NULL |
Reimplemented in SPStyleElemNodeObserver, SPObject, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, and Inkscape::UI::Dialog::DocumentProperties::WatchConnection.
Definition at line 69 of file node-observer.h.
Referenced by Inkscape::XML::EventAdd::_replayOne(), Inkscape::XML::EventDel::_undoOne(), and Inkscape::XML::SimpleNode::addChild().
|
inlinevirtual |
Child order change callback.
This method is called whenever the order of a node's children is changed using Node::changeOrder(). The old_prev
parameter is NULL if the relocated node was first in the sibling order before the order change, and new_prev
is NULL if it was moved to the first position by this operation.
node | The changed XML node |
child | The child node that was relocated in the sibling order |
old_prev | The node that was before child prior to the order change |
new_prev | The node that is before child after the order change |
Reimplemented in SPStyleElemNodeObserver, SPObject, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, and Inkscape::XML::SimpleDocument.
Definition at line 104 of file node-observer.h.
Referenced by Inkscape::XML::EventChgOrder::_replayOne(), Inkscape::XML::EventChgOrder::_undoOne(), and Inkscape::XML::SimpleNode::changeOrder().
|
inlinevirtual |
Child removal callback.
This method is called whenever a child is removed from the observed node. The prev
parameter is NULL when the removed child was first in the sibling order.
node | The changed XML node |
child | The removed child node |
prev | The node that was before the removed node in sibling order, or NULL |
Reimplemented in SPStyleElemNodeObserver, Inkscape::UI::Tools::CCToolLayerNodeObserver, SPObject, SPTRefReference, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, and Inkscape::UI::Dialog::DocumentProperties::WatchConnection.
Definition at line 85 of file node-observer.h.
Referenced by Inkscape::XML::EventDel::_replayOne(), and Inkscape::XML::SimpleNode::removeChild().
|
inlinevirtual |
Content change callback.
This method is called whenever a node's content is changed using Node::setContent(), e.g. for text or comment nodes.
node | The changed XML node |
old_content | Old content of node |
new_content | New content of node |
Reimplemented in SPStyleElemTextNodeObserver, SPTRefReference, SPObject, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, Inkscape::XML::SimpleDocument, and Inkscape::UI::Dialog::AttrDialog.
Definition at line 122 of file node-observer.h.
References node.
Referenced by Inkscape::XML::EventChgContent::_replayOne(), Inkscape::XML::EventChgContent::_undoOne(), and Inkscape::XML::SimpleNode::setContent().
|
inlinevirtual |
Element name change callback.
This method is called whenever an element node's name is changed.
node | The changed XML node. |
old_name | GQuark corresponding to the old element name. |
new_name | GQuark corresponding to the new element name. |
Reimplemented in SPObject, Inkscape::XML::SignalObserver, Inkscape::XML::CompositeNodeObserver, and Inkscape::XML::SimpleDocument.
Definition at line 160 of file node-observer.h.
References node.
Referenced by Inkscape::XML::EventChgElementName::_replayOne(), Inkscape::XML::EventChgElementName::_undoOne(), and Inkscape::XML::SimpleNode::setCodeUnsafe().