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

Command()

Base class for un-/re-doable actions.

UndoCommand(old, new, apply, text)

A diff-based state transition, initialized with old and new values that must be apply-ed to go backward or forward in time.

UndoStack()

Serves as lightweight replacement for QUndoStack.

class madgui.util.undo.Command[source]

Bases: object

Base 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

text

str(object=’’) -> str

redo()[source]

Exec the action represented by this command.

text = ''
undo()[source]

Undo the action represented by this command.

class madgui.util.undo.UndoCommand(old, new, apply, text)[source]

Bases: madgui.util.undo.Command

A diff-based state transition, initialized with old and new values that must be apply-ed to go backward or forward in time.

Methods

redo()

Go forward in time by applying the new state.

undo()

Go backward in time by applying the old state.

redo()[source]

Go forward in time by applying the new state.

undo()[source]

Go backward in time by applying the old state.

class madgui.util.undo.UndoStack[source]

Bases: object

Serves 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 QAction for a “Redo” button.

create_undo_action(parent)

Create a QAction for 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

changed

Signal<>

can_redo()[source]

Check if a redo action can be performed.

can_undo()[source]

Check if an undo action can be performed.

changed

Signal<>

clear()[source]

Clear the stack. This can only be done when no macro is active.

command(index)[source]

Return the i-th command in the stack.

count()[source]

Return number of commands on the stack.

create_redo_action(parent)[source]

Create a QAction for a “Redo” button.

create_undo_action(parent)[source]

Create a QAction for an “Undo” button.

macro(text='')[source]
push(command)[source]

Push and execute command, and truncate all history after current stack position.

redo()[source]

Redo command behind current stack pointer.

rollback(text='temporary change', transient=False)[source]
truncate()[source]

Truncate history after current stack position.

undo()[source]

Undo command before current stack pointer.