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

#include <KisLayerCollapseCommand.h>

+ Inheritance diagram for KisLayerCollapseCommand:

Public Member Functions

 KisLayerCollapseCommand (KisNodeSP node, bool newValue, KUndo2Command *parent=nullptr)
 
 KisLayerCollapseCommand (KisNodeSP node, bool oldValue, bool newValue, KUndo2Command *parent=nullptr)
 
bool mergeWith (const KUndo2Command *other) override
 
void redo () override
 
void undo () 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 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

bool m_newValue
 
KisNodeSP m_node
 
bool m_oldValue
 

Detailed Description

Definition at line 16 of file KisLayerCollapseCommand.h.

Constructor & Destructor Documentation

◆ KisLayerCollapseCommand() [1/2]

KisLayerCollapseCommand::KisLayerCollapseCommand ( KisNodeSP node,
bool oldValue,
bool newValue,
KUndo2Command * parent = nullptr )

Definition at line 12 of file KisLayerCollapseCommand.cpp.

13 : KUndo2Command(newValue ? kundo2_i18n("Collapse node %1", node->name()) : kundo2_i18n("Expand node %1", node->name()), parent)
14 , m_node(node)
15 , m_oldValue(oldValue)
16 , m_newValue(newValue)
17{
18}
KUndo2Command(KUndo2Command *parent=0)
KUndo2MagicString kundo2_i18n(const char *text)
const char * name(StandardAction id)
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327
QString name() const

◆ KisLayerCollapseCommand() [2/2]

KisLayerCollapseCommand::KisLayerCollapseCommand ( KisNodeSP node,
bool newValue,
KUndo2Command * parent = nullptr )

Definition at line 20 of file KisLayerCollapseCommand.cpp.

21 : KisLayerCollapseCommand(node, node->collapsed(), newValue, parent)
22{
23}
KisLayerCollapseCommand(KisNodeSP node, bool oldValue, bool newValue, KUndo2Command *parent=nullptr)

Member Function Documentation

◆ mergeWith()

bool KisLayerCollapseCommand::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 35 of file KisLayerCollapseCommand.cpp.

36{
37 const KisLayerCollapseCommand *cmd = dynamic_cast<const KisLayerCollapseCommand*>(other);
38
39 if (cmd && cmd->m_node == m_node) {
40 // verify the commands are actually chained
42
44 return true;
45 }
46
47 return false;
48}
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
Definition kis_assert.h:129

References KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, m_newValue, m_node, and m_oldValue.

◆ redo()

void KisLayerCollapseCommand::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 25 of file KisLayerCollapseCommand.cpp.

26{
28}
void setCollapsed(bool collapsed)

References m_newValue, m_node, and KisBaseNode::setCollapsed().

◆ undo()

void KisLayerCollapseCommand::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 30 of file KisLayerCollapseCommand.cpp.

References m_node, m_oldValue, and KisBaseNode::setCollapsed().

Member Data Documentation

◆ m_newValue

bool KisLayerCollapseCommand::m_newValue
private

Definition at line 29 of file KisLayerCollapseCommand.h.

◆ m_node

KisNodeSP KisLayerCollapseCommand::m_node
private

Definition at line 27 of file KisLayerCollapseCommand.h.

◆ m_oldValue

bool KisLayerCollapseCommand::m_oldValue
private

Definition at line 28 of file KisLayerCollapseCommand.h.


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