Krita Source Code Documentation
Loading...
Searching...
No Matches
KoTosContainerModel Class Reference

#include <KoTosContainerModel.h>

+ Inheritance diagram for KoTosContainerModel:

Public Member Functions

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

Private Attributes

KoShapem_textShape
 

Additional Inherited Members

- Protected Member Functions inherited from KoShapeContainerModel
 KoShapeContainerModel (const KoShapeContainerModel &rhs)
 

Detailed Description

Definition at line 11 of file KoTosContainerModel.h.

Constructor & Destructor Documentation

◆ KoTosContainerModel()

KoTosContainerModel::KoTosContainerModel ( )

Definition at line 15 of file KoTosContainerModel.cpp.

16: m_textShape(0)
17{
18}

◆ ~KoTosContainerModel()

KoTosContainerModel::~KoTosContainerModel ( )
override

Definition at line 20 of file KoTosContainerModel.cpp.

21{
22}

Member Function Documentation

◆ add()

void KoTosContainerModel::add ( KoShape * shape)
overridevirtual

Add a shape to this models store.

Parameters
shapethe shape to be managed in the container.

Implements KoShapeContainerModel.

Definition at line 24 of file KoTosContainerModel.cpp.

25{
26 // make sure shape is a text shape
27 KoTextShapeDataBase *shapeData = qobject_cast<KoTextShapeDataBase*>(shape->userData());
28 Q_ASSERT(shapeData != 0);
29 if (shapeData) {
30 delete m_textShape;
31 m_textShape = shape;
32 }
33}
KoShapeUserData * userData() const
Definition KoShape.cpp:710

References m_textShape, and KoShape::userData().

◆ containerChanged()

void KoTosContainerModel::containerChanged ( KoShapeContainer * container,
KoShape::ChangeType type )
overridevirtual

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.

Implements KoShapeContainerModel.

Definition at line 81 of file KoTosContainerModel.cpp.

82{
83 debugFlake << "change type:" << type << KoShape::SizeChanged << KoShape::ContentChanged;
84 if (type != KoShape::SizeChanged && type != KoShape::ContentChanged) {
85 return;
86 }
87 KoTosContainer *tosContainer = dynamic_cast<KoTosContainer*>(container);
88 debugFlake << "tosContainer" << tosContainer;
89 if (tosContainer) {
91 }
92 if ( m_textShape && tosContainer && tosContainer->resizeBehavior() != KoTosContainer::TextFollowsPreferredTextRect ) {
93 debugFlake << "change type setSize";
94 m_textShape->setSize(tosContainer->size());
95 }
96}
#define debugFlake
Definition FlakeDebug.h:15
virtual QSizeF size() const
Get the size of the shape in pt.
Definition KoShape.cpp:820
@ ContentChanged
the content of the shape changed e.g. a new image inside a pixmap/text change inside a textshape
Definition KoShape.h:110
@ SizeChanged
used after a setSize()
Definition KoShape.h:100
virtual void setSize(const QSizeF &size)
Resize the shape.
Definition KoShape.cpp:276
ResizeBehavior resizeBehavior() const
@ TextFollowsPreferredTextRect
The size/position of the text area will follow the preferredTextRect property.

References KoShape::ContentChanged, debugFlake, m_textShape, KoTosContainer::resizeBehavior(), KoShape::setSize(), KoShape::size(), KoShape::SizeChanged, and KoTosContainer::TextFollowsPreferredTextRect.

◆ count()

int KoTosContainerModel::count ( ) const
overridevirtual

Return the current number of children registered.

Returns
the current number of children registered.

Implements KoShapeContainerModel.

Definition at line 67 of file KoTosContainerModel.cpp.

68{
69 return m_textShape != 0 ? 1 : 0;
70}

References m_textShape.

◆ inheritsTransform()

bool KoTosContainerModel::inheritsTransform ( const KoShape * shape) const
overridevirtual

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.

Implements KoShapeContainerModel.

Definition at line 61 of file KoTosContainerModel.cpp.

62{
63 Q_UNUSED(shape);
64 return true;
65}

◆ isClipped()

bool KoTosContainerModel::isClipped ( const KoShape * shape) const
overridevirtual

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.

Implements KoShapeContainerModel.

Definition at line 49 of file KoTosContainerModel.cpp.

50{
51 Q_UNUSED(shape);
52 return false;
53}

◆ remove()

void KoTosContainerModel::remove ( KoShape * shape)
overridevirtual

Remove a shape to be completely separated from the model.

Parameters
shapethe shape to be removed.

Implements KoShapeContainerModel.

Definition at line 35 of file KoTosContainerModel.cpp.

36{
37 Q_ASSERT(m_textShape == 0 || shape == m_textShape);
38 if (shape == m_textShape) {
39 m_textShape = 0;
40 }
41}

References m_textShape.

◆ setClipped()

void KoTosContainerModel::setClipped ( const KoShape * shape,
bool clipping )
overridevirtual

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

Implements KoShapeContainerModel.

Definition at line 43 of file KoTosContainerModel.cpp.

44{
45 Q_UNUSED(shape);
46 Q_UNUSED(clipping);
47}

◆ setInheritsTransform()

void KoTosContainerModel::setInheritsTransform ( const KoShape * shape,
bool inherit )
overridevirtual

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

Implements KoShapeContainerModel.

Definition at line 55 of file KoTosContainerModel.cpp.

56{
57 Q_UNUSED(shape);
58 Q_UNUSED(inherit);
59}

◆ shapes()

QList< KoShape * > KoTosContainerModel::shapes ( ) const
overridevirtual

Return the list of all shapes of this model

Returns
the list of all shapes

Implements KoShapeContainerModel.

Definition at line 72 of file KoTosContainerModel.cpp.

73{
75 if (m_textShape) {
77 }
78 return shapes;
79}
QList< KoShape * > shapes() const override

References m_textShape, and shapes().

Member Data Documentation

◆ m_textShape

KoShape* KoTosContainerModel::m_textShape
private

Definition at line 28 of file KoTosContainerModel.h.


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