QgsAbstractLayoutUndoCommand class

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

Constructors, destructors, conversion operators

QgsAbstractLayoutUndoCommand(const QString& text, int id = 0, QUndoCommand* parent = nullptr)
Constructor for QgsLayoutUndoCommand.

Public functions

auto afterState() const -> QDomDocument
Returns the after state for the layout.
auto beforeState() const -> QDomDocument
Returns the before state for the layout.
auto containsChange() const -> bool virtual
Returns true if both the before and after states are valid and different.
void saveAfterState()
Saves current layout state as after state.
void saveBeforeState()
Saves current layout state as before state.

Protected functions

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

Protected variables

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

Function documentation

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.

QDomDocument QgsAbstractLayoutUndoCommand::afterState() const

Returns the after state for the layout.

QDomDocument QgsAbstractLayoutUndoCommand::beforeState() const

Returns the before state for the layout.

void QgsAbstractLayoutUndoCommand::saveAfterState()

Saves current layout state as after state.

void QgsAbstractLayoutUndoCommand::saveBeforeState()

Saves current layout state as before state.

void QgsAbstractLayoutUndoCommand::restoreState(QDomDocument& stateDoc) pure virtual protected

Restores the state of the object from the specified stateDoc.

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

void QgsAbstractLayoutUndoCommand::saveState(QDomDocument& stateDoc) const pure virtual protected

Saves the state of the object to the specified stateDoc.

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

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

Manually sets the after state for the command.

Generally this should not be called directly.