ACF $AcfVersion:0$
Public Member Functions | List of all members
idoc::IUndoManager Class Referenceabstract

Interface providing UNDO/REDO functionality. More...

#include <IUndoManager.h>

Inheritance diagram for idoc::IUndoManager:
idoc::IDocumentStateComparator istd::IChangeable istd::IPolymorphic idoc::CSerializedUndoManagerComp

Public Member Functions

virtual int GetAvailableUndoSteps () const =0
 Get number of available UNDO levels.
 
virtual int GetAvailableRedoSteps () const =0
 Get number of available REDO levels.
 
virtual QString GetUndoLevelDescription (int stepIndex) const =0
 Get description of single UNDO level.
 
virtual QString GetRedoLevelDescription (int stepIndex) const =0
 Get description of single REDO level.
 
virtual void ResetUndo ()=0
 Reset all UNDO and REDO steps.
 
virtual bool DoUndo (int steps=1)=0
 Process UNDO steps.
 
virtual bool DoRedo (int steps=1)=0
 Process REDO steps.
 
- Public Member Functions inherited from idoc::IDocumentStateComparator
virtual bool HasStoredDocumentState () const =0
 Check if there is stored document state available.
 
virtual bool StoreDocumentState ()=0
 Store state of the document.
 
virtual bool RestoreDocumentState ()=0
 Restore last stored document state.
 
virtual DocumentChangeFlag GetDocumentChangeFlag () const =0
 Check if document state is the same as stored state.
 
- Public Member Functions inherited from istd::IChangeable
virtual int GetSupportedOperations () const
 Get set of flags for supported operations.
 
virtual bool CopyFrom (const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
 Copy this object from another one.
 
virtual bool IsEqual (const IChangeable &object) const
 Compare this object with another object.
 
virtual istd::TUniqueInterfacePtr< istd::IChangeableCloneMe (CompatibilityMode mode=CM_WITHOUT_REFS) const
 Make a copy of this object.
 
virtual bool ResetData (CompatibilityMode mode=CM_WITHOUT_REFS)
 Reset data to its default state.
 
virtual void BeginChanges (const ChangeSet &changeSet)
 Starts the change transaction.
 
virtual void EndChanges (const ChangeSet &changeSet)
 Ends the change transaction.
 
virtual void BeginChangeGroup (const ChangeSet &changeSet)
 Starts group of changes.
 
virtual void EndChangeGroup (const ChangeSet &changeSet)
 Ends group of changes.
 
- Public Member Functions inherited from istd::IPolymorphic
virtual ~IPolymorphic ()
 

Additional Inherited Members

- Public Types inherited from idoc::IDocumentStateComparator
enum  DocumentChangeFlag { DCF_UNKNOWN , DCF_EQUAL , DCF_DIFFERENT }
 Flag indicating the relationship between current and stored document state. More...
 
- Public Types inherited from istd::IChangeable
enum  ChangeFlags {
  CF_ACF_INTERNAL = 0 , CF_ALL_DATA , CF_ANY , CF_DESTROYING ,
  CF_DELEGATED , CF_NO_UNDO
}
 Data model change notification flags. More...
 
enum  SupportedOperations {
  SO_NONE = 0 , SO_OBSERVE = 1 << 0 , SO_COPY = 1 << 1 , SO_CLONE = 1 << 2 ,
  SO_COMPARE = 1 << 3 , SO_RESET = 1 << 4
}
 Flags for supported operations. More...
 
enum  CompatibilityMode { CM_STRICT , CM_WITHOUT_REFS , CM_WITH_REFS , CM_CONVERT }
 Control how relationship betweeen objects are interpreted. More...
 
typedef QMultiMap< QByteArray, QVariant > ChangeInfoMap
 
- Static Public Member Functions inherited from istd::IChangeable
static const ChangeSetGetNoChanges ()
 Get empty set of changes.
 
static const ChangeSetGetAnyChange ()
 Get anonymous change set.
 
static const ChangeSetGetAllChanges ()
 Get anonymous change set.
 
static const ChangeSetGetDelegatedChanges ()
 Get delegated change set.
 
- Protected Member Functions inherited from istd::IChangeable
virtual void OnBeginChanges ()
 Callback function for begin change event.
 
virtual void OnEndChanges (const ChangeSet &changeSet)
 Callback function for end change event.
 

Detailed Description

Interface providing UNDO/REDO functionality.

The undo manager tracks changes made to a document and provides the ability to reverse (undo) and reapply (redo) those changes. It maintains a history of document states and allows navigation through that history.

Key features:

The undo manager works in conjunction with IDocumentStateComparator to track and compare document states.

Usage Example
// Get undo manager for a document
idoc::IUndoManager* undoMgr = GetUndoManagerForDocument(doc);
// Check if undo is available
if (undoMgr->GetAvailableUndoSteps() > 0) {
QString desc = undoMgr->GetUndoLevelDescription(0);
qDebug() << "Can undo:" << desc;
undoMgr->DoUndo(); // Undo last change
}
// Check if redo is available
if (undoMgr->GetAvailableRedoSteps() > 0) {
QString desc = undoMgr->GetRedoLevelDescription(0);
qDebug() << "Can redo:" << desc;
undoMgr->DoRedo(); // Redo last undone change
}
// Undo multiple steps at once
int stepsToUndo = 3;
if (undoMgr->GetAvailableUndoSteps() >= stepsToUndo) {
undoMgr->DoUndo(stepsToUndo);
}
// Clear all undo/redo history
undoMgr->ResetUndo();
// Get descriptions of all undo steps
int count = undoMgr->GetAvailableUndoSteps();
for (int i = 0; i < count; ++i) {
QString desc = undoMgr->GetUndoLevelDescription(i);
qDebug() << "Undo step" << i << ":" << desc;
}
Interface providing UNDO/REDO functionality.
virtual int GetAvailableRedoSteps() const =0
Get number of available REDO levels.
virtual bool DoRedo(int steps=1)=0
Process REDO steps.
virtual bool DoUndo(int steps=1)=0
Process UNDO steps.
virtual void ResetUndo()=0
Reset all UNDO and REDO steps.
virtual QString GetUndoLevelDescription(int stepIndex) const =0
Get description of single UNDO level.
virtual int GetAvailableUndoSteps() const =0
Get number of available UNDO levels.
virtual QString GetRedoLevelDescription(int stepIndex) const =0
Get description of single REDO level.
See also
IDocumentManager, IDocumentStateComparator, CSerializedUndoManagerComp

Definition at line 69 of file IUndoManager.h.

Member Function Documentation

◆ DoRedo()

virtual bool idoc::IUndoManager::DoRedo ( int  steps = 1)
pure virtual

Process REDO steps.

Parameters
stepsNumber of redo levels to execute (default is 1).
Returns
True if redo was successful, false otherwise.

Implemented in idoc::CSerializedUndoManagerComp.

◆ DoUndo()

virtual bool idoc::IUndoManager::DoUndo ( int  steps = 1)
pure virtual

Process UNDO steps.

Parameters
stepsNumber of undo levels to execute (default is 1).
Returns
True if undo was successful, false otherwise.

Implemented in idoc::CSerializedUndoManagerComp.

◆ GetAvailableRedoSteps()

virtual int idoc::IUndoManager::GetAvailableRedoSteps ( ) const
pure virtual

Get number of available REDO levels.

Returns
Number of REDO levels, or 0 if there is no REDO available.

REDO levels are created when undo operations are performed.

Implemented in idoc::CSerializedUndoManagerComp.

◆ GetAvailableUndoSteps()

virtual int idoc::IUndoManager::GetAvailableUndoSteps ( ) const
pure virtual

Get number of available UNDO levels.

Returns
Number of UNDO levels, or 0 if there is no UNDO available.

Each level represents a separate change that can be undone.

Implemented in idoc::CSerializedUndoManagerComp.

◆ GetRedoLevelDescription()

virtual QString idoc::IUndoManager::GetRedoLevelDescription ( int  stepIndex) const
pure virtual

Get description of single REDO level.

Parameters
stepIndexIndex of the redo step (0 = most recent).
Returns
Human-readable description of what will be redone.

Implemented in idoc::CSerializedUndoManagerComp.

◆ GetUndoLevelDescription()

virtual QString idoc::IUndoManager::GetUndoLevelDescription ( int  stepIndex) const
pure virtual

Get description of single UNDO level.

Parameters
stepIndexIndex of the undo step (0 = most recent).
Returns
Human-readable description of what will be undone.

Implemented in idoc::CSerializedUndoManagerComp.

◆ ResetUndo()

virtual void idoc::IUndoManager::ResetUndo ( )
pure virtual

Reset all UNDO and REDO steps.

This clears the entire undo/redo history. Use with caution.

Implemented in idoc::CSerializedUndoManagerComp.


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