1 /* This file is part of the KDE project
2  * Copyright (C) 2009 Thomas Zander <zander@kde.org>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #include "KoShapeContainerModel.h"
21 
22 #include "KoShapeContainer.h"
23 
24 #include "kis_assert.h"
25 
KoShapeContainerModel()26 KoShapeContainerModel::KoShapeContainerModel()
27 {
28 }
29 
~KoShapeContainerModel()30 KoShapeContainerModel::~KoShapeContainerModel()
31 {
32 }
33 
deleteOwnedShapes()34 void KoShapeContainerModel::deleteOwnedShapes()
35 {
36     QList<KoShape*> ownedShapes = this->shapes();
37 
38     Q_FOREACH (KoShape *shape, ownedShapes) {
39         shape->setParent(0);
40         delete shape;
41     }
42 
43     KIS_SAFE_ASSERT_RECOVER_NOOP(!this->count());
44 }
45 
proposeMove(KoShape * child,QPointF & move)46 void KoShapeContainerModel::proposeMove(KoShape *child, QPointF &move)
47 {
48     Q_UNUSED(child);
49     Q_UNUSED(move);
50 }
51 
childChanged(KoShape * child,KoShape::ChangeType type)52 void KoShapeContainerModel::childChanged(KoShape *child, KoShape::ChangeType type)
53 {
54     Q_UNUSED(type);
55     KoShapeContainer * parent = child->parent();
56     Q_ASSERT(parent);
57     // propagate the change up the hierarchy
58     KoShapeContainer * grandparent = parent->parent();
59     if (grandparent) {
60         grandparent->model()->childChanged(parent, KoShape::ChildChanged);
61     }
62 }
63 
shapeHasBeenAddedToHierarchy(KoShape * shape,KoShapeContainer * addedToSubtree)64 void KoShapeContainerModel::shapeHasBeenAddedToHierarchy(KoShape *shape, KoShapeContainer *addedToSubtree)
65 {
66     KoShapeContainer *parent = addedToSubtree->parent();
67     if (parent) {
68         parent->model()->shapeHasBeenAddedToHierarchy(shape, parent);
69     }
70 }
71 
shapeToBeRemovedFromHierarchy(KoShape * shape,KoShapeContainer * removedFromSubtree)72 void KoShapeContainerModel::shapeToBeRemovedFromHierarchy(KoShape *shape, KoShapeContainer *removedFromSubtree)
73 {
74     KoShapeContainer *parent = removedFromSubtree->parent();
75     if (parent) {
76         parent->model()->shapeToBeRemovedFromHierarchy(shape, parent);
77     }
78 }
79 
KoShapeContainerModel(const KoShapeContainerModel & rhs)80 KoShapeContainerModel::KoShapeContainerModel(const KoShapeContainerModel &rhs)
81 {
82     Q_UNUSED(rhs);
83 }
84