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"
11
13 const KoSvgTextProperties props,
14 const int pos,
15 const int anchor,
16 const QSet<KoSvgTextProperties::PropertyId> removeProperties,
17 KUndo2Command *parent)
18 : KUndo2Command(parent)
19 , m_shape(shape)
20 , m_props(props)
21 , m_removeProperties(removeProperties)
22 , m_pos(pos)
23 , m_anchor(anchor)
24 , m_textData(m_shape->getMemento())
25{
26 setText(kundo2_i18n("Change Text Properties"));
27
28 // Some properties may change cursor pos count, so we need the indices.
29 m_startIndex = m_shape->indexForPos(qMin(pos, anchor));
30 m_endIndex = m_shape->indexForPos(qMax(pos, anchor));
31}
32
41
48
53
55{
56 const SvgTextMergePropertiesRangeCommand *command = dynamic_cast<const SvgTextMergePropertiesRangeCommand*>(other);
57
58 if (!command || command->m_shape != m_shape || m_startIndex != command->m_startIndex || m_endIndex != command->m_endIndex) {
59 return false;
60 }
61
72 m_removeProperties.insert(p);
73 }
74
77 m_removeProperties.remove(p);
78 }
79
80 return true;
81}
const Params2D p
void setText(const KUndo2MagicString &text)
static void bulkShapesUpdate(const UpdatesList &updates)
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.
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)