Envision
A visual programming IDE for object-oriented languages
List of all members | Public Member Functions | Private Attributes
Model::UndoCommand Class Reference
Inheritance diagram for Model::UndoCommand:
Model::FieldSet< QString > Model::FieldSet< T > Model::NodeOwningCommand Model::NoteNodeChange Model::SetModificationTarget Model::NameChange Model::CompositeNodeChangeChild Model::ListInsert Model::ListPut Model::ListRemove

Public Member Functions

 UndoCommand (Node *target, const QString &text)
 
virtual ~UndoCommand ()
 
virtual NodeinsertedNode () const
 Returns the node that this command inserted into the tree, or nullptr if no node was inserted. More...
 
bool isUndone () const
 Returns whether the command has been undone since it was applied. More...
 
virtual Nodeowned () const
 Returns the node owned by this command or nullptr if no node is owned. More...
 
virtual void redo ()
 
virtual NoderemovedNode () const
 Returns the node that this command removed from the tree, or nullptr if no node was removed. More...
 
Nodetarget () const
 
virtual void undo ()
 

Private Attributes

Nodetarget_
 
bool undone
 

Constructor & Destructor Documentation

◆ UndoCommand()

Model::UndoCommand::UndoCommand ( Node target,
const QString &  text 
)

◆ ~UndoCommand()

Model::UndoCommand::~UndoCommand ( )
virtual

Member Function Documentation

◆ insertedNode()

Node * Model::UndoCommand::insertedNode ( ) const
virtual

Returns the node that this command inserted into the tree, or nullptr if no node was inserted.

The default implementaion returns nullptr. Reimplement this in commands that own a node.

Reimplemented in Model::NodeOwningCommand.

◆ isUndone()

bool Model::UndoCommand::isUndone ( ) const
inline

Returns whether the command has been undone since it was applied.

If a command is undone after it was originally executed, this will return true. If a command which was undone is redone this will return false.

This is used for memory management. If a command is destroyed (leaves the undo stack) it may need to delete objects associated with it. A command can leave the stack for two reasons:

  • It is at the bottom of the stack and the stack is full. Therefore this command needs to be deleted to free up space for new commands. In this case isUndone will return false.
  • The command has been undone and a new command has been pushed on top of the stack. In this case the current command is deleted and isUndone is true.

◆ owned()

Node * Model::UndoCommand::owned ( ) const
virtual

Returns the node owned by this command or nullptr if no node is owned.

Nodes which are owned should be deleted by the command when it is deleted.

Reimplemented in Model::NodeOwningCommand.

◆ redo()

void Model::UndoCommand::redo ( )
virtual

◆ removedNode()

Node * Model::UndoCommand::removedNode ( ) const
virtual

Returns the node that this command removed from the tree, or nullptr if no node was removed.

The default implementaion returns nullptr. Reimplement this in commands that own a node.

Reimplemented in Model::NodeOwningCommand.

◆ target()

Node * Model::UndoCommand::target ( ) const
inline

◆ undo()

void Model::UndoCommand::undo ( )
virtual

Member Data Documentation

◆ target_

Node* Model::UndoCommand::target_
private

◆ undone

bool Model::UndoCommand::undone
private