LibrePCB Developers Documentation
Loading...
Searching...
No Matches
UndoCommandGroup Class Reference

The UndoCommandGroup class makes it possible to pack multiple undo commands together (it acts as a parent of it's child commands) More...

#include <undocommandgroup.h>

+ Inheritance diagram for UndoCommandGroup:
+ Collaboration diagram for UndoCommandGroup:

Public Member Functions

 UndoCommandGroup ()=delete
 
 UndoCommandGroup (const UndoCommandGroup &other)=delete
 
 UndoCommandGroup (const QString &text) noexcept
 
virtual ~UndoCommandGroup () noexcept
 
int getChildCount () const noexcept
 
bool appendChild (UndoCommand *cmd)
 Append a new command to the list of child commands.
 
UndoCommandGroupoperator= (const UndoCommandGroup &rhs)=delete
 
- Public Member Functions inherited from UndoCommand
 UndoCommand ()=delete
 
 UndoCommand (const UndoCommand &other)=delete
 
 UndoCommand (const QString &text) noexcept
 
virtual ~UndoCommand () noexcept
 
const QString & getText () const noexcept
 
bool wasEverExecuted () const noexcept
 This method shows whether that command was ever executed (execute() called successfully)
 
bool wasEverReverted () const noexcept
 This method shows whether that command was ever reverted (undo() called at least one time)
 
bool isCurrentlyExecuted () const noexcept
 This method shows whether that command is currently executed (redo() called one time more than undo())
 
virtual bool execute () final
 Execute the command (must only be called once)
 
virtual void undo () final
 Undo the command.
 
virtual void redo () final
 Redo the command.
 
UndoCommandoperator= (const UndoCommand &rhs)=delete
 

Protected Member Functions

virtual bool performExecute () override
 Execute the command the first time.
 
virtual void performUndo () override
 Undo the command.
 
virtual void performRedo () override
 Redo the command.
 
virtual void performPostExecution () noexcept
 Perform custom actions after modifying the undo stack state.
 
void execNewChildCmd (UndoCommand *cmd)
 Helper method for derived classes to execute and add new child commands.
 

Private Attributes

bool mHasDoneSomething
 Memorized return value of performExecute()
 
QList< UndoCommand * > mChilds
 All child commands.
 

Detailed Description

The UndoCommandGroup class makes it possible to pack multiple undo commands together (it acts as a parent of it's child commands)

Constructor & Destructor Documentation

◆ UndoCommandGroup() [1/3]

UndoCommandGroup ( )
delete

◆ UndoCommandGroup() [2/3]

UndoCommandGroup ( const UndoCommandGroup other)
delete

◆ UndoCommandGroup() [3/3]

UndoCommandGroup ( const QString &  text)
explicitnoexcept

◆ ~UndoCommandGroup()

~UndoCommandGroup ( )
virtualnoexcept

Member Function Documentation

◆ getChildCount()

int getChildCount ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ appendChild()

bool appendChild ( UndoCommand cmd)

Append a new command to the list of child commands.

Parameters
cmdThe command to add (must not be executed already)
Return values
trueIf the command was executed and has done some changes
falseIf the command was not executed or has done nothing
Note
If this command was already executed (execute() called), this method will also immediately execute the newly added child command. Otherwise, it will be executed as soon as execute() is called.
Warning
This method must not be called after undo() was called the first time.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=()

UndoCommandGroup & operator= ( const UndoCommandGroup rhs)
delete

◆ performExecute()

bool performExecute ( )
overrideprotectedvirtual

Execute the command the first time.

Note
This method must be implemented in all derived classes. If the first time execution is exactly identical to an "redo" action, you can simple call librepcb::editor::UndoCommand::performRedo() in the implementation of this method.
Return values
trueIf the command has done some changes
falseIf the command has done nothing (the command can be deleted)

Implements UndoCommand.

Reimplemented in CmdDragSelectedFootprintItems, CmdDragSelectedSymbolItems, CmdPasteFootprintItems, CmdPasteSymbolItems, CmdRemoveSelectedFootprintItems, CmdRemoveSelectedSymbolItems, CmdAddComponentToCircuit, CmdAddDeviceToBoard, CmdAddSymbolToSchematic, CmdBoardSpecctraImport, CmdBoardSplitNetLine, CmdChangeNetSignalOfSchematicNetSegment, CmdCombineAllNetSignalsUnderSchematicNetPoint, CmdCombineBoardNetSegments, CmdCombineNetSignals, CmdCombineSchematicNetSegments, CmdDeviceStrokeTextsReset, CmdDragSelectedBoardItems, CmdDragSelectedSchematicItems, CmdFlipSelectedBoardItems, CmdPasteBoardItems, CmdPasteSchematicItems, CmdRemoveBoardItems, CmdRemoveSelectedSchematicItems, CmdRemoveUnusedLibraryElements, CmdRemoveUnusedNetSignals, CmdReplaceDevice, and CmdSymbolInstanceTextsReset.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performUndo()

void performUndo ( )
overrideprotectedvirtual

Undo the command.

Note
This method must be implemented in all derived classes.

Implements UndoCommand.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performRedo()

void performRedo ( )
overrideprotectedvirtual

Redo the command.

Note
This method must be implemented in all derived classes.

Implements UndoCommand.

+ Here is the call graph for this function:

◆ performPostExecution()

virtual void performPostExecution ( )
inlineprotectedvirtualnoexcept

Perform custom actions after modifying the undo stack state.

This gets called after performExecute(), performUndo() and performRedo() if any state was modified to perform additional tasks.

Attention
Must never throw any exception!

Reimplemented in CmdDragSelectedSchematicItems.

+ Here is the caller graph for this function:

◆ execNewChildCmd()

void execNewChildCmd ( UndoCommand cmd)
protected

Helper method for derived classes to execute and add new child commands.

Parameters
cmdThe command to execute and add (must not be executed already)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ mHasDoneSomething

bool mHasDoneSomething
private

Memorized return value of performExecute()

◆ mChilds

QList<UndoCommand*> mChilds
private

All child commands.

The child which is executed first is at index zero, the last executed command is at the top of the list.


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