LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UndoCommand Class Referenceabstract

The UndoCommand class represents a command which you can undo/redo. More...

#include <undocommand.h>

+ Inheritance diagram for UndoCommand:
+ Collaboration diagram for UndoCommand:

Public Member Functions

 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) More...
 
bool wasEverReverted () const noexcept
 This method shows whether that command was ever reverted (undo() called at least one time) More...
 
bool isCurrentlyExecuted () const noexcept
 This method shows whether that command is currently executed (redo() called one time more than undo()) More...
 
virtual bool execute () final
 Execute the command (must only be called once) More...
 
virtual void undo () final
 Undo the command. More...
 
virtual void redo () final
 Redo the command. More...
 
UndoCommandoperator= (const UndoCommand &rhs)=delete
 

Protected Member Functions

virtual bool performExecute ()=0
 Execute the command the first time. More...
 
virtual void performUndo ()=0
 Undo the command. More...
 
virtual void performRedo ()=0
 Redo the command. More...
 

Private Attributes

QString mText
 
bool mIsExecuted
 Shows whether execute() was called or not. More...
 
int mRedoCount
 Counter of how often redo() was called. More...
 
int mUndoCount
 Counter of how often undo() was called. More...
 

Detailed Description

The UndoCommand class represents a command which you can undo/redo.

See description of librepcb::UndoStack for more details about the whole concept.

See Also
librepcb::UndoStack
Author
ubruhin
Date
2014-08-20
Todo:
Write unit tests

Constructor & Destructor Documentation

UndoCommand ( )
delete
UndoCommand ( const UndoCommand other)
delete
UndoCommand ( const QString &  text)
explicitnoexcept
~UndoCommand ( )
virtualnoexcept

Member Function Documentation

const QString& getText ( ) const
inlinenoexcept

+ Here is the caller graph for this function:

bool wasEverExecuted ( ) const
inlinenoexcept

This method shows whether that command was ever executed (execute() called successfully)

+ Here is the caller graph for this function:

bool wasEverReverted ( ) const
inlinenoexcept

This method shows whether that command was ever reverted (undo() called at least one time)

+ Here is the caller graph for this function:

bool isCurrentlyExecuted ( ) const
inlinenoexcept

This method shows whether that command is currently executed (redo() called one time more than undo())

+ Here is the caller graph for this function:

bool execute ( )
finalvirtual

Execute the command (must only be called once)

Return values
trueIf the command has done some changes
falseIf the command has done nothing (the command can be deleted)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void undo ( )
finalvirtual

Undo the command.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void redo ( )
finalvirtual

Redo the command.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

UndoCommand& operator= ( const UndoCommand rhs)
delete
virtual bool performExecute ( )
protectedpure virtual

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 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)

Implemented in CmdRemoveBoardItems, CmdStrokeTextEdit, UndoCommandGroup, CmdMoveSelectedFootprintItems, CmdMoveSelectedSymbolItems, CmdAddDeviceToBoard, CmdAddSymbolToSchematic, CmdRemoveSelectedSchematicItems, CmdAddComponentToCircuit, CmdBoardNetSegmentAddElements, CmdBoardPlaneEdit, CmdFootprintPadEdit, CmdLibraryBaseElementEdit, CmdMoveSelectedBoardItems, CmdPolygonEdit, CmdComponentInstanceAdd, CmdComponentInstanceEdit, CmdCircleEdit, CmdTextEdit, CmdSymbolPinEdit, CmdRotateSelectedFootprintItems, CmdRotateSelectedSymbolItems, CmdCombineSchematicNetSegments, CmdComponentSymbolVariantEdit, CmdRemoveSelectedFootprintItems, CmdRemoveSelectedSymbolItems, CmdComponentSignalEdit, CmdBoardViaEdit, CmdSchematicNetSegmentAddElements, CmdCombineBoardNetSegments, CmdReplaceDevice, CmdHoleEdit, CmdDeviceInstanceEdit, CmdSymbolInstanceEdit, CmdChangeNetSignalOfSchematicNetSegment, CmdMoveSelectedSchematicItems, CmdComponentEdit, CmdDevicePadSignalMapItemEdit, CmdFootprintEdit, CmdNetSignalAdd, CmdCombineAllNetSignalsUnderSchematicNetPoint, CmdListElementInsert< T, P >, CmdDeviceEdit, CmdPackagePadEdit, CmdBoardNetSegmentRemoveElements, CmdSchematicNetLabelAdd, CmdSchematicNetLabelEdit, CmdListElementRemove< T, P >, CmdLibraryEdit, CmdBoardAdd, CmdDeviceInstanceAdd, CmdSchematicNetSegmentAdd, CmdListElementsSwap< T, P >, CmdLibraryElementEdit, CmdBoardNetSegmentAdd, CmdProjectMetadataEdit, CmdSchematicNetSegmentRemoveElements, CmdRemoveSelectedBoardItems, CmdLibraryCategoryEdit, CmdBoardLayerStackEdit, CmdBoardNetPointEdit, CmdNetClassAdd, CmdNetClassEdit, CmdNetSignalEdit, CmdSchematicAdd, CmdSchematicNetPointEdit, CmdProjectSettingsChange, CmdBoardDesignRulesModify, CmdBoardHoleAdd, CmdBoardNetSegmentEdit, CmdBoardPolygonAdd, CmdBoardStrokeTextAdd, CmdSchematicNetSegmentEdit, CmdCombineNetSignals, CmdFlipSelectedBoardItems, CmdMirrorSelectedSchematicItems, CmdRotateSelectedSchematicItems, CmdProjectLibraryAddElement< ElementType >, CmdSchematicNetLabelAnchorsUpdate, CmdRemoveUnusedNetSignals, CmdRotateSelectedBoardItems, CmdBoardNetLineEdit, CmdFootprintStrokeTextAdd, CmdFootprintStrokeTextRemove, CmdCompSigInstSetNetSignal, CmdProjectLibraryRemoveElement< ElementType >, CmdSchematicNetLabelRemove, CmdSymbolInstanceAdd, CmdBoardHoleRemove, CmdBoardNetSegmentRemove, CmdBoardPlaneAdd, CmdBoardPlaneRemove, CmdBoardPolygonRemove, CmdBoardRemove, CmdBoardStrokeTextRemove, CmdDeviceInstanceRemove, CmdComponentInstanceRemove, CmdNetClassRemove, CmdNetSignalRemove, CmdSchematicNetSegmentRemove, CmdSchematicRemove, CmdSymbolInstanceRemove, CmdFootprintStrokeTextsReset, and CmdRemoveUnusedLibraryElements.

+ Here is the caller graph for this function:

virtual void performUndo ( )
protectedpure virtual

Undo the command.

Note
This method must be implemented in all derived classes.

Implemented in CmdStrokeTextEdit, UndoCommandGroup, CmdBoardNetSegmentAddElements, CmdBoardPlaneEdit, CmdFootprintPadEdit, CmdLibraryBaseElementEdit, CmdPolygonEdit, CmdComponentInstanceAdd, CmdComponentInstanceEdit, CmdCircleEdit, CmdTextEdit, CmdSymbolPinEdit, CmdListElementInsert< T, P >, CmdListElementRemove< T, P >, CmdComponentSymbolVariantEdit, CmdComponentSignalEdit, CmdBoardViaEdit, CmdSchematicNetSegmentAddElements, CmdHoleEdit, CmdDeviceInstanceEdit, CmdSymbolInstanceEdit, CmdListElementsSwap< T, P >, CmdComponentEdit, CmdDevicePadSignalMapItemEdit, CmdFootprintEdit, CmdNetSignalAdd, CmdDeviceEdit, CmdPackagePadEdit, CmdBoardNetSegmentRemoveElements, CmdSchematicNetLabelAdd, CmdSchematicNetLabelEdit, CmdLibraryEdit, CmdBoardAdd, CmdDeviceInstanceAdd, CmdSchematicNetSegmentAdd, CmdLibraryElementEdit, CmdBoardNetSegmentAdd, CmdProjectMetadataEdit, CmdSchematicNetSegmentRemoveElements, CmdRemoveSelectedBoardItems, CmdLibraryCategoryEdit, CmdBoardLayerStackEdit, CmdBoardNetPointEdit, CmdNetClassAdd, CmdNetClassEdit, CmdNetSignalEdit, CmdSchematicAdd, CmdSchematicNetPointEdit, CmdProjectSettingsChange, CmdBoardDesignRulesModify, CmdBoardHoleAdd, CmdBoardNetSegmentEdit, CmdBoardPolygonAdd, CmdBoardStrokeTextAdd, CmdSchematicNetSegmentEdit, CmdProjectLibraryAddElement< ElementType >, CmdSchematicNetLabelAnchorsUpdate, CmdBoardNetLineEdit, CmdFootprintStrokeTextAdd, CmdFootprintStrokeTextRemove, CmdCompSigInstSetNetSignal, CmdProjectLibraryRemoveElement< ElementType >, CmdSchematicNetLabelRemove, CmdSymbolInstanceAdd, CmdBoardHoleRemove, CmdBoardNetSegmentRemove, CmdBoardPlaneAdd, CmdBoardPlaneRemove, CmdBoardPolygonRemove, CmdBoardRemove, CmdBoardStrokeTextRemove, CmdDeviceInstanceRemove, CmdComponentInstanceRemove, CmdNetClassRemove, CmdNetSignalRemove, CmdSchematicNetSegmentRemove, CmdSchematicRemove, and CmdSymbolInstanceRemove.

+ Here is the caller graph for this function:

virtual void performRedo ( )
protectedpure virtual

Redo the command.

Note
This method must be implemented in all derived classes.

Implemented in CmdStrokeTextEdit, UndoCommandGroup, CmdBoardNetSegmentAddElements, CmdBoardPlaneEdit, CmdFootprintPadEdit, CmdLibraryBaseElementEdit, CmdPolygonEdit, CmdComponentInstanceAdd, CmdComponentInstanceEdit, CmdCircleEdit, CmdTextEdit, CmdSymbolPinEdit, CmdListElementInsert< T, P >, CmdListElementRemove< T, P >, CmdComponentSymbolVariantEdit, CmdComponentSignalEdit, CmdBoardViaEdit, CmdSchematicNetSegmentAddElements, CmdHoleEdit, CmdDeviceInstanceEdit, CmdSymbolInstanceEdit, CmdListElementsSwap< T, P >, CmdComponentEdit, CmdDevicePadSignalMapItemEdit, CmdFootprintEdit, CmdNetSignalAdd, CmdDeviceEdit, CmdPackagePadEdit, CmdBoardNetSegmentRemoveElements, CmdSchematicNetLabelAdd, CmdSchematicNetLabelEdit, CmdLibraryEdit, CmdBoardAdd, CmdDeviceInstanceAdd, CmdSchematicNetSegmentAdd, CmdLibraryElementEdit, CmdBoardNetSegmentAdd, CmdProjectMetadataEdit, CmdSchematicNetSegmentRemoveElements, CmdRemoveSelectedBoardItems, CmdLibraryCategoryEdit, CmdBoardLayerStackEdit, CmdBoardNetPointEdit, CmdNetClassAdd, CmdNetClassEdit, CmdNetSignalEdit, CmdSchematicAdd, CmdSchematicNetPointEdit, CmdProjectSettingsChange, CmdBoardDesignRulesModify, CmdBoardHoleAdd, CmdBoardNetSegmentEdit, CmdBoardPolygonAdd, CmdBoardStrokeTextAdd, CmdSchematicNetSegmentEdit, CmdProjectLibraryAddElement< ElementType >, CmdSchematicNetLabelAnchorsUpdate, CmdBoardNetLineEdit, CmdFootprintStrokeTextAdd, CmdFootprintStrokeTextRemove, CmdCompSigInstSetNetSignal, CmdProjectLibraryRemoveElement< ElementType >, CmdSchematicNetLabelRemove, CmdSymbolInstanceAdd, CmdBoardHoleRemove, CmdBoardNetSegmentRemove, CmdBoardPlaneAdd, CmdBoardPlaneRemove, CmdBoardPolygonRemove, CmdBoardRemove, CmdBoardStrokeTextRemove, CmdDeviceInstanceRemove, CmdComponentInstanceRemove, CmdNetClassRemove, CmdNetSignalRemove, CmdSchematicNetSegmentRemove, CmdSchematicRemove, and CmdSymbolInstanceRemove.

+ Here is the caller graph for this function:

Member Data Documentation

QString mText
private
bool mIsExecuted
private

Shows whether execute() was called or not.

int mRedoCount
private

Counter of how often redo() was called.

int mUndoCount
private

Counter of how often undo() was called.


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