Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgMoveTextCommand.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Alvin <alvin@alvinhc.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
8
9#include <klocalizedstring.h>
10
11#include "KoSvgTextShape.h"
12#include "kis_command_ids.h"
13
15 const QPointF &newPosition,
16 const QPointF &oldPosition,
17 KUndo2Command *parent)
18 : KUndo2Command(parent)
19 , m_shape(shape)
20 , m_newPosition(newPosition)
21 , m_oldPosition(oldPosition)
22{
23 setText(kundo2_i18n("Move text"));
24}
25
26static void moveShape(KoSvgTextShape *shape, const QPointF &position)
27{
28 QRectF updateRect = shape->boundingRect();
29 shape->setAbsolutePosition(position);
30 updateRect |= shape->boundingRect();
31 shape->updateAbsolute(updateRect);
32}
33
38
43
48
50{
51 const SvgMoveTextCommand *other = dynamic_cast<const SvgMoveTextCommand *>(otherCommand);
52
53 if (!other || other->m_shape != m_shape) {
54 return false;
55 }
56
58
59 return true;
60}
static void moveShape(KoSvgTextShape *shape, const QPointF &position)
void setText(const KUndo2MagicString &text)
virtual void updateAbsolute(const QRectF &rect) const
Definition KoShape.cpp:616
void setAbsolutePosition(const QPointF &newPosition, KoFlake::AnchorPosition anchor=KoFlake::Center)
Definition KoShape.cpp:668
QRectF boundingRect() const override
Get the bounding box of the shape.
int id() const override
SvgMoveTextCommand(KoSvgTextShape *shape, const QPointF &newPosition, const QPointF &oldPosition, KUndo2Command *parent=nullptr)
KoSvgTextShape * m_shape
bool mergeWith(const KUndo2Command *other) override
KUndo2MagicString kundo2_i18n(const char *text)