Krita Source Code Documentation
Loading...
Searching...
No Matches
SvgInlineSizeChangeCommand Class Reference

#include <SvgInlineSizeChangeCommand.h>

+ Inheritance diagram for SvgInlineSizeChangeCommand:

Public Member Functions

int id () const override
 
bool mergeWith (const KUndo2Command *other) override
 
void redo () override
 
 SvgInlineSizeChangeCommand (KoSvgTextShape *shape, double inlineSize, double oldInlineSize, int anchor, int oldAnchor, QPointF newPos, QPointF oldPos, KUndo2Command *parent=nullptr)
 
 SvgInlineSizeChangeCommand (KoSvgTextShape *shape, double inlineSize, KUndo2Command *parent=nullptr)
 
void undo () override
 
 ~SvgInlineSizeChangeCommand () override=default
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Commandchild (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraDataextraData () const
 
bool hasParent () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual void redoMergedCommands ()
 
void setEndTime ()
 
virtual void setEndTime (const QTime &time)
 
void setExtraData (KUndo2CommandExtraData *data)
 
void setText (const KUndo2MagicString &text)
 
void setTime ()
 
virtual void setTime (const QTime &time)
 
virtual void setTimedID (int timedID)
 
KUndo2MagicString text () const
 
virtual QTime time () const
 
virtual int timedId () const
 
virtual bool timedMergeWith (KUndo2Command *other)
 
virtual void undoMergedCommands ()
 
virtual ~KUndo2Command ()
 

Private Member Functions

void applyInlineSize (double inlineSize, int anchor, QPointF pos, bool undo=false)
 

Private Attributes

int m_anchor
 
double m_inlineSize
 
QPointF m_movePos
 
int m_oldAnchor
 
double m_oldInlineSize
 
QPointF m_originalPos
 
KoSvgTextShapem_shape
 

Detailed Description

Definition at line 14 of file SvgInlineSizeChangeCommand.h.

Constructor & Destructor Documentation

◆ SvgInlineSizeChangeCommand() [1/2]

SvgInlineSizeChangeCommand::SvgInlineSizeChangeCommand ( KoSvgTextShape * shape,
double inlineSize,
KUndo2Command * parent = nullptr )

Definition at line 22 of file SvgInlineSizeChangeCommand.cpp.

23 : SvgInlineSizeChangeCommand(shape, inlineSize, SvgInlineSizeHelper::getInlineSizePt(shape), 0, 0, QPointF(), QPointF(), parent)
24{
25}
SvgInlineSizeChangeCommand(KoSvgTextShape *shape, double inlineSize, KUndo2Command *parent=nullptr)
static double getInlineSizePt(const KoSvgTextShape *const shape)

◆ SvgInlineSizeChangeCommand() [2/2]

SvgInlineSizeChangeCommand::SvgInlineSizeChangeCommand ( KoSvgTextShape * shape,
double inlineSize,
double oldInlineSize,
int anchor,
int oldAnchor,
QPointF newPos,
QPointF oldPos,
KUndo2Command * parent = nullptr )

Definition at line 27 of file SvgInlineSizeChangeCommand.cpp.

35 : KUndo2Command(parent)
36 , m_shape(shape)
37 , m_inlineSize(inlineSize)
38 , m_oldInlineSize(oldInlineSize)
39 , m_anchor(anchor)
40 , m_oldAnchor(oldAnchor)
41 , m_originalPos(oldPos)
42 , m_movePos(movePos)
43{
44 setText(kundo2_i18n("Adjust text auto wrap"));
45}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
KUndo2MagicString kundo2_i18n(const char *text)

References kundo2_i18n(), and KUndo2Command::setText().

◆ ~SvgInlineSizeChangeCommand()

SvgInlineSizeChangeCommand::~SvgInlineSizeChangeCommand ( )
overridedefault

Member Function Documentation

◆ applyInlineSize()

void SvgInlineSizeChangeCommand::applyInlineSize ( double inlineSize,
int anchor,
QPointF pos,
bool undo = false )
private

Definition at line 47 of file SvgInlineSizeChangeCommand.cpp.

48{
49 QRectF updateRect = m_shape->boundingRect();
50
53 inlineSizeProp.customValue = inlineSize;
54 inlineSizeProp.isAuto = false;
56 properties.setProperty(KoSvgTextProperties::TextAnchorId, QVariant(anchor));
57
58 if (undo) {
59 m_shape->setPropertiesAtPos(-1, properties);
61 } else {
63 m_shape->setPropertiesAtPos(-1, properties);
64 }
65
67}
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
@ TextAnchorId
KoSvgText::TextAnchor.
@ InlineSizeId
KoSvgText::AutoValue.
void setProperty(PropertyId id, const QVariant &value)
QVariant propertyOrDefault(PropertyId id) const
QRectF boundingRect() const override
Get the bounding box of the shape.
KoSvgTextProperties propertiesForPos(const int pos, bool inherited=false) const
Return the properties at a given position.
void setPropertiesAtPos(int pos, KoSvgTextProperties properties)
setPropertiesAtPos will set the properties at pos.
@ TopLeft
Definition KoFlake.h:86
QVariant fromAutoValue(const KoSvgText::AutoValue &value)
Definition KoSvgText.h:493

References KoSvgTextShape::boundingRect(), KoSvgText::AutoValue::customValue, KoSvgText::fromAutoValue(), KoSvgTextProperties::InlineSizeId, KoSvgText::AutoValue::isAuto, m_shape, KoSvgTextShape::propertiesForPos(), KoSvgTextProperties::propertyOrDefault(), KoShape::setAbsolutePosition(), KoSvgTextShape::setPropertiesAtPos(), KoSvgTextProperties::setProperty(), KoSvgTextProperties::TextAnchorId, KoFlake::TopLeft, undo(), and KoShape::updateAbsolute().

◆ id()

int SvgInlineSizeChangeCommand::id ( ) const
overridevirtual

Returns the ID of this command.

A command ID is used in command compression. It must be an integer unique to this command's class, or -1 if the command doesn't support compression.

If the command supports compression this function must be overridden in the derived class to return the correct ID. The base implementation returns -1.

KUndo2QStack::push() will only try to merge two commands if they have the same ID, and the ID is not -1.

See also
mergeWith(), KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 79 of file SvgInlineSizeChangeCommand.cpp.

References KisCommandUtils::SvgInlineSizeChangeCommand.

◆ mergeWith()

bool SvgInlineSizeChangeCommand::mergeWith ( const KUndo2Command * command)
overridevirtual

Attempts to merge this command with command. Returns true on success; otherwise returns false.

If this function returns true, calling this command's redo() must have the same effect as redoing both this command and command. Similarly, calling this command's undo() must have the same effect as undoing command and this command.

KUndo2QStack will only try to merge two commands if they have the same id, and the id is not -1.

The default implementation returns false.

See also
id() KUndo2QStack::push()

Reimplemented from KUndo2Command.

Definition at line 84 of file SvgInlineSizeChangeCommand.cpp.

85{
86 const SvgInlineSizeChangeCommand *other = dynamic_cast<const SvgInlineSizeChangeCommand *>(otherCommand);
87
88 if (!other || other->m_shape != m_shape) {
89 return false;
90 }
91
93 m_anchor = other->m_anchor;
94 m_movePos = other->m_movePos;
95
96 return true;
97}

References m_anchor, m_inlineSize, m_movePos, and m_shape.

◆ redo()

void SvgInlineSizeChangeCommand::redo ( )
overridevirtual

Applies a change to the document. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls redo() on all child commands.

See also
undo()

Reimplemented from KUndo2Command.

Definition at line 69 of file SvgInlineSizeChangeCommand.cpp.

70{
72}
void applyInlineSize(double inlineSize, int anchor, QPointF pos, bool undo=false)

References applyInlineSize(), m_anchor, m_inlineSize, and m_movePos.

◆ undo()

void SvgInlineSizeChangeCommand::undo ( )
overridevirtual

Reverts a change to the document. After undo() is called, the state of the document should be the same as before redo() was called. This function must be implemented in the derived class. Calling KUndo2QStack::push(), KUndo2QStack::undo() or KUndo2QStack::redo() from this function leads to undefined behavior.

The default implementation calls undo() on all child commands in reverse order.

See also
redo()

Reimplemented from KUndo2Command.

Definition at line 74 of file SvgInlineSizeChangeCommand.cpp.

References applyInlineSize(), m_oldAnchor, m_oldInlineSize, and m_originalPos.

Member Data Documentation

◆ m_anchor

int SvgInlineSizeChangeCommand::m_anchor
private

Definition at line 41 of file SvgInlineSizeChangeCommand.h.

◆ m_inlineSize

double SvgInlineSizeChangeCommand::m_inlineSize
private

Definition at line 39 of file SvgInlineSizeChangeCommand.h.

◆ m_movePos

QPointF SvgInlineSizeChangeCommand::m_movePos
private

Definition at line 44 of file SvgInlineSizeChangeCommand.h.

◆ m_oldAnchor

int SvgInlineSizeChangeCommand::m_oldAnchor
private

Definition at line 42 of file SvgInlineSizeChangeCommand.h.

◆ m_oldInlineSize

double SvgInlineSizeChangeCommand::m_oldInlineSize
private

Definition at line 40 of file SvgInlineSizeChangeCommand.h.

◆ m_originalPos

QPointF SvgInlineSizeChangeCommand::m_originalPos
private

Definition at line 43 of file SvgInlineSizeChangeCommand.h.

◆ m_shape

KoSvgTextShape* SvgInlineSizeChangeCommand::m_shape
private

Definition at line 38 of file SvgInlineSizeChangeCommand.h.


The documentation for this class was generated from the following files: