Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeContainerModel.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2009 Thomas Zander <zander@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8
9#include "KoShapeContainer.h"
10
11#include "kis_assert.h"
12
16
20
22{
23 QList<KoShape*> ownedShapes = this->shapes();
24
25 Q_FOREACH (KoShape *shape, ownedShapes) {
26 shape->setParent(0);
27 delete shape;
28 }
29
31}
32
34{
35 Q_UNUSED(child);
36 Q_UNUSED(move);
37}
38
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}
50
52{
53 KoShapeContainer *parent = addedToSubtree->parent();
54 if (parent) {
55 parent->model()->shapeHasBeenAddedToHierarchy(shape, parent);
56 }
57}
58
60{
61 KoShapeContainer *parent = removedFromSubtree->parent();
62 if (parent) {
63 parent->model()->shapeToBeRemovedFromHierarchy(shape, parent);
64 }
65}
66
virtual void childChanged(KoShape *shape, KoShape::ChangeType type)
virtual void proposeMove(KoShape *shape, QPointF &move)
KoShapeContainerModel()
default constructor
virtual void shapeToBeRemovedFromHierarchy(KoShape *shape, KoShapeContainer *removedFromSubtree)
virtual int count() const =0
virtual void shapeHasBeenAddedToHierarchy(KoShape *shape, KoShapeContainer *addedToSubtree)
virtual ~KoShapeContainerModel()
destructor
virtual QList< KoShape * > shapes() const =0
KoShapeContainerModel * model
KoShapeContainer * parent() const
Definition KoShape.cpp:1039
ChangeType
Used by shapeChanged() to select which change was made.
Definition KoShape.h:95
@ ChildChanged
a child of a container was changed/removed. This is propagated to all parents
Definition KoShape.h:112
void setParent(KoShapeContainer *parent)
Definition KoShape.cpp:535
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130