QGIS API Documentation  3.20.0-Odense (decaadbb31)
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsAbstractLayoutUndoCommand Class Referenceabstract

Base class for commands to undo/redo layout and layout object changes. More...

#include <qgslayoutundocommand.h>

Inheritance diagram for QgsAbstractLayoutUndoCommand:
Inheritance graph
[legend]

Public Member Functions

 QgsAbstractLayoutUndoCommand (const QString &text, int id=0, QUndoCommand *parent=nullptr)
 Constructor for QgsLayoutUndoCommand. More...
 
QDomDocument afterState () const
 Returns the after state for the layout. More...
 
QDomDocument beforeState () const
 Returns the before state for the layout. More...
 
virtual bool containsChange () const
 Returns true if both the before and after states are valid and different. More...
 
int id () const override
 
void redo () override
 
void saveAfterState ()
 Saves current layout state as after state. More...
 
void saveBeforeState ()
 Saves current layout state as before state. More...
 
void undo () override
 

Protected Member Functions

virtual void restoreState (QDomDocument &stateDoc)=0
 Restores the state of the object from the specified stateDoc. More...
 
virtual void saveState (QDomDocument &stateDoc) const =0
 Saves the state of the object to the specified stateDoc. More...
 
void setAfterState (const QDomDocument &stateDoc)
 Manually sets the after state for the command. More...
 

Protected Attributes

bool mFirstRun = true
 Flag to prevent the first redo() if the command is pushed to the undo stack. More...
 

Detailed Description

Base class for commands to undo/redo layout and layout object changes.

Since
QGIS 3.0

Definition at line 34 of file qgslayoutundocommand.h.

Constructor & Destructor Documentation

◆ QgsAbstractLayoutUndoCommand()

QgsAbstractLayoutUndoCommand::QgsAbstractLayoutUndoCommand ( const QString &  text,
int  id = 0,
QUndoCommand *  parent = nullptr 
)

Constructor for QgsLayoutUndoCommand.

The id argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand command compression can apply to the command.

Definition at line 21 of file qgslayoutundocommand.cpp.

Member Function Documentation

◆ afterState()

QDomDocument QgsAbstractLayoutUndoCommand::afterState ( ) const
inline

Returns the after state for the layout.

See also
saveAfterState()
beforeState()

Definition at line 75 of file qgslayoutundocommand.h.

◆ beforeState()

QDomDocument QgsAbstractLayoutUndoCommand::beforeState ( ) const
inline

Returns the before state for the layout.

See also
saveBeforeState()
afterState()

Definition at line 68 of file qgslayoutundocommand.h.

◆ containsChange()

bool QgsAbstractLayoutUndoCommand::containsChange ( ) const
virtual

Returns true if both the before and after states are valid and different.

Definition at line 53 of file qgslayoutundocommand.cpp.

◆ id()

int QgsAbstractLayoutUndoCommand::id ( ) const
inlineoverride

Definition at line 47 of file qgslayoutundocommand.h.

◆ redo()

void QgsAbstractLayoutUndoCommand::redo ( )
override

Definition at line 32 of file qgslayoutundocommand.cpp.

◆ restoreState()

virtual void QgsAbstractLayoutUndoCommand::restoreState ( QDomDocument &  stateDoc)
protectedpure virtual

Restores the state of the object from the specified stateDoc.

Subclasses must implement this to handle restoring their current state from the encapsulated state.

See also
saveState()

◆ saveAfterState()

void QgsAbstractLayoutUndoCommand::saveAfterState ( )

Saves current layout state as after state.

See also
afterState()
saveBeforeState()

Definition at line 48 of file qgslayoutundocommand.cpp.

◆ saveBeforeState()

void QgsAbstractLayoutUndoCommand::saveBeforeState ( )

Saves current layout state as before state.

See also
beforeState()
saveAfterState()

Definition at line 43 of file qgslayoutundocommand.cpp.

◆ saveState()

virtual void QgsAbstractLayoutUndoCommand::saveState ( QDomDocument &  stateDoc) const
protectedpure virtual

Saves the state of the object to the specified stateDoc.

Subclasses must implement this to handle encapsulating their current state into a DOM document.

See also
restoreState()

◆ setAfterState()

void QgsAbstractLayoutUndoCommand::setAfterState ( const QDomDocument &  stateDoc)
protected

Manually sets the after state for the command.

Generally this should not be called directly.

Definition at line 58 of file qgslayoutundocommand.cpp.

◆ undo()

void QgsAbstractLayoutUndoCommand::undo ( )
override

Definition at line 26 of file qgslayoutundocommand.cpp.

Member Data Documentation

◆ mFirstRun

bool QgsAbstractLayoutUndoCommand::mFirstRun = true
protected

Flag to prevent the first redo() if the command is pushed to the undo stack.

Definition at line 108 of file qgslayoutundocommand.h.


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