Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextMergePropertiesRangeCommand.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
7
8#include "KoSvgTextShape.h"
9#include "kis_command_ids.h"
10
12 const KoSvgTextProperties props,
13 const int pos,
14 const int anchor,
15 const QSet<KoSvgTextProperties::PropertyId> removeProperties,
16 KUndo2Command *parent)
17 : KUndo2Command(parent)
18 , m_shape(shape)
19 , m_props(props)
20 , m_removeProperties(removeProperties)
21 , m_pos(pos)
22 , m_anchor(anchor)
23 , m_textData(m_shape->getMemento())
24{
25 setText(kundo2_i18n("Change Text Properties"));
26
27 // Some properties may change cursor pos count, so we need the indices.
28 m_startIndex = m_shape->indexForPos(qMin(pos, anchor));
29 m_endIndex = m_shape->indexForPos(qMax(pos, anchor));
30}
31
40
47
52
54{
55 const SvgTextMergePropertiesRangeCommand *command = dynamic_cast<const SvgTextMergePropertiesRangeCommand*>(other);
56
57 if (!command || command->m_shape != m_shape || m_startIndex != command->m_startIndex || m_endIndex != command->m_endIndex) {
58 return false;
59 }
60
71 m_removeProperties.insert(p);
72 }
73
76 m_removeProperties.remove(p);
77 }
78
79 return true;
80}
const Params2D p
void setText(const KUndo2MagicString &text)
virtual void updateAbsolute(const QRectF &rect) const
Definition KoShape.cpp:616
void removeProperty(PropertyId id)
QList< PropertyId > properties() const
QVariant property(PropertyId id, const QVariant &defaultValue=QVariant()) const
void setProperty(PropertyId id, const QVariant &value)
void setMemento(const KoSvgTextShapeMementoSP memento)
Set the text data and layout info, reset listening cursors to 0.
QRectF boundingRect() const override
Get the bounding box of the shape.
void notifyMarkupChanged()
Notify that the markup has changed.
int indexForPos(int pos) const
indexForPos get the string index for a given cursor position.
void mergePropertiesIntoRange(const int startPos, const int endPos, const KoSvgTextProperties properties, const QSet< KoSvgTextProperties::PropertyId > removeProperties=QSet< KoSvgTextProperties::PropertyId >())
mergePropertiesIntoRange Merge given properties into the given range. This will first split the nodes...
The SvgTextMergePropertiesRangeCommand class This sets properties on a specific range in a single tex...
QSet< KoSvgTextProperties::PropertyId > m_removeProperties
SvgTextMergePropertiesRangeCommand(KoSvgTextShape *shape, const KoSvgTextProperties props, const int pos, const int anchor, const QSet< KoSvgTextProperties::PropertyId > removeProperties=QSet< KoSvgTextProperties::PropertyId >(), KUndo2Command *parent=0)
bool mergeWith(const KUndo2Command *other) override
KUndo2MagicString kundo2_i18n(const char *text)