QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
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.
 
QDomDocument afterState () const
 Returns the after state for the layout.
 
QDomDocument beforeState () const
 Returns the before state for the layout.
 
virtual bool containsChange () const
 Returns true if both the before and after states are valid and different.
 
int id () const override
 
void redo () override
 
void saveAfterState ()
 Saves current layout state as after state.
 
void saveBeforeState ()
 Saves current layout state as before state.
 
void undo () override
 

Protected Member Functions

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

Protected Attributes

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

Detailed Description

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

Definition at line 33 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 74 of file qgslayoutundocommand.h.

◆ beforeState()

QDomDocument QgsAbstractLayoutUndoCommand::beforeState ( ) const
inline

Returns the before state for the layout.

See also
saveBeforeState()
afterState()

Definition at line 67 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 46 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 107 of file qgslayoutundocommand.h.


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