Krita Source Code Documentation
Loading...
Searching...
No Matches
KisCommandUtils::CompositeCommand Struct Reference

#include <kis_command_utils.h>

+ Inheritance diagram for KisCommandUtils::CompositeCommand:

Public Member Functions

void addCommand (KUndo2Command *cmd)
 
 CompositeCommand (KUndo2Command *parent=0)
 
void redo () override
 
void undo () override
 
 ~CompositeCommand () 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 int id () const
 
virtual bool isMerged () const
 
 KUndo2Command (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 KUndo2Command (KUndo2Command *parent=0)
 
virtual QVector< KUndo2Command * > mergeCommandsVector () const
 
virtual bool mergeWith (const KUndo2Command *other)
 
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

QVector< KUndo2Command * > m_commands
 

Detailed Description

Definition at line 121 of file kis_command_utils.h.

Constructor & Destructor Documentation

◆ CompositeCommand()

KisCommandUtils::CompositeCommand::CompositeCommand ( KUndo2Command * parent = 0)

Definition at line 174 of file kis_command_utils.cpp.

175 : KUndo2Command(parent) {}
KUndo2Command(KUndo2Command *parent=0)

◆ ~CompositeCommand()

KisCommandUtils::CompositeCommand::~CompositeCommand ( )
override

Definition at line 177 of file kis_command_utils.cpp.

177 {
178 qDeleteAll(m_commands);
179 }
QVector< KUndo2Command * > m_commands

References m_commands.

Member Function Documentation

◆ addCommand()

void KisCommandUtils::CompositeCommand::addCommand ( KUndo2Command * cmd)

Definition at line 181 of file kis_command_utils.cpp.

181 {
182 if (cmd) {
183 m_commands << cmd;
184 }
185 }

References m_commands.

◆ redo()

void KisCommandUtils::CompositeCommand::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.

Reimplemented in KisQmicSynchronizeLayersCommand.

Definition at line 187 of file kis_command_utils.cpp.

187 {
189 Q_FOREACH (KUndo2Command *cmd, m_commands) {
190 cmd->redo();
191 }
192 }
virtual void redo()

References m_commands, and KUndo2Command::redo().

◆ undo()

void KisCommandUtils::CompositeCommand::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.

Reimplemented in KisQmicSynchronizeLayersCommand.

Definition at line 194 of file kis_command_utils.cpp.

194 {
195 for (auto it = m_commands.rbegin(); it != m_commands.rend(); ++it) {
196 (*it)->undo();
197 }
199 }
virtual void undo()

References m_commands, and KUndo2Command::undo().

Member Data Documentation

◆ m_commands

QVector<KUndo2Command*> KisCommandUtils::CompositeCommand::m_commands
private

Definition at line 131 of file kis_command_utils.h.


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