madgui.util.undo module¶
This module provides a lightweight alternative for the QUndoStack that
can be used in the absence of Qt and without initializing a QApplication.
Classes
|
Base class for un-/re-doable actions. |
|
A diff-based state transition, initialized with |
Serves as lightweight replacement for QUndoStack. |
-
class
madgui.util.undo.Command[source]¶ Bases:
objectBase class for un-/re-doable actions. Command objects are only to be pushed onto an UndoStack and must not be called directly.
Methods
redo()Exec the action represented by this command.
undo()Undo the action represented by this command.
Attributes
str(object=’’) -> str
-
text= ''¶
-
-
class
madgui.util.undo.UndoCommand(old, new, apply, text)[source]¶ Bases:
madgui.util.undo.CommandA diff-based state transition, initialized with
oldandnewvalues that must beapply-ed to go backward or forward in time.Methods
redo()Go forward in time by applying the
newstate.undo()Go backward in time by applying the
oldstate.
-
class
madgui.util.undo.UndoStack[source]¶ Bases:
objectServes as lightweight replacement for QUndoStack.
Methods
can_redo()Check if a redo action can be performed.
can_undo()Check if an undo action can be performed.
clear()Clear the stack.
command(index)Return the i-th command in the stack.
count()Return number of commands on the stack.
create_redo_action(parent)Create a
QActionfor a “Redo” button.create_undo_action(parent)Create a
QActionfor an “Undo” button.macro([text])push(command)Push and execute command, and truncate all history after current stack position.
redo()Redo command behind current stack pointer.
rollback([text, transient])truncate()Truncate history after current stack position.
undo()Undo command before current stack pointer.
Attributes
Signal<>
-
changed¶ Signal<>
-