Class: QgsLayoutUndoStack¶
- class qgis.core.QgsLayoutUndoStack(layout: QgsLayout)¶
Bases:
PyQt5.QtCore.QObject
Constructor for
QgsLayoutUndoStack
, for the specified parentlayout
.An undo stack for
QgsLayouts
.Methods
Begins a new undo command for the specified
object
.Starts a macro command, with the given descriptive
commandText
.Sets whether undo commands for the layout should be temporarily blocked.
Cancels the active command, discarding it without pushing to the undo history.
Saves final state of an object and pushes the active command to the undo history.
Ends a macro command.
Returns
True
if undo commands are currently blocked.Notifies the stack that an undo or redo action occurred for a specified
item
.Manually pushes a
command
to the stack, and takes ownership of the command.Returns a pointer to the internal QUndoStack.
Signals
Emitted when an undo or redo action has occurred, which affected a set of layout
itemUuids
.- beginCommand(self, object: QgsLayoutUndoObjectInterface, commandText: str, id: int = 0)¶
Begins a new undo command for the specified
object
.This must be followed by a call to
endCommand()
orcancelCommand()
after the desired changes have been made toobject
.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
See also
- Parameters
object (QgsLayoutUndoObjectInterface) –
commandText (str) –
id (int = 0) –
- beginMacro(self, commandText: str)¶
Starts a macro command, with the given descriptive
commandText
.Any commands added to the stack (either via direct manipulation of
stack()
or viabeginCommand()
/endCommand()
calls) between abeginMacro()
andendMacro()
block are collapsed into a single undo command, which will be applied or rolled back in a single step.See also
- Parameters
commandText (str) –
- blockCommands(self, blocked: bool)¶
Sets whether undo commands for the layout should be temporarily blocked.
If
blocked
isTrue
, 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
- Parameters
blocked (bool) –
- cancelCommand(self)¶
Cancels the active command, discarding it without pushing to the undo history.
See also
See also
- childEvent(self, QChildEvent)¶
- connectNotify(self, QMetaMethod)¶
- customEvent(self, QEvent)¶
- disconnectNotify(self, QMetaMethod)¶
- endCommand(self)¶
Saves final state of an object and pushes the active command to the undo history.
See also
See also
- endMacro(self)¶
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 viabeginCommand()
/endCommand()
calls) between abeginMacro()
andendMacro()
block are collapsed into a single undo command, which will be applied or rolled back in a single step.See also
- isBlocked(self) → bool¶
Returns
True
if undo commands are currently blocked.See also
- Return type
bool
- isSignalConnected(self, QMetaMethod) → bool¶
- notifyUndoRedoOccurred(self, item: QgsLayoutItem)¶
Notifies the stack that an undo or redo action occurred for a specified
item
.- Parameters
item (QgsLayoutItem) –
- push(self, command: QUndoCommand)¶
Manually pushes a
command
to the stack, and takes ownership of the command.- Parameters
command (QUndoCommand) –
- receivers(self, PYQT_SIGNAL) → int¶
- sender(self) → QObject¶
- senderSignalIndex(self) → int¶
- stack(self) → QUndoStack¶
Returns a pointer to the internal QUndoStack.
- Return type
QUndoStack
- timerEvent(self, QTimerEvent)¶
- undoRedoOccurredForItems¶
Emitted when an undo or redo action has occurred, which affected a set of layout
itemUuids
. [signal]- Parameters
itemUuids (Iterable[str]) –