Krita Source Code Documentation
Loading...
Searching...
No Matches
GroupShape.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#include "GroupShape.h"
7#include <KoShapeGroup.h>
8
9GroupShape::GroupShape(QObject *parent) : Shape(new KoShapeGroup(), parent)
10{
11}
12
13GroupShape::GroupShape(KoShapeGroup *shape, QObject *parent) :
14 Shape(shape, parent)
15{
16
17}
18
23
24QString GroupShape::type() const
25{
26 //Has no default KoID
27 return "groupshape";
28}
29
31{
32 KoShapeGroup * group = dynamic_cast<KoShapeGroup*>(this->shape());
33 QList <Shape*> shapes;
34 if (group) {
35 QList<KoShape*> originalShapes = group->shapes();
36 std::sort(originalShapes.begin(), originalShapes.end(), KoShape::compareShapeZIndex);
37 for(int i=0; i<group->shapeCount(); i++) {
38 if (dynamic_cast<KoShapeGroup*>(originalShapes.at(i))) {
39 shapes << new GroupShape(dynamic_cast<KoShapeGroup*>(originalShapes.at(i)));
40 } else {
41 shapes << new Shape(originalShapes.at(i));
42 }
43 }
44 }
45 return shapes;
46}
QString type() const override
type returns the type.
QList< Shape * > children()
children
QList< KoShape * > shapes() const
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:434
The Shape class The shape class is a wrapper around Krita's vector objects.
Definition Shape.h:38
friend class GroupShape
Definition Shape.h:202
KoShape * shape()
Definition Shape.cpp:236
Shape(KoShape *shape, QObject *parent=0)
Definition Shape.cpp:31