Krita Source Code Documentation
Loading...
Searching...
No Matches
KoShapeConnectionChangeCommand.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * SPDX-FileCopyrightText: 2011 Jan Hambrecht <jaham@gmx.net>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6
8
10{
11public:
13 : connection(0), newConnectedShape(0), oldConnectedShape(0)
14 , newConnectionPointId(-1), oldConnectionPointId(-1)
15 {
16 }
17
18 KoConnectionShape *connection;
19 KoConnectionShape::HandleId connectionHandle;
24
25};
26
28 KoConnectionShape *connection, KoConnectionShape::HandleId connectionHandle,
29 KoShape *oldConnectedShape, int oldConnectionPointId,
30 KoShape *newConnectedShape, int newConnectionPointId, KUndo2Command *parent)
31 : KUndo2Command(parent), d(new Private)
32{
33 d->connection = connection;
34 d->connectionHandle = connectionHandle;
35 d->oldConnectedShape = oldConnectedShape;
36 d->oldConnectionPointId = oldConnectionPointId;
37 d->newConnectedShape = newConnectedShape;
38 d->newConnectionPointId = newConnectionPointId;
39}
40
45
47{
48 if(d->connection) {
49 if(d->connectionHandle == KoConnectionShape::StartHandle) {
50 d->connection->connectFirst(d->newConnectedShape, d->newConnectionPointId);
51 }
52 else {
53 d->connection->connectSecond(d->newConnectedShape, d->newConnectionPointId);
54 }
55 }
56
58}
59
61{
63
64 if(d->connection) {
65 if(d->connectionHandle == KoConnectionShape::StartHandle) {
66 d->connection->connectFirst(d->oldConnectedShape, d->oldConnectionPointId);
67 }
68 else {
69 d->connection->connectSecond(d->oldConnectedShape, d->oldConnectionPointId);
70 }
71 }
72}
virtual void undo()
virtual void redo()
A command to add a connection between two shapes.
KoShapeConnectionChangeCommand(KoConnectionShape *connection, KoConnectionShape::HandleId connectionHandle, KoShape *oldConnectedShape, int oldConnectionPointId, KoShape *newConnectedShape, int newConnectionPointId, KUndo2Command *parent=0)
void undo() override
revert the actions done in redo
~KoShapeConnectionChangeCommand() override
Destroys the command.