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
7
#include "
KoShapeConnectionChangeCommand.h
"
8
9
class
Q_DECL_HIDDEN
KoShapeConnectionChangeCommand
::
Private
10
{
11
public
:
12
Private
()
13
: connection(0), newConnectedShape(0), oldConnectedShape(0)
14
, newConnectionPointId(-1), oldConnectionPointId(-1)
15
{
16
}
17
18
KoConnectionShape *
connection
;
19
KoConnectionShape::HandleId
connectionHandle
;
20
KoShape
*
newConnectedShape
;
21
KoShape
*
oldConnectedShape
;
22
int
newConnectionPointId
;
23
int
oldConnectionPointId
;
24
25
};
26
27
KoShapeConnectionChangeCommand::KoShapeConnectionChangeCommand
(
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
41
KoShapeConnectionChangeCommand::~KoShapeConnectionChangeCommand
()
42
{
43
delete
d
;
44
}
45
46
void
KoShapeConnectionChangeCommand::redo
()
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
57
KUndo2Command::redo
();
58
}
59
60
void
KoShapeConnectionChangeCommand::undo
()
61
{
62
KUndo2Command::undo
();
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
}
KoShapeConnectionChangeCommand.h
KUndo2Command
Definition
kundo2stack.h:87
KUndo2Command::undo
virtual void undo()
Definition
kundo2stack.cpp:240
KUndo2Command::redo
virtual void redo()
Definition
kundo2stack.cpp:222
KoShapeConnectionChangeCommand
A command to add a connection between two shapes.
Definition
KoShapeConnectionChangeCommand.cpp:10
KoShapeConnectionChangeCommand::Private
Private()
Definition
KoShapeConnectionChangeCommand.cpp:12
KoShapeConnectionChangeCommand::KoShapeConnectionChangeCommand
KoShapeConnectionChangeCommand(KoConnectionShape *connection, KoConnectionShape::HandleId connectionHandle, KoShape *oldConnectedShape, int oldConnectionPointId, KoShape *newConnectedShape, int newConnectionPointId, KUndo2Command *parent=0)
Definition
KoShapeConnectionChangeCommand.cpp:27
KoShapeConnectionChangeCommand::newConnectedShape
KoShape * newConnectedShape
Definition
KoShapeConnectionChangeCommand.cpp:20
KoShapeConnectionChangeCommand::redo
void redo() override
redo the command
Definition
KoShapeConnectionChangeCommand.cpp:46
KoShapeConnectionChangeCommand::undo
void undo() override
revert the actions done in redo
Definition
KoShapeConnectionChangeCommand.cpp:60
KoShapeConnectionChangeCommand::newConnectionPointId
int newConnectionPointId
Definition
KoShapeConnectionChangeCommand.cpp:22
KoShapeConnectionChangeCommand::~KoShapeConnectionChangeCommand
~KoShapeConnectionChangeCommand() override
Destroys the command.
Definition
KoShapeConnectionChangeCommand.cpp:41
KoShapeConnectionChangeCommand::connection
KoConnectionShape * connection
Definition
KoShapeConnectionChangeCommand.cpp:18
KoShapeConnectionChangeCommand::d
Private *const d
Definition
KoShapeConnectionChangeCommand.h:41
KoShapeConnectionChangeCommand::oldConnectionPointId
int oldConnectionPointId
Definition
KoShapeConnectionChangeCommand.cpp:23
KoShapeConnectionChangeCommand::connectionHandle
KoConnectionShape::HandleId connectionHandle
Definition
KoShapeConnectionChangeCommand.cpp:19
KoShapeConnectionChangeCommand::oldConnectedShape
KoShape * oldConnectedShape
Definition
KoShapeConnectionChangeCommand.cpp:21
KoShape
Definition
KoShape.h:92
Private
Definition
SvgTransformParser.cpp:20
libs
flake
commands
KoShapeConnectionChangeCommand.cpp
Generated at
2025-11-04 02:30:02+01:00
from
Krita
branch
master
, commit
c9dde2e79561a8aea4a7e8d9ac99c98a7bac9e52