Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgTextInsertRichCommand.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 */
8
10 : KUndo2Command(parent)
11 , m_shape(shape)
12 , m_insert(insert)
13 , m_pos(pos)
14 , m_anchor(anchor)
15{
16 setText(kundo2_i18n("Insert Rich Text"));
17}
18
20{
21 QRectF updateRect = m_shape->boundingRect();
22 // Index defaults to -1 when there's no text in the shape.
23 int oldIndex = qMax(0, m_shape->indexForPos(m_pos));
24
29
30 int pos = m_shape->posForIndex(oldIndex + m_insert->plainText().size(), false, false);
33}
34
void setText(const KUndo2MagicString &text)
virtual void updateAbsolute(const QRectF &rect) const
Definition KoShape.cpp:616
void notifyCursorPosChanged(int pos, int anchor)
Notify that the cursor position has changed.
KoSvgTextShapeMementoSP getMemento()
Get a memento holding the current textdata and layout info.
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.
bool insertRichText(int pos, const KoSvgTextShape *richText)
insertRichText Insert rich text at the given cursor pos. This will first split contents at the given ...
void cleanUp()
Cleans up the internal text data. Used by undo commands.
int posForIndex(int index, bool firstIndex=false, bool skipSynthetic=false) const
posForIndex Get the cursor position for a given index in a string.
KoSvgTextShapeMementoSP m_textData
SvgTextInsertRichCommand(KoSvgTextShape *shape, KoSvgTextShape *insert, int pos, int anchor, KUndo2Command *parent=0)
KUndo2MagicString kundo2_i18n(const char *text)