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

The LambdaCommand struct is a shorthand for creation of AggregateCommand commands using C++ lambda feature. Just pass a lambda object into a command and it will be called from within the context of the strokes thread to populate the command content. More...

#include <kis_command_utils.h>

+ Inheritance diagram for KisCommandUtils::LambdaCommand:

Public Member Functions

 LambdaCommand (const KUndo2MagicString &text, KUndo2Command *parent, std::function< KUndo2Command *()> createCommandFunc)
 
 LambdaCommand (const KUndo2MagicString &text, std::function< KUndo2Command *()> createCommandFunc)
 
 LambdaCommand (KUndo2Command *parent, std::function< KUndo2Command *()> createCommandFunc)
 
 LambdaCommand (std::function< KUndo2Command *()> createCommandFunc)
 
- Public Member Functions inherited from KisCommandUtils::AggregateCommand
 AggregateCommand (const KUndo2MagicString &text, KUndo2Command *parent=0)
 
 AggregateCommand (KUndo2Command *parent=0)
 
void redo () override
 
void undo () override
 
- Public Member Functions inherited from KUndo2Command
QString actionText () const
 
virtual bool canAnnihilateWith (const KUndo2Command *other) const
 
const KUndo2Command * child (int index) const
 
int childCount () const
 
virtual QTime endTime () const
 
KUndo2CommandExtraData * extraData () 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 ()
 

Protected Member Functions

void populateChildCommands () override
 
- Protected Member Functions inherited from KisCommandUtils::AggregateCommand
void addCommand (KUndo2Command *cmd)
 

Private Attributes

std::function< KUndo2Command *()> m_createCommandFunc
 

Detailed Description

The LambdaCommand struct is a shorthand for creation of AggregateCommand commands using C++ lambda feature. Just pass a lambda object into a command and it will be called from within the context of the strokes thread to populate the command content.

Definition at line 51 of file kis_command_utils.h.

Constructor & Destructor Documentation

◆ LambdaCommand() [1/4]

KisCommandUtils::LambdaCommand::LambdaCommand ( std::function< KUndo2Command *()> createCommandFunc)

Definition at line 42 of file kis_command_utils.cpp.

43 : m_createCommandFunc(createCommandFunc)
44 {
45
46 }
std::function< KUndo2Command *()> m_createCommandFunc

◆ LambdaCommand() [2/4]

KisCommandUtils::LambdaCommand::LambdaCommand ( const KUndo2MagicString & text,
std::function< KUndo2Command *()> createCommandFunc )

Definition at line 48 of file kis_command_utils.cpp.

51 m_createCommandFunc(createCommandFunc)
52 {
53
54 }
KUndo2MagicString text() const
AggregateCommand(KUndo2Command *parent=0)

◆ LambdaCommand() [3/4]

KisCommandUtils::LambdaCommand::LambdaCommand ( const KUndo2MagicString & text,
KUndo2Command * parent,
std::function< KUndo2Command *()> createCommandFunc )

Definition at line 56 of file kis_command_utils.cpp.

59 : AggregateCommand(text, parent),
60 m_createCommandFunc(createCommandFunc)
61 {
62 }

◆ LambdaCommand() [4/4]

KisCommandUtils::LambdaCommand::LambdaCommand ( KUndo2Command * parent,
std::function< KUndo2Command *()> createCommandFunc )

Definition at line 64 of file kis_command_utils.cpp.

66 : AggregateCommand(parent),
67 m_createCommandFunc(createCommandFunc)
68 {
69 }

Member Function Documentation

◆ populateChildCommands()

void KisCommandUtils::LambdaCommand::populateChildCommands ( )
overrideprotectedvirtual

We should release all the potential resources owned by the attached lambda

Implements KisCommandUtils::AggregateCommand.

Definition at line 71 of file kis_command_utils.cpp.

72 {
75
81 }
82 }
void addCommand(KUndo2Command *cmd)

References KisCommandUtils::AggregateCommand::addCommand(), and m_createCommandFunc.

Member Data Documentation

◆ m_createCommandFunc

std::function<KUndo2Command*()> KisCommandUtils::LambdaCommand::m_createCommandFunc
private

Definition at line 65 of file kis_command_utils.h.


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