![]() |
Mapper
0.9.0
API documentation
|
Manages the history of steps for undoing and redoing changes to a map. More...
#include <undo_manager.h>
Classes | |
struct | State |
Keeps the state of an UndoManager. More... | |
Signals | |
void | canUndoChanged (bool can_undo) |
This signal is emitted whenever the value of canUndo() changes. More... | |
void | canRedoChanged (bool can_redo) |
This signal is emitted whenever the value of canRedo() changes. More... | |
void | cleanChanged (bool clean) |
This signal is emitted whenever the value of isClean() changes. More... | |
void | loadedChanged (bool loaded) |
This signal is emitted whenever the value of isLoaded() changes. More... | |
Public Member Functions | |
UndoManager (Map *map) | |
Constructs an empty undo manager. More... | |
~UndoManager () override | |
Destroys the undo manager, deleting all managed steps. More... | |
void | clear () |
Deletes all undo and redo steps. More... | |
void | push (std::unique_ptr< UndoStep > &&step) |
Adds a new undo step to the manager. More... | |
bool | canUndo () const |
Returns true iff valid undo steps are available. More... | |
bool | undo (QWidget *dialog_parent=nullptr) |
Executes the current undo step. More... | |
bool | canRedo () const |
Returns true iff valid redo steps are available. More... | |
bool | redo (QWidget *dialog_parent=nullptr) |
Executes the current redo step. More... | |
bool | isClean () const |
Returns true iff the current state is the clean state. More... | |
void | setClean () |
Marks the current state as the clean state. More... | |
bool | isLoaded () const |
Returns true iff the current state is the loaded state. More... | |
void | setLoaded () |
Marks the current state as the loaded state. More... | |
int | undoStepCount () const |
Returns the current number of undo steps. More... | |
UndoStep * | nextUndoStep () const |
Returns the step performed by the next call to undo(). More... | |
int | redoStepCount () const |
Returns the current number of redo steps. More... | |
UndoStep * | nextRedoStep () const |
Returns the step performed by the next call to redo(). More... | |
void | saveUndo (QXmlStreamWriter &xml) const |
Saves the undo steps to the file in xml format. More... | |
void | saveRedo (QXmlStreamWriter &xml) const |
Saves the undo steps to the file in xml format. More... | |
void | loadUndo (QXmlStreamReader &xml, SymbolDictionary &symbol_dict) |
Loads the undo steps from the file in xml format. More... | |
void | loadRedo (QXmlStreamReader &xml, SymbolDictionary &symbol_dict) |
Loads the redo steps from the file in xml format. More... | |
![]() | |
virtual const QMetaObject * | metaObject () const const |
QObject (QObject *parent) | |
virtual | ~QObject () |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
QString | objectName () const const |
void | setObjectName (const QString &name) |
bool | isWidgetType () const const |
bool | isWindowType () const const |
bool | signalsBlocked () const const |
bool | blockSignals (bool block) |
QThread * | thread () const const |
void | moveToThread (QThread *targetThread) |
int | startTimer (int interval, Qt::TimerType timerType) |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType) |
void | killTimer (int id) |
T | findChild (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QString &name, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegExp ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () const const |
void | setParent (QObject *parent) |
void | installEventFilter (QObject *filterObj) |
void | removeEventFilter (QObject *obj) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) const const |
bool | disconnect (const QObject *receiver, const char *method) const const |
void | dumpObjectTree () |
void | dumpObjectInfo () |
void | dumpObjectTree () const const |
void | dumpObjectInfo () const const |
bool | setProperty (const char *name, const QVariant &value) |
QVariant | property (const char *name) const const |
QList< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
Q_CLASSINFO (Name, Value) | |
Q_INTERFACES (...) | |
Q_PROPERTY (...) | |
Q_ENUMS (...) | |
Q_FLAGS (...) | |
Q_ENUM (...) | |
Q_FLAG (...) | |
Q_ENUM_NS (...) | |
Q_FLAG_NS (...) | |
Q_OBJECT Q_OBJECT | |
Q_GADGET Q_GADGET | |
Q_NAMESPACE Q_NAMESPACE | |
Q_SIGNALS Q_SIGNALS | |
Q_SIGNAL Q_SIGNAL | |
Q_SLOTS Q_SLOTS | |
Q_SLOT Q_SLOT | |
Q_EMIT Q_EMIT | |
Q_INVOKABLE Q_INVOKABLE | |
Q_REVISION Q_REVISION | |
Q_SET_OBJECT_NAME (Object) | |
QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT | |
Static Public Attributes | |
static constexpr std::size_t | max_undo_steps = 128 |
The maximum number of steps kept for undo() and redo(), respectively. More... | |
Protected Types | |
using | StepList = std::vector< std::unique_ptr< UndoStep > > |
A list of UndoSteps. More... | |
Protected Member Functions | |
void | clearRedoSteps () |
Deletes all redo steps and removes them from undo_steps. More... | |
void | validateUndoSteps () |
Validates the list of steps available for undo(). More... | |
void | validateRedoSteps () |
Validates the list of steps available for redo(). More... | |
void | emitChangedSignals (UndoManager::State const &old_state) |
Emits "changed" signals for all properties which are different from old_state. More... | |
void | updateMapState (const UndoStep *step) const |
Set the map's current part and selection from the given undo step. More... | |
![]() | |
QObject * | sender () const const |
int | senderSignalIndex () const const |
int | receivers (const char *signal) const const |
bool | isSignalConnected (const QMetaMethod &signal) const const |
virtual void | timerEvent (QTimerEvent *event) |
virtual void | childEvent (QChildEvent *event) |
virtual void | customEvent (QEvent *event) |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
Additional Inherited Members | |
![]() | |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, Functor functor) |
QMetaObject::Connection | connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
bool | disconnect (const QMetaObject::Connection &connection) |
bool | disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method) |
![]() | |
typedef | QObjectList |
![]() | |
objectName | |
Manages the history of steps for undoing and redoing changes to a map.
This API is intentionally similar to QUndoStack. (QUndoStack is part of Qt since 4.2 and available under the GPL3.)
|
protected |
A list of UndoSteps.
OpenOrienteering::UndoManager::UndoManager | ( | Map * | map | ) |
Constructs an empty undo manager.
|
override |
Destroys the undo manager, deleting all managed steps.
bool OpenOrienteering::UndoManager::canRedo | ( | ) | const |
Returns true iff valid redo steps are available.
|
signal |
This signal is emitted whenever the value of canRedo() changes.
bool OpenOrienteering::UndoManager::canUndo | ( | ) | const |
Returns true iff valid undo steps are available.
|
signal |
This signal is emitted whenever the value of canUndo() changes.
|
signal |
This signal is emitted whenever the value of isClean() changes.
void OpenOrienteering::UndoManager::clear | ( | ) |
Deletes all undo and redo steps.
Can be necessary if changes are made to objects which are not tracked by the undo system but related to it.
|
protected |
Deletes all redo steps and removes them from undo_steps.
|
protected |
Emits "changed" signals for all properties which are different from old_state.
bool OpenOrienteering::UndoManager::isClean | ( | ) | const |
Returns true iff the current state is the clean state.
bool OpenOrienteering::UndoManager::isLoaded | ( | ) | const |
Returns true iff the current state is the loaded state.
|
signal |
This signal is emitted whenever the value of isLoaded() changes.
void OpenOrienteering::UndoManager::loadRedo | ( | QXmlStreamReader & | xml, |
SymbolDictionary & | symbol_dict | ||
) |
Loads the redo steps from the file in xml format.
Any existing redo steps will be deleted first, but undo steps are left untouched.
void OpenOrienteering::UndoManager::loadUndo | ( | QXmlStreamReader & | xml, |
SymbolDictionary & | symbol_dict | ||
) |
Loads the undo steps from the file in xml format.
Any existing undo steps and redo steps will be deleted first.
UndoStep * OpenOrienteering::UndoManager::nextRedoStep | ( | ) | const |
Returns the step performed by the next call to redo().
UndoStep * OpenOrienteering::UndoManager::nextUndoStep | ( | ) | const |
Returns the step performed by the next call to undo().
void OpenOrienteering::UndoManager::push | ( | std::unique_ptr< UndoStep > && | step | ) |
Adds a new undo step to the manager.
All recorded redo steps will be deleted.
Executes the current redo step.
int OpenOrienteering::UndoManager::redoStepCount | ( | ) | const |
Returns the current number of redo steps.
This figure may include invalid steps. So canRedo() may return false even if redoStepCount() is positive.
void OpenOrienteering::UndoManager::saveRedo | ( | QXmlStreamWriter & | xml | ) | const |
Saves the undo steps to the file in xml format.
void OpenOrienteering::UndoManager::saveUndo | ( | QXmlStreamWriter & | xml | ) | const |
Saves the undo steps to the file in xml format.
void OpenOrienteering::UndoManager::setClean | ( | ) |
Marks the current state as the clean state.
Whenever the manager returns to this state through the use of undo()/redo(), it emits the signal cleanChanged().
Emits cleanChanged(true) if the current state was not the clean state.
Call this when the currently edited file is loaded or saved.
void OpenOrienteering::UndoManager::setLoaded | ( | ) |
Marks the current state as the loaded state.
When calling undo() while in loaded state, an extra warning will be displayed.
Call this when the currently edited file is loaded.
Executes the current undo step.
If the UndoManager is in loaded state, the user is offered the choice to cancel the operation.
dialog_parent | Optional QWidget parent for any dialogs shown by the method. |
int OpenOrienteering::UndoManager::undoStepCount | ( | ) | const |
Returns the current number of undo steps.
This figure may include invalid steps. So canUndo() may return false even if undoStepCount() is positive.
|
protected |
Set the map's current part and selection from the given undo step.
This method relies on the step already being applied to the map, i.e. all affected parts and objects do exist.
|
protected |
Validates the list of steps available for redo().
This method removes elements from undo_steps which are no longer reachable via valid steps, or which exceed the max_undo_steps limit, with invalid NoOpUndoStep objects, thus releasing the memory which was originally occupied by now obsolete undo steps.
|
protected |
Validates the list of steps available for undo().
In order to maintain the validness of current_index etc., this method does not remove elements from undo_steps. Instead, it replaces steps which are no longer reachable via valid steps, or which exceed the max_undo_steps limit, with invalid NoOpUndoStep objects, thus releasing the memory which was originally occupied by now obsolete undo steps.
|
static |