File indexing completed on 2024-05-12 15:56:47

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2009 Thomas Zander <zander@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.0-or-later
0005  */
0006 
0007 #include "KoShapeContainerModel.h"
0008 
0009 #include "KoShapeContainer.h"
0010 
0011 #include "kis_assert.h"
0012 
0013 KoShapeContainerModel::KoShapeContainerModel()
0014 {
0015 }
0016 
0017 KoShapeContainerModel::~KoShapeContainerModel()
0018 {
0019 }
0020 
0021 void KoShapeContainerModel::deleteOwnedShapes()
0022 {
0023     QList<KoShape*> ownedShapes = this->shapes();
0024 
0025     Q_FOREACH (KoShape *shape, ownedShapes) {
0026         shape->setParent(0);
0027         delete shape;
0028     }
0029 
0030     KIS_SAFE_ASSERT_RECOVER_NOOP(!this->count());
0031 }
0032 
0033 void KoShapeContainerModel::proposeMove(KoShape *child, QPointF &move)
0034 {
0035     Q_UNUSED(child);
0036     Q_UNUSED(move);
0037 }
0038 
0039 void KoShapeContainerModel::childChanged(KoShape *child, KoShape::ChangeType type)
0040 {
0041     Q_UNUSED(type);
0042     KoShapeContainer * parent = child->parent();
0043     Q_ASSERT(parent);
0044     // propagate the change up the hierarchy
0045     KoShapeContainer * grandparent = parent->parent();
0046     if (grandparent) {
0047         grandparent->model()->childChanged(parent, KoShape::ChildChanged);
0048     }
0049 }
0050 
0051 void KoShapeContainerModel::shapeHasBeenAddedToHierarchy(KoShape *shape, KoShapeContainer *addedToSubtree)
0052 {
0053     KoShapeContainer *parent = addedToSubtree->parent();
0054     if (parent) {
0055         parent->model()->shapeHasBeenAddedToHierarchy(shape, parent);
0056     }
0057 }
0058 
0059 void KoShapeContainerModel::shapeToBeRemovedFromHierarchy(KoShape *shape, KoShapeContainer *removedFromSubtree)
0060 {
0061     KoShapeContainer *parent = removedFromSubtree->parent();
0062     if (parent) {
0063         parent->model()->shapeToBeRemovedFromHierarchy(shape, parent);
0064     }
0065 }
0066 
0067 KoShapeContainerModel::KoShapeContainerModel(const KoShapeContainerModel &rhs)
0068 {
0069     Q_UNUSED(rhs);
0070 }