|
ACF $AcfVersion:0$
|
Implements multi-level UNDO mechanism based on storing complete object state at each step using serialization. More...
#include <CSerializedUndoManagerComp.h>
Classes | |
| struct | UndoStepInfo |
Public Member Functions | |
| CSerializedUndoManagerComp () | |
| virtual int | GetAvailableUndoSteps () const override |
| Get number of available UNDO levels. | |
| virtual int | GetAvailableRedoSteps () const override |
| Get number of available REDO levels. | |
| virtual QString | GetUndoLevelDescription (int stepIndex) const override |
| Get description of single UNDO level. | |
| virtual QString | GetRedoLevelDescription (int stepIndex) const override |
| Get description of single REDO level. | |
| virtual void | ResetUndo () override |
| Reset all UNDO and REDO steps. | |
| virtual bool | DoUndo (int steps=1) override |
| Process UNDO steps. | |
| virtual bool | DoRedo (int steps=1) override |
| Process REDO steps. | |
| virtual bool | OnModelAttached (imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override |
| Callback invoked when an observable model is about to be attached to this observer. | |
| virtual bool | OnModelDetached (imod::IModel *modelPtr) override |
| Callback invoked when an observable model is about to be detached from this observer. | |
Public Member Functions inherited from icomp::CComponentBase | |
| CComponentBase () | |
| Create component and assign it to specific context. | |
| virtual const icomp::IComponent * | GetParentComponent (bool ownerOnly=false) const override |
| Get parent of this component. | |
| virtual void * | GetInterface (const istd::CClassInfo &interfaceType, const QByteArray &subId="") override |
| Get access to specified component interface. | |
| virtual IComponentContextSharedPtr | GetComponentContext () const override |
| Get access to component context describing all application-specified component information loaded from components registry. | |
| virtual void | SetComponentContext (const IComponentContextSharedPtr &contextPtr, const icomp::IComponent *parentPtr, bool isParentOwner) override |
| Set component context of this component. | |
Public Member Functions inherited from istd::IPolymorphic | |
| virtual | ~IPolymorphic () |
Public Member Functions inherited from imod::TSingleModelObserverBase< iser::ISerializable > | |
| TSingleModelObserverBase () | |
| iser::ISerializable * | GetObservedObject () const |
| Get instance of observed object. | |
| iser::ISerializable * | GetObjectPtr () const |
| Get instance of observed object. | |
| bool | AttachOrSetObject (iser::ISerializable *objectPtr) |
| Attach to model of object or set object pointer, if no connection is possible. | |
Public Member Functions inherited from imod::CSingleModelObserverBase | |
| CSingleModelObserverBase () | |
| virtual | ~CSingleModelObserverBase () |
| imod::IModel * | GetObservedModel () const |
| Get access to observed model. | |
| imod::IModel * | GetModelPtr () const |
| Get access to observed model. | |
| void | EnsureModelDetached () |
| Make sure this observer is detached. | |
| void | SetObservedIds (const istd::IChangeable::ChangeSet &changeMask) |
| Set list of ID's beeing observed. | |
| virtual bool | IsModelAttached (const imod::IModel *modelPtr=NULL) const override |
| Checks if the specified model is currently attached to this observer. | |
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::IChangeable > | CloneMe (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. | |
Protected Types | |
| typedef istd::TDelPtr< iser::CMemoryWriteArchive > | UndoArchivePtr |
| typedef QList< UndoStepInfo > | UndoList |
Protected Member Functions | |
| bool | DoListShift (int steps, UndoList &fromList, UndoList &toList) |
| virtual iser::ISerializable * | CastFromModel (imod::IModel *modelPtr) const override |
| virtual void | BeforeUpdate (imod::IModel *modelPtr) override |
| Callback invoked before an update of the observer's content occurs. | |
| virtual void | AfterUpdate (imod::IModel *modelPtr, const istd::IChangeable::ChangeSet &changeSet) override |
| Callback invoked after an update of the observer's content occurs. | |
| virtual bool | HasStoredDocumentState () const override |
| Check if there is stored document state available. | |
| virtual bool | StoreDocumentState () override |
| Store state of the document. | |
| virtual bool | RestoreDocumentState () override |
| Restore last stored document state. | |
| virtual DocumentChangeFlag | GetDocumentChangeFlag () const override |
| Check if document state is the same as stored state. | |
| virtual void | OnComponentDestroyed () override |
Protected Member Functions inherited from icomp::CComponentBase | |
| bool | IsComponentActive () const |
| Check if component is active. | |
| virtual void | OnComponentCreated () |
| virtual const icomp::IRealComponentStaticInfo & | GetComponentStaticInfo () const =0 |
| Get access to static info of this component. | |
Protected Member Functions inherited from imod::CSingleModelObserverBase | |
| void | SetModelPtr (imod::IModel *modelPtr) |
| Set internal model pointer to specified value. | |
| virtual void | OnUpdate (const istd::IChangeable::ChangeSet &changeSet) |
| Called on update of observed model. | |
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. | |
Additional Inherited Members | |
Static Public Member Functions inherited from istd::IChangeable | |
| static const ChangeSet & | GetNoChanges () |
| Get empty set of changes. | |
| static const ChangeSet & | GetAnyChange () |
| Get anonymous change set. | |
| static const ChangeSet & | GetAllChanges () |
| Get anonymous change set. | |
| static const ChangeSet & | GetDelegatedChanges () |
| Get delegated change set. | |
Static Protected Member Functions inherited from icomp::CComponentBase | |
| static const icomp::IRealComponentStaticInfo & | InitStaticInfo (IComponent *componentPtr) |
| static QByteArray | GetComponentId (const icomp::IComponentContext *componentContextPtr, const QByteArray &contextId=QByteArray()) |
Static Protected Attributes inherited from imod::CSingleModelObserverBase | |
| static const istd::IChangeable::ChangeSet | s_undoChanges |
Implements multi-level UNDO mechanism based on storing complete object state at each step using serialization.
This component provides a complete undo/redo implementation by serializing the entire document state before each change. It maintains separate undo and redo stacks and automatically manages memory usage by limiting the buffer size.
The undo manager observes the document model and automatically captures state snapshots when changes occur. It integrates with the ACF model/observer pattern to track when undo/redo availability changes.
Definition at line 104 of file CSerializedUndoManagerComp.h.
Definition at line 110 of file CSerializedUndoManagerComp.h.
| typedef imod::TSingleModelObserverBase<iser::ISerializable> idoc::CSerializedUndoManagerComp::BaseClass2 |
Definition at line 111 of file CSerializedUndoManagerComp.h.
|
protected |
Definition at line 136 of file CSerializedUndoManagerComp.h.
|
protected |
Definition at line 142 of file CSerializedUndoManagerComp.h.
| idoc::CSerializedUndoManagerComp::CSerializedUndoManagerComp | ( | ) |
|
overrideprotectedvirtual |
Callback invoked after an update of the observer's content occurs.
This is the primary notification method where observers react to model changes. It's called after the model has finished updating its state. The implementation should examine the changeSet to determine what changed and update accordingly.
| modelPtr | Pointer to the model that has changed |
| changeSet | Contains information about what changed in the model. Use changeSet.Contains(changeId) to check for specific changes. The changeSet respects the mask specified in OnModelAttached(). |
Reimplemented from imod::CSingleModelObserverBase.
|
overrideprotectedvirtual |
Callback invoked before an update of the observer's content occurs.
This method is called at the start of a model update cycle, before any data actually changes. It allows the observer to prepare for the update, such as saving current state for comparison or disabling UI updates temporarily.
| modelPtr | Pointer to the model that is about to change |
Reimplemented from imod::CSingleModelObserverBase.
|
overrideprotectedvirtual |
Reimplemented from imod::TSingleModelObserverBase< iser::ISerializable >.
|
protected |
|
overridevirtual |
Process REDO steps.
| steps | Number of redo levels to execute (default is 1). |
Implements idoc::IUndoManager.
|
overridevirtual |
Process UNDO steps.
| steps | Number of undo levels to execute (default is 1). |
Implements idoc::IUndoManager.
|
overridevirtual |
Get number of available REDO levels.
REDO levels are created when undo operations are performed.
Implements idoc::IUndoManager.
|
overridevirtual |
Get number of available UNDO levels.
Each level represents a separate change that can be undone.
Implements idoc::IUndoManager.
|
overrideprotectedvirtual |
Check if document state is the same as stored state.
Implements idoc::IDocumentStateComparator.
|
overridevirtual |
Get description of single REDO level.
| stepIndex | Index of the redo step (0 = most recent). |
Implements idoc::IUndoManager.
|
overridevirtual |
Get description of single UNDO level.
| stepIndex | Index of the undo step (0 = most recent). |
Implements idoc::IUndoManager.
|
overrideprotectedvirtual |
Check if there is stored document state available.
Implements idoc::IDocumentStateComparator.
|
overrideprotectedvirtual |
Reimplemented from icomp::CComponentBase.
|
overridevirtual |
Callback invoked when an observable model is about to be attached to this observer.
This method is called by the model when attempting to establish an observer relationship. The implementation should:
| modelPtr | Pointer to the model object being attached. Never nullptr. |
| changeMask | Output parameter where the observer specifies which change types it wants to be notified about. Set the appropriate change flags using changeMask.Set(changeId). An empty mask means the observer wants all changes. |
Reimplemented from imod::TSingleModelObserverBase< iser::ISerializable >.
|
overridevirtual |
Callback invoked when an observable model is about to be detached from this observer.
This method is called when the observer-model relationship is being terminated, either explicitly or because the model is being destroyed. The implementation should clean up any state or resources related to this model.
| modelPtr | Pointer to the model object being detached |
Reimplemented from imod::TSingleModelObserverBase< iser::ISerializable >.
|
overridevirtual |
Reset all UNDO and REDO steps.
This clears the entire undo/redo history. Use with caution.
Implements idoc::IUndoManager.
|
overrideprotectedvirtual |
Restore last stored document state.
This reverts the document to the last stored state, effectively undoing all changes made since the state was stored.
Implements idoc::IDocumentStateComparator.
|
overrideprotectedvirtual |
Store state of the document.
This creates a snapshot of the current document state that can be used for comparison or restoration later.
Implements idoc::IDocumentStateComparator.