QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
Signals | Public Member Functions | List of all members
QgsLayoutUndoStack Class Reference

An undo stack for QgsLayouts. More...

#include <qgslayoutundostack.h>

Inheritance diagram for QgsLayoutUndoStack:
Inheritance graph
[legend]

Signals

void undoRedoOccurredForItems (QSet< QString > itemUuids)
 Emitted when an undo or redo action has occurred, which affected a set of layout itemUuids. More...
 

Public Member Functions

 QgsLayoutUndoStack (QgsLayout *layout)
 Constructor for QgsLayoutUndoStack, for the specified parent layout. More...
 
void beginCommand (QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
 Begins a new undo command for the specified object. More...
 
void beginMacro (const QString &commandText)
 Starts a macro command, with the given descriptive commandText. More...
 
void blockCommands (bool blocked)
 Sets whether undo commands for the layout should be temporarily blocked. More...
 
void cancelCommand ()
 Cancels the active command, discarding it without pushing to the undo history. More...
 
void endCommand ()
 Saves final state of an object and pushes the active command to the undo history. More...
 
void endMacro ()
 Ends a macro command. More...
 
bool isBlocked () const
 Returns true if undo commands are currently blocked. More...
 
void notifyUndoRedoOccurred (QgsLayoutItem *item)
 Notifies the stack that an undo or redo action occurred for a specified item. More...
 
void push (QUndoCommand *command)
 Manually pushes a command to the stack, and takes ownership of the command. More...
 
QUndoStack * stack ()
 Returns a pointer to the internal QUndoStack. More...
 

Detailed Description

An undo stack for QgsLayouts.

Since
QGIS 3.0

Definition at line 36 of file qgslayoutundostack.h.

Constructor & Destructor Documentation

◆ QgsLayoutUndoStack()

QgsLayoutUndoStack::QgsLayoutUndoStack ( QgsLayout layout)

Constructor for QgsLayoutUndoStack, for the specified parent layout.

Definition at line 23 of file qgslayoutundostack.cpp.

Member Function Documentation

◆ beginCommand()

void QgsLayoutUndoStack::beginCommand ( QgsLayoutUndoObjectInterface object,
const QString &  commandText,
int  id = 0 
)

Begins a new undo command for the specified object.

This must be followed by a call to endCommand() or cancelCommand() after the desired changes have been made to object.

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.

See also
endCommand()
cancelCommand()

Definition at line 42 of file qgslayoutundostack.cpp.

◆ beginMacro()

void QgsLayoutUndoStack::beginMacro ( const QString &  commandText)

Starts a macro command, with the given descriptive commandText.

Any commands added to the stack (either via direct manipulation of stack() or via beginCommand()/endCommand() calls) between a beginMacro() and endMacro() block are collapsed into a single undo command, which will be applied or rolled back in a single step.

See also
endMacro()

Definition at line 30 of file qgslayoutundostack.cpp.

◆ blockCommands()

void QgsLayoutUndoStack::blockCommands ( bool  blocked)

Sets whether undo commands for the layout should be temporarily blocked.

If blocked is true, subsequent undo commands will be blocked until a follow-up call to blockCommands( false ) is made.

Note that calls to blockCommands are stacked, so two calls blocking the commands will take two calls unblocking commands in order to release the block.

See also
isBlocked()

Definition at line 86 of file qgslayoutundostack.cpp.

◆ cancelCommand()

void QgsLayoutUndoStack::cancelCommand ( )

Cancels the active command, discarding it without pushing to the undo history.

See also
endCommand()
cancelCommand()

Definition at line 68 of file qgslayoutundostack.cpp.

◆ endCommand()

void QgsLayoutUndoStack::endCommand ( )

Saves final state of an object and pushes the active command to the undo history.

See also
beginCommand()
cancelCommand()

Definition at line 53 of file qgslayoutundostack.cpp.

◆ endMacro()

void QgsLayoutUndoStack::endMacro ( )

Ends a macro command.

This must be called after beginMacro(), when all child undo commands which form part of the macro have been completed.

Any commands added to the stack (either via direct manipulation of stack() or via beginCommand()/endCommand() calls) between a beginMacro() and endMacro() block are collapsed into a single undo command, which will be applied or rolled back in a single step.

See also
beginMacro()

Definition at line 36 of file qgslayoutundostack.cpp.

◆ isBlocked()

bool QgsLayoutUndoStack::isBlocked ( ) const

Returns true if undo commands are currently blocked.

See also
blockCommands()

Definition at line 99 of file qgslayoutundostack.cpp.

◆ notifyUndoRedoOccurred()

void QgsLayoutUndoStack::notifyUndoRedoOccurred ( QgsLayoutItem item)

Notifies the stack that an undo or redo action occurred for a specified item.

Definition at line 81 of file qgslayoutundostack.cpp.

◆ push()

void QgsLayoutUndoStack::push ( QUndoCommand *  command)

Manually pushes a command to the stack, and takes ownership of the command.

Definition at line 104 of file qgslayoutundostack.cpp.

◆ stack()

QUndoStack * QgsLayoutUndoStack::stack ( )

Returns a pointer to the internal QUndoStack.

Definition at line 76 of file qgslayoutundostack.cpp.

◆ undoRedoOccurredForItems

void QgsLayoutUndoStack::undoRedoOccurredForItems ( QSet< QString >  itemUuids)
signal

Emitted when an undo or redo action has occurred, which affected a set of layout itemUuids.


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