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

The undo / redo command for changing a parameter. More...

#include <KoParameterHandleMoveCommand.h>

+ Inheritance diagram for KoParameterHandleMoveCommand:

Public Member Functions

int id () const override
 
 KoParameterHandleMoveCommand (KoParameterShape *shape, int handleId, const QPointF &startPoint, const QPointF &endPoint, Qt::KeyboardModifiers keyModifiers, KUndo2Command *parent=0)
 
bool mergeWith (const KUndo2Command *command) override
 
void redo () override
 redo the command
 
void undo () override
 revert the actions done in redo
 
 ~KoParameterHandleMoveCommand () override
 
- 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 Attributes

QPointF m_endPoint
 
int m_handleId
 
Qt::KeyboardModifiers m_keyModifiers
 
KoParameterShapem_shape
 
QPointF m_startPoint
 

Detailed Description

The undo / redo command for changing a parameter.

Definition at line 19 of file KoParameterHandleMoveCommand.h.

Constructor & Destructor Documentation

◆ KoParameterHandleMoveCommand()

KoParameterHandleMoveCommand::KoParameterHandleMoveCommand ( KoParameterShape * shape,
int handleId,
const QPointF & startPoint,
const QPointF & endPoint,
Qt::KeyboardModifiers keyModifiers,
KUndo2Command * parent = 0 )

Constructor.

Parameters
shapethe shape this command works on
handleIdthe ID under which the parameterShape knows the handle in KoParameterShape::moveHandle()
startPointThe old position
endPointThe new position
keyModifiersthe key modifiers used while moving.
parentthe parent command if this is a compound undo command.

Definition at line 14 of file KoParameterHandleMoveCommand.cpp.

15 : KUndo2Command(parent)
16 , m_shape(shape)
17 , m_handleId(handleId)
18 , m_startPoint(startPoint)
19 , m_endPoint(endPoint)
20 , m_keyModifiers(keyModifiers)
21{
22 setText(kundo2_i18n("Change parameter"));
23}
void setText(const KUndo2MagicString &text)
KUndo2Command(KUndo2Command *parent=0)
KUndo2MagicString kundo2_i18n(const char *text)

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

◆ ~KoParameterHandleMoveCommand()

KoParameterHandleMoveCommand::~KoParameterHandleMoveCommand ( )
override

Definition at line 25 of file KoParameterHandleMoveCommand.cpp.

26{
27}

Member Function Documentation

◆ id()

int KoParameterHandleMoveCommand::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 47 of file KoParameterHandleMoveCommand.cpp.

References KisCommandUtils::ChangeShapeParameterId.

◆ mergeWith()

bool KoParameterHandleMoveCommand::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 52 of file KoParameterHandleMoveCommand.cpp.

53{
54 const KoParameterHandleMoveCommand *other = dynamic_cast<const KoParameterHandleMoveCommand*>(command);
55
56 if (!other ||
57 other->m_shape != m_shape ||
58 other->m_handleId != m_handleId ||
60
61 return false;
62 }
63
64 m_endPoint = other->m_endPoint;
65
66 return true;
67}
The undo / redo command for changing a parameter.

References m_endPoint, m_handleId, m_keyModifiers, and m_shape.

◆ redo()

void KoParameterHandleMoveCommand::redo ( )
overridevirtual

redo the command

Reimplemented from KUndo2Command.

Definition at line 30 of file KoParameterHandleMoveCommand.cpp.

31{
33 m_shape->update();
35 m_shape->update();
36}
virtual void redo()
void moveHandle(int handleId, const QPointF &point, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Move handle to point.
void update() const override
reimplemented

References m_endPoint, m_handleId, m_keyModifiers, m_shape, KoParameterShape::moveHandle(), KUndo2Command::redo(), and KoShapeContainer::update().

◆ undo()

void KoParameterHandleMoveCommand::undo ( )
overridevirtual

revert the actions done in redo

Reimplemented from KUndo2Command.

Definition at line 39 of file KoParameterHandleMoveCommand.cpp.

References m_handleId, m_shape, m_startPoint, KoParameterShape::moveHandle(), KUndo2Command::undo(), and KoShapeContainer::update().

Member Data Documentation

◆ m_endPoint

QPointF KoParameterHandleMoveCommand::m_endPoint
private

Definition at line 46 of file KoParameterHandleMoveCommand.h.

◆ m_handleId

int KoParameterHandleMoveCommand::m_handleId
private

Definition at line 44 of file KoParameterHandleMoveCommand.h.

◆ m_keyModifiers

Qt::KeyboardModifiers KoParameterHandleMoveCommand::m_keyModifiers
private

Definition at line 47 of file KoParameterHandleMoveCommand.h.

◆ m_shape

KoParameterShape* KoParameterHandleMoveCommand::m_shape
private

Definition at line 43 of file KoParameterHandleMoveCommand.h.

◆ m_startPoint

QPointF KoParameterHandleMoveCommand::m_startPoint
private

Definition at line 45 of file KoParameterHandleMoveCommand.h.


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