|
Jameo Core Library
|
This class represents the manager for undo operations. More...
Public Member Functions | |
| UndoManager () | |
| Constructor. | |
| ~UndoManager () override | |
| Destructor. | |
| void | setDocument (jm::Document *document) |
| Sets the document associated with this manager. This enables automatic tracking of changes. | |
| void | setActive (bool status) |
| Sets whether changes should be tracked or not. | |
| bool | isActive () const |
| Returns the status of the manager, indicating whether changes are being tracked. | |
| bool | hasOpenUndoStep () const |
| Returns true, if a undo step is open. | |
| bool | undo () |
| Undoes the last editing step on the file and pushes the change to the RedoStack. | |
| bool | redo () |
| Repeats the last editing step, undoing previous "undos". | |
| void | close () |
| This method finalizes the current editing step. Programmers must explicitly mark the completion of an editing step that should be undone as a whole. | |
| void | clearStacks () |
| This method clears the Undo-Stack and the Redo-Stack manually. | |
| void | clearUndoStack () |
| This method clears the Undo-Stack manually. | |
| void | clearRedoStack () |
| This method clears the Redo-Stack manually. | |
| unsigned int | undoCount () const |
| Returns the number of elements on the Undo-Stack. | |
| unsigned int | redoCount () const |
| Returns the number of elements on the Redo-Stack. | |
| void | registerChange (Object *object, float *pointer) |
| This method registers a change in the file where a float value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, double *pointer) |
| This method registers a change in the file where a double value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, bool *pointer) |
| This method registers a change in the file where a boolean value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, int8 *pointer) |
| This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, uint8 *pointer) |
| This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, int16 *pointer) |
| This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, uint16 *pointer) |
| This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, int32 *pointer) |
| This method registers a change in the file where an int32 value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, uint32 *pointer) |
| This method registers a change in the file where an uint32 value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, Integer *pointer) |
| This method registers a change in the file where a Integer value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, int64 *pointer) |
| This method registers a change in the file where a int64 value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, uint64 *pointer) |
| This method registers a change in the file where a long value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, Vertex2 *pointer) |
| This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, Vertex3 *pointer) |
| This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, String *pointer) |
| This method registers a change in the file where a string value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, Date *pointer) |
| This method registers a change in the file where a Date value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, Color *pointer) |
| This method registers a change in the file where a color value of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (UndoChange *change) |
| This method registers a general change in the file. This method is used when the user derives their own custom change steps. | |
| void | registerChange (Object *object, Object **pointer) |
| This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerChange (Object *object, uint8 **pointer, uint64 length) |
| This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens. | |
| void | registerRegenerationMarker (EditableObject *object) |
| This method registers a regeneration marker that is triggered at every undo/redo step to regenerate objects in the view. | |
| void | registerRelease (Object *object) |
| void | registerRetain (Object *object) |
| void | openTransaction () |
| Begin a transaction. | |
| void | commit () |
| Commit the content of the transaction to the current undo step. | |
| void | rollback () |
| Rollback all changes of the transaction. | |
| Status | closeTransaction () |
| Closes the transaction. | |
| bool | hasOpenTransaction () const |
| Returns true, if a transaction is open. | |
| void | registerTransactionStatus (Status status) |
| This method registers the status of operations during a transaction. As long as status is eOK, nothing happens. If status is not eOk, we register a transaction error. | |
| Status | transactionStatus () const |
| Returns the transaction status. | |
| UndoStep * | openStep () |
Public Member Functions inherited from jm::Object | |
| Object () noexcept | |
| Constructor. | |
| virtual | ~Object () noexcept |
| Destructor. | |
| void | release () noexcept |
| Decreases the reference counter and releases the object immediately when the reference counter becomes 0. | |
| Object * | retain () noexcept |
| Increases the reference counter of this object by 1. | |
| Object * | autorelease () noexcept |
| Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object. | |
| int32 | referenceCount () const noexcept |
| Returns the value of the reference counter. | |
| virtual bool | equals (const Object *other) const |
| Comparison of objects. | |
| virtual String | displayName () const |
| Returns the display name of the object intended to present to a user. | |
| virtual void | printDiffInfo (DiffOperation operation, Object *other) const |
| Output method for outputting the diff results for the diff algorithm. | |
| void | setHighBit (bool status) noexcept |
| bool | highBit () const noexcept |
Friends | |
| class | Document |
This class represents the manager for undo operations.
Editing steps on a document are registered here, and the undo manager belongs to the corresponding document, so that each document owns its own undo manager. This makes it possible to undo editing steps on the document independently of the editing procedure.
However, it is necessary to consider by the developer the form in which processing steps are atomised.
Therefore, there is the following procedure:
To complete the current editing step, the method Close() must be called. The developer must do this manually. Otherwise, all changes are saved in one step.
| jm::UndoManager::UndoManager | ( | ) |
Constructor.
|
override |
Destructor.
| void jm::UndoManager::clearRedoStack | ( | ) |
This method clears the Redo-Stack manually.
| void jm::UndoManager::clearStacks | ( | ) |
This method clears the Undo-Stack and the Redo-Stack manually.
| void jm::UndoManager::clearUndoStack | ( | ) |
This method clears the Undo-Stack manually.
| void jm::UndoManager::close | ( | ) |
This method finalizes the current editing step. Programmers must explicitly mark the completion of an editing step that should be undone as a whole.
| Status jm::UndoManager::closeTransaction | ( | ) |
Closes the transaction.
Dependent on the value of the transaction status, this method decides to call Commit() or Rollback();
If the transaction level is still > 0, nothing happens. Only if the level is back to 0 the closing actions happens.
| void jm::UndoManager::commit | ( | ) |
Commit the content of the transaction to the current undo step.
Each time this method is called, the transaction level decrements.
If the transaction level is still > 0, nothing happens. Only if the level is back to 0 the commit of changes happens, whether the transaction status value.
| bool jm::UndoManager::hasOpenTransaction | ( | ) | const |
Returns true, if a transaction is open.
The transaction is open, if the transaction level is > 0.
| bool jm::UndoManager::hasOpenUndoStep | ( | ) | const |
Returns true, if a undo step is open.
| bool jm::UndoManager::isActive | ( | ) | const |
Returns the status of the manager, indicating whether changes are being tracked.
| UndoStep * jm::UndoManager::openStep | ( | ) |
| void jm::UndoManager::openTransaction | ( | ) |
Begin a transaction.
A transaction is used to change data on objects, which have a meaningful relationship and always shall be consistent. So after changing data, you have to decide of committing a transaction or rollback the data to previous state.
Each time this method is called, the transaction level increments.
| bool jm::UndoManager::redo | ( | ) |
Repeats the last editing step, undoing previous "undos".
| unsigned int jm::UndoManager::redoCount | ( | ) | const |
Returns the number of elements on the Redo-Stack.
| void jm::UndoManager::registerChange | ( | Object * | object, |
| bool * | pointer | ||
| ) |
This method registers a change in the file where a boolean value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where a color value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where a Date value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| double * | pointer | ||
| ) |
This method registers a change in the file where a double value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| float * | pointer | ||
| ) |
This method registers a change in the file where a float value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| int16 * | pointer | ||
| ) |
This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| int32 * | pointer | ||
| ) |
This method registers a change in the file where an int32 value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| int64 * | pointer | ||
| ) |
This method registers a change in the file where a int64 value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| int8 * | pointer | ||
| ) |
This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where a Integer value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where a string value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| uint16 * | pointer | ||
| ) |
This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| uint32 * | pointer | ||
| ) |
This method registers a change in the file where an uint32 value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| uint64 * | pointer | ||
| ) |
This method registers a change in the file where a long value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| uint8 ** | pointer, | ||
| uint64 | length | ||
| ) |
This method registers a change in the file where an object reference of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | Object * | object, |
| uint8 * | pointer | ||
| ) |
This method registers a change in the file where an unsigned short value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
This method registers a change in the file where a Vertex3 value of an object is modified. If the UndoManager is not active, nothing happens.
This method opens an undo step and also resets the RedoStack.
| object | The object whose value is being modified. |
| pointer | A pointer to the value that will be modified. This method automatically saves the old value. |
| void jm::UndoManager::registerChange | ( | UndoChange * | change | ) |
This method registers a general change in the file. This method is used when the user derives their own custom change steps.
| change | The change to be registered. |
| void jm::UndoManager::registerRegenerationMarker | ( | EditableObject * | object | ) |
This method registers a regeneration marker that is triggered at every undo/redo step to regenerate objects in the view.
This method opens an undo step and also resets the RedoStack.
| object | The object that needs to be regenerated in the view. |
| void jm::UndoManager::registerRelease | ( | Object * | object | ) |
| void jm::UndoManager::registerRetain | ( | Object * | object | ) |
| void jm::UndoManager::registerTransactionStatus | ( | Status | status | ) |
This method registers the status of operations during a transaction. As long as status is eOK, nothing happens. If status is not eOk, we register a transaction error.
| void jm::UndoManager::rollback | ( | ) |
Rollback all changes of the transaction.
Each time this method is called, the transaction level decrements.
If the transaction level is still > 0, nothing happens. Only if the level is back to 0 the rollback of changes happens, whether the transaction status value.
| void jm::UndoManager::setActive | ( | bool | status | ) |
Sets whether changes should be tracked or not.
| status | True if changes should be tracked. |
| void jm::UndoManager::setDocument | ( | jm::Document * | document | ) |
Sets the document associated with this manager. This enables automatic tracking of changes.
| document | The document to be associated with this manager. |
| Status jm::UndoManager::transactionStatus | ( | ) | const |
Returns the transaction status.
| bool jm::UndoManager::undo | ( | ) |
Undoes the last editing step on the file and pushes the change to the RedoStack.
| unsigned int jm::UndoManager::undoCount | ( | ) | const |
Returns the number of elements on the Undo-Stack.
|
friend |