History (hwx.inspire)#

class History(*args)#

Bases: object

Manages the Undo, Redo support.

history.noteState() needs to be called after any data model updates.

Attribute Table#

Name

Type

undoRedoActive

property

Method Table#

Name

Description

addAction (self, undo=None, redo=None)

Append undo/redo callbacks for a gui event.

disabled (self)

Disable history recording. For internal use only.

noteState (self, tag=’’)

Creates history noteState with supplied tag.

redo (self)

Undoes an undo.

temporaryMode (self)

Begins a transaction for data model changes.

undo (self)

Undo data model changes till previous noteState.

noteState(tag='')#

Creates history noteState with supplied tag.

Parameters:

tag (str) – Name/description for the noteState. Currently, not shown in the ui. Only used by __repr__ for debugging.

undo()#

Undo data model changes till previous noteState.

redo()#

Undoes an undo.

temporaryMode()#

Begins a transaction for data model changes.

NoteState commits the changes otherwise the model is restored when

leaving the contextmanager.

Yields commit and rollback functions.

disabled()#

Disable history recording. For internal use only.

property undoRedoActive#

(bool) Check if an undo/redo is in progress.

Callback code which generates history actions should be skipped if this is True. For example, if you modify an object in a ModelListener event. Rely on the history actions to handle the event instead.

addAction(undo=None, redo=None)#

Append undo/redo callbacks for a gui event.

Actions for data model changes are added automatically.

NOOP if history.undoRedoActive but it’s better to avoid calling this.

Parameters:
  • undo (function) – Restore state to before this action.

  • redo (function) – Redo the state update.