Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeContainerModel Class Referenceabstract

#include <KoShapeContainerModel.h>

+ Inheritance diagram for KoShapeContainerModel:

Public Member Functions

virtual void add (KoShape *shape)=0
 
virtual void childChanged (KoShape *shape, KoShape::ChangeType type)
 
virtual void containerChanged (KoShapeContainer *container, KoShape::ChangeType type)=0
 
virtual int count () const =0
 
void deleteOwnedShapes ()
 
virtual bool inheritsTransform (const KoShape *shape) const =0
 
virtual bool isClipped (const KoShape *shape) const =0
 
 KoShapeContainerModel ()
 default constructor
 
virtual void proposeMove (KoShape *shape, QPointF &move)
 
virtual void remove (KoShape *shape)=0
 
virtual void setClipped (const KoShape *shape, bool clipping)=0
 
virtual void setInheritsTransform (const KoShape *shape, bool inherit)=0
 
virtual void shapeHasBeenAddedToHierarchy (KoShape *shape, KoShapeContainer *addedToSubtree)
 
virtual QList< KoShape * > shapes () const =0
 
virtual void shapeToBeRemovedFromHierarchy (KoShape *shape, KoShapeContainer *removedFromSubtree)
 
virtual ~KoShapeContainerModel ()
 destructor
 

Protected Member Functions

 KoShapeContainerModel (const KoShapeContainerModel &rhs)
 

Detailed Description

The interface for the container model. This class has no implementation, but only pure virtual methods. You can find a fully implemented model using KoShapeContainerDefaultModel. Extending this class and implementing all methods allows you to implement a custom data-backend for the KoShapeContainer.

See also
KoShapeContainer, KoShapeContainerDefaultModel

Definition at line 27 of file KoShapeContainerModel.h.

Constructor & Destructor Documentation

◆ KoShapeContainerModel() [1/2]

KoShapeContainerModel::KoShapeContainerModel ( )

default constructor

Definition at line 13 of file KoShapeContainerModel.cpp.

14{
15}

◆ ~KoShapeContainerModel()

KoShapeContainerModel::~KoShapeContainerModel ( )
virtual

destructor

Definition at line 17 of file KoShapeContainerModel.cpp.

18{
19}

◆ KoShapeContainerModel() [2/2]

KoShapeContainerModel::KoShapeContainerModel ( const KoShapeContainerModel & rhs)
protected

Definition at line 67 of file KoShapeContainerModel.cpp.

68{
69 Q_UNUSED(rhs);
70}

Member Function Documentation

◆ add()

virtual void KoShapeContainerModel::add ( KoShape * shape)
pure virtual

Add a shape to this models store.

Parameters
shapethe shape to be managed in the container.

Implemented in ShapeGroupContainerModel, SimpleShapeContainerModel, ShapeLayerContainerModel, KisShapeSelectionModel, and KoTosContainerModel.

◆ childChanged()

void KoShapeContainerModel::childChanged ( KoShape * shape,
KoShape::ChangeType type )
virtual

This method is called when one of the shape shapes has been modified. When a shape is rotated, moved or scaled/skewed this method will be called to inform the container of such a change. The change has already happened at the time this method is called. The base implementation notifies the grand parent of the shape that there was a change in a shape. A reimplementation if this function should call this method when overriding the function.

Parameters
shapethe shape that has been changed
typethis enum shows which change the shape has had.

Reimplemented in KisShapeSelectionModel, and ShapeGroupContainerModel.

Definition at line 39 of file KoShapeContainerModel.cpp.

40{
41 Q_UNUSED(type);
42 KoShapeContainer * parent = child->parent();
43 Q_ASSERT(parent);
44 // propagate the change up the hierarchy
45 KoShapeContainer * grandparent = parent->parent();
46 if (grandparent) {
47 grandparent->model()->childChanged(parent, KoShape::ChildChanged);
48 }
49}
virtual void childChanged(KoShape *shape, KoShape::ChangeType type)
KoShapeContainerModel * model
@ ChildChanged
a child of a container was changed/removed. This is propagated to all parents
Definition KoShape.h:112
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327

References KoShape::ChildChanged, childChanged(), KoShapeContainer::model, and KoShape::parent().

◆ containerChanged()

virtual void KoShapeContainerModel::containerChanged ( KoShapeContainer * container,
KoShape::ChangeType type )
pure virtual

This method is called as a notification that one of the properties of the container changed. This can be one of size, position, rotation and skew. Note that clipped children will automatically get all these changes, the model does not have to do anything for that.

Parameters
containerthe actual container that changed.
typethis enum shows which change the container has had.

Implemented in SimpleShapeContainerModel, KisShapeSelectionModel, and KoTosContainerModel.

◆ count()

virtual int KoShapeContainerModel::count ( ) const
pure virtual

Return the current number of children registered.

Returns
the current number of children registered.

Implemented in KoTosContainerModel, SimpleShapeContainerModel, and KisShapeSelectionModel.

◆ deleteOwnedShapes()

void KoShapeContainerModel::deleteOwnedShapes ( )

Definition at line 21 of file KoShapeContainerModel.cpp.

22{
23 QList<KoShape*> ownedShapes = this->shapes();
24
25 Q_FOREACH (KoShape *shape, ownedShapes) {
26 shape->setParent(0);
27 delete shape;
28 }
29
31}
virtual int count() const =0
virtual QList< KoShape * > shapes() const =0
void setParent(KoShapeContainer *parent)
Definition KoShape.cpp:535
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References count(), KIS_SAFE_ASSERT_RECOVER_NOOP, KoShape::setParent(), and shapes().

◆ inheritsTransform()

virtual bool KoShapeContainerModel::inheritsTransform ( const KoShape * shape) const
pure virtual

Returns if the shape inherits the container transform.

A shape that inherits the transform of the parent container will have its share / rotation / skew etc be calculated as being the product of both its own local transformation and also that of its parent container. If you set this to true and rotate the container, the shape will get that rotation as well automatically.

Returns
if the argument shape has its 'inherits transform' property set.
Parameters
shapethe shape for which the property will be returned.

Implemented in KoTosContainerModel, SimpleShapeContainerModel, and KisShapeSelectionModel.

◆ isClipped()

virtual bool KoShapeContainerModel::isClipped ( const KoShape * shape) const
pure virtual

Returns if the argument shape has its 'clipping' property set.

A shape that is clipped by the container will have its visible portion limited to the area where it intersects with the container. If a shape is positioned or sized such that it would be painted outside of the KoShape::outline() of its parent container, setting this property to true will clip the shape painting to the container outline.

Returns
if the argument shape has its 'clipping' property set.
Parameters
shapethe shape for which the property will be returned.

Implemented in KisShapeSelectionModel, KoTosContainerModel, and SimpleShapeContainerModel.

◆ proposeMove()

void KoShapeContainerModel::proposeMove ( KoShape * shape,
QPointF & move )
virtual

This method is called when the user tries to move a shape that is a shape of the container this model represents. The shape itself is not yet moved; it is proposed to be moved over the param move distance. You can alter the value of the move to affect the actual distance moved. The default implementation does nothing.

Parameters
shapethe shape of this container that the user is trying to move.
movethe distance that the user proposes to move shape from the current position.

Reimplemented in SimpleShapeContainerModel.

Definition at line 33 of file KoShapeContainerModel.cpp.

34{
35 Q_UNUSED(child);
36 Q_UNUSED(move);
37}

◆ remove()

virtual void KoShapeContainerModel::remove ( KoShape * shape)
pure virtual

Remove a shape to be completely separated from the model.

Parameters
shapethe shape to be removed.

Implemented in ShapeGroupContainerModel, ShapeLayerContainerModel, KisShapeSelectionModel, KoTosContainerModel, and SimpleShapeContainerModel.

◆ setClipped()

virtual void KoShapeContainerModel::setClipped ( const KoShape * shape,
bool clipping )
pure virtual

Set the argument shape to have its 'clipping' property set.

A shape that is clipped by the container will have its visible portion limited to the area where it intersects with the container. If a shape is positioned or sized such that it would be painted outside of the KoShape::outline() of its parent container, setting this property to true will clip the shape painting to the container outline.

Parameters
shapethe shape for which the property will be changed.
clippingthe new value

Implemented in KisShapeSelectionModel, KoTosContainerModel, and SimpleShapeContainerModel.

◆ setInheritsTransform()

virtual void KoShapeContainerModel::setInheritsTransform ( const KoShape * shape,
bool inherit )
pure virtual

Set the shape to inherit the container transform.

A shape that inherits the transform of the parent container will have its share / rotation / skew etc be calculated as being the product of both its own local transformation and also that of its parent container. If you set this to true and rotate the container, the shape will get that rotation as well automatically.

Parameters
shapethe shape for which the property will be changed.
inheritthe new value

Implemented in KoTosContainerModel, KisShapeSelectionModel, and SimpleShapeContainerModel.

◆ shapeHasBeenAddedToHierarchy()

void KoShapeContainerModel::shapeHasBeenAddedToHierarchy ( KoShape * shape,
KoShapeContainer * addedToSubtree )
virtual

Reimplemented in SimpleShapeContainerModel.

Definition at line 51 of file KoShapeContainerModel.cpp.

52{
53 KoShapeContainer *parent = addedToSubtree->parent();
54 if (parent) {
55 parent->model()->shapeHasBeenAddedToHierarchy(shape, parent);
56 }
57}
KoShapeContainer * parent() const
Definition KoShape.cpp:1039

References KoShape::parent().

◆ shapes()

virtual QList< KoShape * > KoShapeContainerModel::shapes ( ) const
pure virtual

Return the list of all shapes of this model

Returns
the list of all shapes

Implemented in KoTosContainerModel, SimpleShapeContainerModel, and KisShapeSelectionModel.

◆ shapeToBeRemovedFromHierarchy()

void KoShapeContainerModel::shapeToBeRemovedFromHierarchy ( KoShape * shape,
KoShapeContainer * removedFromSubtree )
virtual

Reimplemented in SimpleShapeContainerModel.

Definition at line 59 of file KoShapeContainerModel.cpp.

60{
61 KoShapeContainer *parent = removedFromSubtree->parent();
62 if (parent) {
63 parent->model()->shapeToBeRemovedFromHierarchy(shape, parent);
64 }
65}

References KoShape::parent().


The documentation for this class was generated from the following files: