Scribus
Open source desktop publishing at your fingertips
UndoManager Class Reference

UndoManager handles the undo stack. More...

#include <undomanager.h>

Inheritance diagram for UndoManager:
Collaboration diagram for UndoManager:

Public Slots

void languageChange ()
 Updates strings when the GUI language is changed.
 
void action (UndoObject *target, UndoState *state, QPixmap *targetPixmap=0)
 Adds a new action to the undo stack. More...
 
void action (UndoObject *target, UndoState *state, const QString &targetName, QPixmap *targetPixmap=0)
 Adds a new action to the undo stack. More...
 
void undo (int steps)
 Informs UndoManager to perform undo. More...
 
void redo (int steps)
 Informs UndoManager to perform redo. More...
 
void showObject (int uid)
 Switches the state of UndoManager (global/object specific undo). More...
 
void setHistoryLength (int steps)
 Sets the length of the undo stack. More...
 
void setAllHistoryLengths (int steps)
 

Signals

void newAction (UndoObject *target, UndoState *state)
 Emitted when a new undo action is stored to the undo stack. More...
 
void undoSignal (int steps)
 Emitted when an undo action has been done. More...
 
void redoSignal (int steps)
 Emitted when a redo action has been done. More...
 
void clearRedo ()
 Emitted when a new actions comes in and UndoManager is in object. More...
 
void popBack ()
 This signal is used to notify registered UndoGui instances that. More...
 
void undoRedoBegin ()
 This signal is emitted when beginning a series of undo/redo actions. More...
 
void undoRedoDone ()
 This signal is emitted when all requested undo/redo actions have been done. More...
 

Public Member Functions

void setUndoEnabled (bool isEnabled)
 Sets the undo action tracking enabled or disabled. More...
 
UndoTransaction beginTransaction (const QString &targetName="", QPixmap *targetPixmap=0, const QString &actionName="", const QString &description="", QPixmap *actionPixmap=0)
 Start a transaction. More...
 
UndoTransaction beginTransaction (const TransactionSettings &settings)
 
bool isTransactionMode ()
 Cancels the current transaction and deletes groupped UndoStates. More...
 
void registerGui (UndoGui *gui)
 Register an UndoGui to the UndoManager. More...
 
void removeGui (UndoGui *gui)
 Removes an UndoGui from UndoManager. More...
 
void switchStack (const QString &stackName)
 Changes the active undo stack. More...
 
void renameStack (const QString &newName)
 Rename the current stack. More...
 
void removeStack (const QString &stackName)
 Remove the stack with the name stackName More...
 
void clearStack ()
 
bool hasUndoActions (int uid=-1)
 Returns true if there are actions that can be undone otherwise returns false. More...
 
bool hasRedoActions (int uid=-1)
 Returns true if there are actions that can be redone otherwise returns false. More...
 
UndoObjectreplaceObject (ulong uid, UndoObject *newUndoObject)
 Replace an UndoObject with the id uid with a new UndoObject new. More...
 
int getHistoryLength ()
 Returns the maximum length of the undostack. More...
 
bool isGlobalMode ()
 Returns true if in global mode and false if in object specific mode. More...
 
UndoStategetLastUndo ()
 

Static Public Member Functions

static UndoManagerinstance ()
 Returns a pointer to the UndoManager instance. More...
 
static void deleteInstance ()
 Deletes the UndoManager Instance. More...
 
static bool undoEnabled ()
 Returns true if undo actions are stored, if not will return false. More...
 

Static Public Attributes

static const int GLOBAL_UNDO_MODE = -1
 Marks for a global undo mode where ever UndoOjbect id is requested.
 
static const int NO_UNDO_STACK = -2
 When object specific mode is requested but no suitable object is selected. More...
 
Action strings

Strings describing undo actions

static QString ConnectPath = ""
 
static QString AddVGuide = ""
 
static QString AddHGuide = ""
 
static QString DelVGuide = ""
 
static QString DelHGuide = ""
 
static QString DelVAGuide = ""
 
static QString DelHAGuide = ""
 
static QString MoveVGuide = ""
 
static QString MoveHGuide = ""
 
static QString UniteItem = ""
 
static QString Overprint = ""
 
static QString BlendMode = ""
 
static QString ActionPDF = ""
 
static QString SplitItem = ""
 
static QString RemoveAllGuides = ""
 
static QString RemoveAllPageGuides = ""
 
static QString LockGuides = ""
 
static QString UnlockGuides = ""
 
static QString Move = ""
 
static QString NewMasterPage = ""
 
static QString DelMasterPage = ""
 
static QString ImportMasterPage = ""
 
static QString DuplicateMasterPage = ""
 
static QString ApplyMasterPage = ""
 
static QString RenameMasterPage = ""
 
static QString Resize = ""
 
static QString Rotate = ""
 
static QString MoveFromTo = ""
 
static QString ResizeFromTo = ""
 
static QString ImageOffset = ""
 
static QString ImageScale = ""
 
static QString ImageOffsetFromTo = ""
 
static QString ImageScaleFromTo = ""
 
static QString Selection = ""
 
static QString Group = ""
 
static QString SelectionGroup = ""
 
static QString Create = ""
 
static QString CreateTo = ""
 
static QString AlignDistribute = ""
 
static QString ItemsInvolved = ""
 
static QString ItemsInvolved2 = ""
 
static uint ItemsInvolvedLimit = 20
 
static QString Cancel = ""
 
static QString SetFill = ""
 
static QString ColorFromTo = ""
 
static QString SetShade = ""
 
static QString SetLineColor = ""
 
static QString SetLineShade = ""
 
static QString FlipH = ""
 
static QString FlipV = ""
 
static QString Lock = ""
 
static QString UnLock = ""
 
static QString SizeLock = ""
 
static QString SizeUnLock = ""
 
static QString EnablePrint = ""
 
static QString DisablePrint = ""
 
static QString Ungroup = ""
 
static QString Delete = ""
 
static QString Rename = ""
 
static QString FromTo = ""
 
static QString Mode = ""
 
static QString Paste = ""
 
static QString Cut = ""
 
static QString Transparency = ""
 
static QString LineTransparency = ""
 
static QString LineStyle = ""
 
static QString LineEnd = ""
 
static QString LineJoin = ""
 
static QString LineWidth = ""
 
static QString NoStyle = ""
 
static QString CustomLineStyle = ""
 
static QString NoLineStyle = ""
 
static QString StartArrow = ""
 
static QString EndArrow = ""
 
static QString StartAndEndArrow = ""
 
static QString CreateTable = ""
 
static QString RowsCols = ""
 
static QString SetFont = ""
 
static QString SetFontSize = ""
 
static QString SetFontWidth = ""
 
static QString SetFontHeight = ""
 
static QString SetFontFill = ""
 
static QString SetFontStroke = ""
 
static QString SetFontFillShade = ""
 
static QString SetFontStrokeShade = ""
 
static QString SetKerning = ""
 
static QString SetLineSpacing = ""
 
static QString SetStyle = ""
 
static QString SetLanguage = ""
 
static QString AlignText = ""
 
static QString SetFontEffect = ""
 
static QString ImageFrame = ""
 
static QString TextFrame = ""
 
static QString Layer = ""
 
static QString LatexFrame = ""
 
static QString ResTyp = ""
 
static QString Polygon = ""
 
static QString EditPolygon = ""
 
static QString EditArc = ""
 
static QString EditSpiral = ""
 
static QString BezierCurve = ""
 
static QString ShowImage = ""
 
static QString Polyline = ""
 
static QString PathText = ""
 
static QString ConvertTo = ""
 
static QString ImportSVG = ""
 
static QString RoundCorner = ""
 
static QString ImportUniconv = ""
 
static QString ImportEPS = ""
 
static QString ImportBarcode = ""
 
static QString ImportOOoDraw = ""
 
static QString ImportAI = ""
 
static QString ImportXfig = ""
 
static QString ImportWMF = ""
 
static QString ScratchSpace = ""
 
static QString ObjectFrame = ""
 
static QString BoundingBox = ""
 
static QString ContourLine = ""
 
static QString ImageClip = ""
 
static QString NoTextFlow = ""
 
static QString NoObjectFrame = ""
 
static QString NoBoundingBox = ""
 
static QString NoContourLine = ""
 
static QString PageNmbr = ""
 
static QString ImageScaling = ""
 
static QString FrameSize = ""
 
static QString FreeScaling = ""
 
static QString KeepRatio = ""
 
static QString BreakRatio = ""
 
static QString EditContourLine = ""
 
static QString EditShape = ""
 
static QString ChangeShapeType = ""
 
static QString ResetContourLine = ""
 
static QString AddPage = ""
 
static QString AddPages = ""
 
static QString ReplaceText = ""
 
static QString FirstLineOffset = ""
 
static QString AppendText = ""
 
static QString ImportText = ""
 
static QString ClearText = ""
 
static QString TruncateText = ""
 
static QString AddLoremIpsum = ""
 
static QString DeleteText = ""
 
static QString InsertText = ""
 
static QString InsertMark = ""
 
static QString InsertNote = ""
 
static QString EditMark = ""
 
static QString DeleteMark = ""
 
static QString NewNotesStyle = ""
 
static QString EditNotesStyle = ""
 
static QString DeleteNotesStyle = ""
 
static QString DeleteNote = ""
 
static QString DeletePage = ""
 
static QString DeletePages = ""
 
static QString ChangePageProps = ""
 
static QString AddLayer = ""
 
static QString DuplicateLayer = ""
 
static QString DeleteLayer = ""
 
static QString RenameLayer = ""
 
static QString RaiseLayer = ""
 
static QString LowerLayer = ""
 
static QString SendToLayer = ""
 
static QString PrintLayer = ""
 
static QString DoNotPrintLayer = ""
 
static QString SetLayerName = ""
 
static QString FlowLayer = ""
 
static QString DisableFlowLayer = ""
 
static QString SetLayerBlendMode = ""
 
static QString SetLayerTransparency =""
 
static QString MeshGradient = ""
 
static QString ChangeMeshGradient = ""
 
static QString SetLayerLocked = ""
 
static QString SetLayerUnlocked = ""
 
static QString RemoveMeshPatch = ""
 
static QString StartArrowScale = ""
 
static QString EndArrowScale = ""
 
static QString GetImage = ""
 
static QString ChangeFormula = ""
 
static QString GradType = ""
 
static QString GradTypeMask = ""
 
static QString GradPos = ""
 
static QString GradVal = ""
 
static QString GradValStroke = ""
 
static QString GradCol = ""
 
static QString GradTypeStroke = ""
 
static QString MultipleDuplicate = ""
 
static QString Duplicate = ""
 
static QString Transform = ""
 
static QString ApplyTextStyle = ""
 
static QString RemoveTextStyle = ""
 
static QString Columns = ""
 
static QString ColumnsGap = ""
 
static QString TextFrameDist = ""
 
static QString MenuUndo = ""
 
static QString MenuUndoEmpty = ""
 
static QString MenuRedo = ""
 
static QString MenuRedoEmpty = ""
 
static QString EditContour = ""
 
static QString ResetControlPoint = ""
 
static QString ResetControlPoints = ""
 
static QString ImageEffects = ""
 
static QString LevelUp = ""
 
static QString LevelDown = ""
 
static QString LevelBottom = ""
 
static QString LevelTop = ""
 
static QString InsertFrame = ""
 
static QString AdjustFrameToImage = ""
 
static QString Copy = ""
 
static QString CopyPage = ""
 
static QString ChangePageAttrs = ""
 
static QString ImportPage = ""
 
static QString MovePage = ""
 
static QString SwapPage = ""
 
static QString ToOutlines = ""
 
static QString LinkTextFrame = ""
 
static QString UnlinkTextFrame = ""
 
static QString ClearImage = ""
 
static QString PathOperation = ""
 
static QString WeldItems = ""
 
static QString UnweldItems = ""
 
static QString SoftShadow = ""
 
static QString SoftShadowColor = ""
 
static QString SoftShadowShade = ""
 
static QString SoftShadowBlurRadius =""
 
static QString SoftShadowXOffset = ""
 
static QString SoftShadowYOffset = ""
 
static QString SoftShadowOpacity = ""
 
static QString SoftShadowBlendMode = ""
 
static QString SoftShadowErase = ""
 
static QString SoftShadowObjectTrans = ""
 
Action icons

Icons for undo actions

static QPixmap * IImageFrame = 0
 
static QPixmap * ITextFrame = 0
 
static QPixmap * ILatexFrame = 0
 
static QPixmap * ILine = 0
 
static QPixmap * IPolygon = 0
 
static QPixmap * IPolyline = 0
 
static QPixmap * IPathText = 0
 
static QPixmap * IGroup = 0
 
static QPixmap * ILayer = 0
 
static QPixmap * IMove = 0
 
static QPixmap * IResize = 0
 
static QPixmap * IRotate = 0
 
static QPixmap * IGuides = 0
 
static QPixmap * ILockGuides = 0
 
static QPixmap * IAlignDistribute = 0
 
static QPixmap * IFill = 0
 
static QPixmap * IShade = 0
 
static QPixmap * IFlipH = 0
 
static QPixmap * IFlipV = 0
 
static QPixmap * ILock = 0
 
static QPixmap * IUnLock = 0
 
static QPixmap * IEnablePrint = 0
 
static QPixmap * IDisablePrint = 0
 
static QPixmap * IDelete = 0
 
static QPixmap * ICreate = 0
 
static QPixmap * IPaste = 0
 
static QPixmap * ICut = 0
 
static QPixmap * ITransparency = 0
 
static QPixmap * ILineStyle = 0
 
static QPixmap * IArrow = 0
 
static QPixmap * ITable = 0
 
static QPixmap * IFont = 0
 
static QPixmap * ISVG = 0
 
static QPixmap * IUniconv = 0
 
static QPixmap * IEPS = 0
 
static QPixmap * IAI = 0
 
static QPixmap * IXFIG = 0
 
static QPixmap * IWMF = 0
 
static QPixmap * IImportOOoDraw = 0
 
static QPixmap * IImageScaling = 0
 
static QPixmap * IBorder = 0
 
static QPixmap * IDocument = 0
 
static QPixmap * ILayerAction = 0
 
static QPixmap * IUp = 0
 
static QPixmap * IDown = 0
 
static QPixmap * IPrint = 0
 
static QPixmap * IGetImage = 0
 
static QPixmap * IChangeFormula = 0
 
static QPixmap * IMultipleDuplicate = 0
 

Protected Member Functions

 UndoManager ()
 Creates a new UndoManager instance.
 
 ~UndoManager ()
 Destroys the UndoManager instance.
 

Friends

class UndoTransaction
 

Detailed Description

UndoManager handles the undo stack.

UndoManager is the engine of the undo/redo handling. When ever an undoable action happens an UndoState object will be sent to the UndoManager which then stores the state in the undo stack. When an undo is requested the state is send back to it's creator which is then responsible for doing the actual undo or redo.

UndoManager also handles the UndoGuis by linking them together and reporting all undo/redo actions to the guis for them to update the visual representation. For this to work all UndoGuis need to be registered to the UndoManager with the registerGui() method.

Author
Riku Leino tsoot.nosp@m.s@gm.nosp@m.ail.c.nosp@m.om
Date
December 2004

Member Function Documentation

void UndoManager::action ( UndoObject target,
UndoState state,
QPixmap *  targetPixmap = 0 
)
slot

Adds a new action to the undo stack.

If _unodEnabled is true the action will be stored otherwise it will be just ignored. When a new action is added redo items from the stack will be removed and the current action will be set to the one which was added.

Parameters
targetSource of the action. When undoing/redoing this action restore() method of this UndoObject will be called.
stateUndoSate describing the state (action).
targetPixmapIs used to override the default target icon in this action.
void UndoManager::action ( UndoObject target,
UndoState state,
const QString &  targetName,
QPixmap *  targetPixmap = 0 
)
slot

Adds a new action to the undo stack.

If _unodEnabled is true the action will be stored otherwise it will be just ignored. When a new action is added redo items from the stack will be removed and the current action will be set to the one which was added.

Parameters
targetSource of the action. When undoing/redoing this action restore() method of this UndoObject will be called.
stateUndoSate describing the state (action).
targetNameIs used to override the default target name in this action.
targetPixmapIs used to override the default target icon in this action.
UndoTransaction UndoManager::beginTransaction ( const QString &  targetName = "",
QPixmap *  targetPixmap = 0,
const QString &  actionName = "",
const QString &  description = "",
QPixmap *  actionPixmap = 0 
)

Start a transaction.

After this method has been invoked UndoManager will switch to the transaction (silent) mode where it does not report actions to the attached UndoGui widgets but stores all incoming UndoState objects into the transaction container which after call to the method commit() will be sent to the guis as a single undo action. Transaction can be named when starting it or naming can be done when commiting it.

Parameters
targetNamename for the target of this transaction (f.e. "Selection")
targetPixmapIcon for the target on which this transaction works. this icon will be drawn first when the action is presented in Action History window and icon for the action will be drawn over this one.
actionNamename for the transaction (f.e. "Move" would make with the above "Move Selection") The result can only be used for initializing a Transaction object, eg. on the stack: Transaction groupTransaction(undoManger->beginTransaction(...)); or the heap: Transaction* groupTransactionPtr = new Transaction(undoManger->beginTransaction(...));
descriptiondescription for the transaction
actionPixmapicon for the action performed by the transaction
See also
commit()

Dummy object for storing transaction target's name

void UndoManager::clearRedo ( )
signal

Emitted when a new actions comes in and UndoManager is in object.

specific mode and action does not belong to the currently selected object.

void UndoManager::clearStack ( )

clear the current undo stack

void UndoManager::deleteInstance ( )
static

Deletes the UndoManager Instance.

Must be called when UndoManager is no more needed.

int UndoManager::getHistoryLength ( )

Returns the maximum length of the undostack.

Returns
the maximum length of the undostack
bool UndoManager::hasRedoActions ( int  uid = -1)

Returns true if there are actions that can be redone otherwise returns false.

Returns
true if there are actions that can be redone otherwise returns false
See also
UndoManager::hasUndoActions()
bool UndoManager::hasUndoActions ( int  uid = -1)

Returns true if there are actions that can be undone otherwise returns false.

This is useful when undo/redo actions are handled with a gui that is not attached to the UndoManager (f.e. menu items) and when those gui items are wanted to set enabled or disabled depending on the status of the undo stack.

Returns
true if there are actions that can be undone otherwise returns false
UndoManager * UndoManager::instance ( )
static

Returns a pointer to the UndoManager instance.

Returns
A pointer to the UndoManager instance
bool UndoManager::isGlobalMode ( )

Returns true if in global mode and false if in object specific mode.

Returns
true if in global mode and false if in object specific mode
bool UndoManager::isTransactionMode ( )

Cancels the current transaction and deletes groupped UndoStates.

Nothing from canceled transaction will be sent to the undo gui widgets. Returns true if in transaction mode if not will return false.

Returns
bool true if in transaction mode if not will return false
void UndoManager::newAction ( UndoObject target,
UndoState state 
)
signal

Emitted when a new undo action is stored to the undo stack.

This signal is connected to the registered UndoGuis for them to update the visual representation of the undo stack.

Parameters
targetSource of the action
stateUndoState describing the action
void UndoManager::popBack ( )
signal

This signal is used to notify registered UndoGui instances that.

history limit is reached and the last item from the stack representation should be removed.

void UndoManager::redo ( int  steps)
slot

Informs UndoManager to perform redo.

Parameters
stepsNumber of redo steps to take
See also
UndoManager::undo(int steps)
void UndoManager::redoSignal ( int  steps)
signal

Emitted when a redo action has been done.

Parameters
stepsNumber of steps to take
See also
UndoManager::undoSignal(int steps)
void UndoManager::registerGui ( UndoGui gui)

Register an UndoGui to the UndoManager.

After registering a gui to the manager the gui will be updated with the undo action information received by the UndoManager. Actions done with the UndoGui to be registered are also handled after registering.

Parameters
guiA pointer to the UndoGui that is wanted to be registered.
void UndoManager::removeGui ( UndoGui gui)

Removes an UndoGui from UndoManager.

Parameters
guiUndoGui to be removed from the UndoManager.
void UndoManager::removeStack ( const QString &  stackName)

Remove the stack with the name stackName

Parameters
stackNameName of the stack that is wanted to be removed
void UndoManager::renameStack ( const QString &  newName)

Rename the current stack.

Parameters
newNameNew name for the current stack.
UndoObject * UndoManager::replaceObject ( ulong  uid,
UndoObject newUndoObject 
)

Replace an UndoObject with the id uid with a new UndoObject new.

Parameters
uidId for the UndoObject that is wanted to be replaced.
newUndoObjectUndoObject which will replace an old UndoObject in the stack.
Returns
UndoObject which was replaced
void UndoManager::setHistoryLength ( int  steps)
slot

Sets the length of the undo stack.

Tells how many UndoStates are stored.

Parameters
stepsnumber of UndoStates to store in the undo stack
void UndoManager::setUndoEnabled ( bool  isEnabled)

Sets the undo action tracking enabled or disabled.

Parameters
isEnabledIf true undo stack is updated with the states sent to the UndoManager else undo stack is not updated and attached UndoGuis are not informed of the actions.
void UndoManager::showObject ( int  uid)
slot

Switches the state of UndoManager (global/object specific undo).

If parameter uid is less than 0 global undo is used else the undo state is object specific using the object whose uid is given as a parameter.

Parameters
uidUndoObject's id for what the object specific undo is wanted or -1 if global undo is wanted.
void UndoManager::switchStack ( const QString &  stackName)

Changes the active undo stack.

Sets the stack connected to the name stackName active. Calling this method will send clear() signal to the attached UndoGuis and will update their undo stack representations.

Parameters
stackNameName of the stack to be used
void UndoManager::undo ( int  steps)
slot

Informs UndoManager to perform undo.

If an undo is wanted and the caller is not registered UndoGui this method can be used. Useful for example with the menu entry for undo.

Parameters
stepsNumber of undo steps to take
bool UndoManager::undoEnabled ( )
static

Returns true if undo actions are stored, if not will return false.

Returns
true if undo actions are stored, if not will return false
void UndoManager::undoRedoBegin ( )
signal

This signal is emitted when beginning a series of undo/redo actions.

It could be used in the application as a signal to disable temporarily gui updates.

void UndoManager::undoRedoDone ( )
signal

This signal is emitted when all requested undo/redo actions have been done.

It could be used in the application as a signal when the view can be rendered again after undo/redo.

void UndoManager::undoSignal ( int  steps)
signal

Emitted when an undo action has been done.

It is connected to attached guis to inform them to update the visual representation of the undo stack. This signal will be also sent to the UndoGui where it came from.

Parameters
stepsNumber of steps to take

Member Data Documentation

const int UndoManager::NO_UNDO_STACK = -2
static

When object specific mode is requested but no suitable object is selected.

this can be passed to showObject() to clear the undo stack representations.


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