LibrePCB Developers Documentation
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::editor::UndoStack for more details about the whole concept.

See also
librepcb::editor::UndoStack

Constructor & Destructor Documentation

◆ UndoCommand() [1/3]

UndoCommand ( )
delete

◆ UndoCommand() [2/3]

UndoCommand ( const UndoCommand other)
delete

◆ UndoCommand() [3/3]

UndoCommand ( const QString &  text)
explicitnoexcept

◆ ~UndoCommand()

~UndoCommand ( )
virtualnoexcept

Member Function Documentation

◆ getText()

const QString & getText ( ) const
inlinenoexcept
+ Here is the caller graph for this function:

◆ wasEverExecuted()

bool wasEverExecuted ( ) const
inlinenoexcept

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

+ Here is the caller graph for this function:

◆ wasEverReverted()

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:

◆ isCurrentlyExecuted()

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:

◆ execute()

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:

◆ undo()

void undo ( )
finalvirtual

Undo the command.

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

◆ redo()

void redo ( )
finalvirtual

Redo the command.

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

◆ operator=()

UndoCommand & operator= ( const UndoCommand rhs)
delete

◆ performExecute()

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

Implemented in CmdAttributeEdit, CmdCircleEdit, CmdHoleEdit, CmdListElementInsert< T, P, OnEditedArgs >, CmdListElementRemove< T, P, OnEditedArgs >, CmdListElementsSwap< T, P, OnEditedArgs >, CmdPolygonEdit, CmdStrokeTextEdit, CmdTextEdit, CmdZoneEdit, CmdComponentEdit, CmdComponentPinSignalMapItemEdit, CmdComponentSignalEdit, CmdComponentSymbolVariantEdit, CmdComponentSymbolVariantItemEdit, CmdDeviceEdit, CmdDevicePadSignalMapItemEdit, CmdDragSelectedFootprintItems, CmdDragSelectedSymbolItems, CmdFootprintEdit, CmdFootprintPadEdit, CmdLibraryBaseElementEdit, CmdLibraryCategoryEdit, CmdLibraryEdit, CmdLibraryElementEdit, CmdPackageEdit, CmdPackageModelAdd, CmdPackageModelEdit, CmdPackageModelRemove, CmdPackagePadEdit, CmdPartEdit, CmdPasteFootprintItems, CmdPasteSymbolItems, CmdRemoveSelectedFootprintItems, CmdRemoveSelectedSymbolItems, CmdSymbolPinEdit, CmdAddComponentToCircuit, CmdAddDeviceToBoard, CmdAddSymbolToSchematic, CmdAssemblyVariantAdd, CmdAssemblyVariantEdit, CmdAssemblyVariantRemove, CmdBoardAdd, CmdBoardEdit, CmdBoardHoleAdd, CmdBoardHoleEdit, CmdBoardHoleRemove, CmdBoardNetLineEdit, CmdBoardNetPointEdit, CmdBoardNetSegmentAdd, CmdBoardNetSegmentAddElements, CmdBoardNetSegmentEdit, CmdBoardNetSegmentRemove, CmdBoardNetSegmentRemoveElements, CmdBoardPlaneAdd, CmdBoardPlaneEdit, CmdBoardPlaneRemove, CmdBoardPolygonAdd, CmdBoardPolygonEdit, CmdBoardPolygonRemove, CmdBoardRemove, CmdBoardSplitNetLine, CmdBoardStrokeTextAdd, CmdBoardStrokeTextEdit, CmdBoardStrokeTextRemove, CmdBoardViaEdit, CmdBoardZoneAdd, CmdBoardZoneEdit, CmdBoardZoneRemove, CmdChangeNetSignalOfSchematicNetSegment, CmdCombineAllNetSignalsUnderSchematicNetPoint, CmdCombineBoardNetSegments, CmdCombineNetSignals, CmdCombineSchematicNetSegments, CmdComponentInstanceAdd, CmdComponentInstanceEdit, CmdComponentInstanceRemove, CmdCompSigInstSetNetSignal, CmdDeviceInstanceAdd, CmdDeviceInstanceEdit, CmdDeviceInstanceRemove, CmdDeviceStrokeTextAdd, CmdDeviceStrokeTextRemove, CmdDeviceStrokeTextsReset, CmdDragSelectedBoardItems, CmdDragSelectedSchematicItems, CmdFlipSelectedBoardItems, CmdNetClassAdd, CmdNetClassEdit, CmdNetClassRemove, CmdNetSignalAdd, CmdNetSignalEdit, CmdNetSignalRemove, CmdPasteBoardItems, CmdPasteSchematicItems, CmdProjectEdit, CmdProjectLibraryAddElement< ElementType >, CmdProjectLibraryRemoveElement< ElementType >, CmdRemoveBoardItems, CmdRemoveSelectedBoardItems, CmdRemoveSelectedSchematicItems, CmdRemoveUnusedLibraryElements, CmdRemoveUnusedNetSignals, CmdReplaceDevice, CmdSchematicAdd, CmdSchematicEdit, CmdSchematicNetLabelAdd, CmdSchematicNetLabelEdit, CmdSchematicNetLabelRemove, CmdSchematicNetPointEdit, CmdSchematicNetSegmentAdd, CmdSchematicNetSegmentAddElements, CmdSchematicNetSegmentEdit, CmdSchematicNetSegmentRemove, CmdSchematicNetSegmentRemoveElements, CmdSchematicPolygonAdd, CmdSchematicPolygonRemove, CmdSchematicRemove, CmdSchematicTextAdd, CmdSchematicTextRemove, CmdSymbolInstanceAdd, CmdSymbolInstanceEdit, CmdSymbolInstanceRemove, CmdSymbolInstanceTextAdd, CmdSymbolInstanceTextRemove, CmdSymbolInstanceTextsReset, and UndoCommandGroup.

+ Here is the caller graph for this function:

◆ performUndo()

virtual void performUndo ( )
protectedpure virtual

Undo the command.

Note
This method must be implemented in all derived classes.

Implemented in CmdAttributeEdit, CmdCircleEdit, CmdHoleEdit, CmdListElementInsert< T, P, OnEditedArgs >, CmdListElementRemove< T, P, OnEditedArgs >, CmdListElementsSwap< T, P, OnEditedArgs >, CmdPolygonEdit, CmdStrokeTextEdit, CmdTextEdit, CmdZoneEdit, CmdComponentEdit, CmdComponentPinSignalMapItemEdit, CmdComponentSignalEdit, CmdComponentSymbolVariantEdit, CmdComponentSymbolVariantItemEdit, CmdDeviceEdit, CmdDevicePadSignalMapItemEdit, CmdFootprintEdit, CmdFootprintPadEdit, CmdLibraryBaseElementEdit, CmdLibraryCategoryEdit, CmdLibraryEdit, CmdLibraryElementEdit, CmdPackageEdit, CmdPackageModelAdd, CmdPackageModelEdit, CmdPackageModelRemove, CmdPackagePadEdit, CmdPartEdit, CmdSymbolPinEdit, CmdAssemblyVariantAdd, CmdAssemblyVariantEdit, CmdAssemblyVariantRemove, CmdBoardAdd, CmdBoardEdit, CmdBoardHoleAdd, CmdBoardHoleEdit, CmdBoardHoleRemove, CmdBoardNetLineEdit, CmdBoardNetPointEdit, CmdBoardNetSegmentAdd, CmdBoardNetSegmentAddElements, CmdBoardNetSegmentEdit, CmdBoardNetSegmentRemove, CmdBoardNetSegmentRemoveElements, CmdBoardPlaneAdd, CmdBoardPlaneEdit, CmdBoardPlaneRemove, CmdBoardPolygonAdd, CmdBoardPolygonEdit, CmdBoardPolygonRemove, CmdBoardRemove, CmdBoardStrokeTextAdd, CmdBoardStrokeTextEdit, CmdBoardStrokeTextRemove, CmdBoardViaEdit, CmdBoardZoneAdd, CmdBoardZoneEdit, CmdBoardZoneRemove, CmdComponentInstanceAdd, CmdComponentInstanceEdit, CmdComponentInstanceRemove, CmdCompSigInstSetNetSignal, CmdDeviceInstanceAdd, CmdDeviceInstanceEdit, CmdDeviceInstanceRemove, CmdDeviceStrokeTextAdd, CmdDeviceStrokeTextRemove, CmdNetClassAdd, CmdNetClassEdit, CmdNetClassRemove, CmdNetSignalAdd, CmdNetSignalEdit, CmdNetSignalRemove, CmdProjectEdit, CmdProjectLibraryAddElement< ElementType >, CmdProjectLibraryRemoveElement< ElementType >, CmdRemoveSelectedBoardItems, CmdSchematicAdd, CmdSchematicEdit, CmdSchematicNetLabelAdd, CmdSchematicNetLabelEdit, CmdSchematicNetLabelRemove, CmdSchematicNetPointEdit, CmdSchematicNetSegmentAdd, CmdSchematicNetSegmentAddElements, CmdSchematicNetSegmentEdit, CmdSchematicNetSegmentRemove, CmdSchematicNetSegmentRemoveElements, CmdSchematicPolygonAdd, CmdSchematicPolygonRemove, CmdSchematicRemove, CmdSchematicTextAdd, CmdSchematicTextRemove, CmdSymbolInstanceAdd, CmdSymbolInstanceEdit, CmdSymbolInstanceRemove, CmdSymbolInstanceTextAdd, CmdSymbolInstanceTextRemove, and UndoCommandGroup.

+ Here is the caller graph for this function:

◆ performRedo()

virtual void performRedo ( )
protectedpure virtual

Redo the command.

Note
This method must be implemented in all derived classes.

Implemented in CmdAttributeEdit, CmdCircleEdit, CmdHoleEdit, CmdListElementInsert< T, P, OnEditedArgs >, CmdListElementRemove< T, P, OnEditedArgs >, CmdListElementsSwap< T, P, OnEditedArgs >, CmdPolygonEdit, CmdStrokeTextEdit, CmdTextEdit, CmdZoneEdit, CmdComponentEdit, CmdComponentPinSignalMapItemEdit, CmdComponentSignalEdit, CmdComponentSymbolVariantEdit, CmdComponentSymbolVariantItemEdit, CmdDeviceEdit, CmdDevicePadSignalMapItemEdit, CmdFootprintEdit, CmdFootprintPadEdit, CmdLibraryBaseElementEdit, CmdLibraryCategoryEdit, CmdLibraryEdit, CmdLibraryElementEdit, CmdPackageEdit, CmdPackageModelAdd, CmdPackageModelEdit, CmdPackageModelRemove, CmdPackagePadEdit, CmdPartEdit, CmdSymbolPinEdit, CmdAssemblyVariantAdd, CmdAssemblyVariantEdit, CmdAssemblyVariantRemove, CmdBoardAdd, CmdBoardEdit, CmdBoardHoleAdd, CmdBoardHoleEdit, CmdBoardHoleRemove, CmdBoardNetLineEdit, CmdBoardNetPointEdit, CmdBoardNetSegmentAdd, CmdBoardNetSegmentAddElements, CmdBoardNetSegmentEdit, CmdBoardNetSegmentRemove, CmdBoardNetSegmentRemoveElements, CmdBoardPlaneAdd, CmdBoardPlaneEdit, CmdBoardPlaneRemove, CmdBoardPolygonAdd, CmdBoardPolygonEdit, CmdBoardPolygonRemove, CmdBoardRemove, CmdBoardStrokeTextAdd, CmdBoardStrokeTextEdit, CmdBoardStrokeTextRemove, CmdBoardViaEdit, CmdBoardZoneAdd, CmdBoardZoneEdit, CmdBoardZoneRemove, CmdComponentInstanceAdd, CmdComponentInstanceEdit, CmdComponentInstanceRemove, CmdCompSigInstSetNetSignal, CmdDeviceInstanceAdd, CmdDeviceInstanceEdit, CmdDeviceInstanceRemove, CmdDeviceStrokeTextAdd, CmdDeviceStrokeTextRemove, CmdNetClassAdd, CmdNetClassEdit, CmdNetClassRemove, CmdNetSignalAdd, CmdNetSignalEdit, CmdNetSignalRemove, CmdProjectEdit, CmdProjectLibraryAddElement< ElementType >, CmdProjectLibraryRemoveElement< ElementType >, CmdRemoveSelectedBoardItems, CmdSchematicAdd, CmdSchematicEdit, CmdSchematicNetLabelAdd, CmdSchematicNetLabelEdit, CmdSchematicNetLabelRemove, CmdSchematicNetPointEdit, CmdSchematicNetSegmentAdd, CmdSchematicNetSegmentAddElements, CmdSchematicNetSegmentEdit, CmdSchematicNetSegmentRemove, CmdSchematicNetSegmentRemoveElements, CmdSchematicPolygonAdd, CmdSchematicPolygonRemove, CmdSchematicRemove, CmdSchematicTextAdd, CmdSchematicTextRemove, CmdSymbolInstanceAdd, CmdSymbolInstanceEdit, CmdSymbolInstanceRemove, CmdSymbolInstanceTextAdd, CmdSymbolInstanceTextRemove, and UndoCommandGroup.

+ Here is the caller graph for this function:

Member Data Documentation

◆ mText

QString mText
private

◆ mIsExecuted

bool mIsExecuted
private

Shows whether execute() was called or not.

◆ mRedoCount

int mRedoCount
private

Counter of how often redo() was called.

◆ mUndoCount

int mUndoCount
private

Counter of how often undo() was called.


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