Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeBackgroundCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2006 Thomas Zander <zander@kde.org>
3 * SPDX-FileCopyrightText: 2008 Jan Hambrecht <jaham@gmx.net>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
9#include "KoShape.h"
10#include "KoShapeBackground.h"
11
12#include <klocalizedstring.h>
13
14#include "kis_command_ids.h"
15
16
18{
19public:
21 }
23 oldFills.clear();
24 newFills.clear();
25 }
26
28 {
29 oldFills.append(oldFill);
30 }
31
33 {
34 newFills.append(newFill);
35 }
36
40};
41
43 KUndo2Command *parent)
44 : KUndo2Command(parent)
45 , d(new Private())
46{
47 d->shapes = shapes;
48 Q_FOREACH (KoShape *shape, d->shapes) {
49 d->addOldFill(shape->background());
50 d->addNewFill(fill);
51 }
52
53 setText(kundo2_i18n("Set background"));
54}
55
57 : KUndo2Command(parent)
58 , d(new Private())
59{
60 d->shapes.append(shape);
61 d->addOldFill(shape->background());
62 d->addNewFill(fill);
63
64 setText(kundo2_i18n("Set background"));
65}
66
68 : KUndo2Command(parent)
69 , d(new Private())
70{
71 d->shapes = shapes;
72 Q_FOREACH (KoShape *shape, d->shapes) {
73 d->addOldFill(shape->background());
74 }
75 foreach (QSharedPointer<KoShapeBackground> fill, fills) {
76 d->addNewFill(fill);
77 }
78
79 setText(kundo2_i18n("Set background"));
80}
81
83{
85 QList<QSharedPointer<KoShapeBackground> >::iterator brushIt = d->newFills.begin();
86 Q_FOREACH (KoShape *shape, d->shapes) {
87 shape->setBackground(*brushIt);
88 shape->update();
89 ++brushIt;
90 }
91}
92
94{
96 QList<QSharedPointer<KoShapeBackground> >::iterator brushIt = d->oldFills.begin();
97 Q_FOREACH (KoShape *shape, d->shapes) {
98 shape->setBackground(*brushIt);
99 shape->update();
100 ++brushIt;
101 }
102}
103
108
110{
111 const KoShapeBackgroundCommand *other = dynamic_cast<const KoShapeBackgroundCommand*>(command);
112
113 if (!other ||
114 other->d->shapes != d->shapes) {
115
116 return false;
117 }
118
119 d->newFills= other->d->newFills;
120 return true;
121}
122
virtual void undo()
void setText(const KUndo2MagicString &text)
virtual void redo()
The undo / redo command for setting the shape background.
void redo() override
redo the command
void undo() override
revert the actions done in redo
QList< QSharedPointer< KoShapeBackground > > newFills
bool mergeWith(const KUndo2Command *command) override
QList< KoShape * > shapes
the shapes to set background for
QList< QSharedPointer< KoShapeBackground > > oldFills
KoShapeBackgroundCommand(const QList< KoShape * > &shapes, QSharedPointer< KoShapeBackground > fill, KUndo2Command *parent=0)
void addOldFill(QSharedPointer< KoShapeBackground > oldFill)
void addNewFill(QSharedPointer< KoShapeBackground > newFill)
virtual void update() const
Definition KoShape.cpp:605
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
Definition KoShape.cpp:918
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:926
KUndo2MagicString kundo2_i18n(const char *text)