Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
Signals | Public Member Functions | Private Member Functions | Private Attributes | List of all members
UndoRedoManager Class Reference
+ Inheritance diagram for UndoRedoManager:
Inheritance graph
[legend]
+ Collaboration diagram for UndoRedoManager:
Collaboration graph
[legend]

Signals

void didUpdateUndoStack ()
 

Public Member Functions

 UndoRedoManager (Editor *editor)
 
bool init () override
 
Status load (Object *) override
 
Status save (Object *) override
 
void record (SAVESTATE_ID SaveStateId, const QString &description)
 Records the given save state.
 
bool hasUnsavedChanges () const
 Checks whether there are unsaved changes.
 
SAVESTATE_ID createState (UndoRedoRecordType recordType)
 Prepares and returns an save state with common data.
 
void addUserState (SAVESTATE_ID SaveStateId, const UserSaveState &userState)
 Adds userState to the saveState found at SaveStateId If no record is found matching the id, nothing happens.
 
QAction * createUndoAction (QObject *parent, const QIcon &icon)
 
QAction * createRedoAction (QObject *parent, const QIcon &icon)
 
void updateUndoAction (QAction *undoAction)
 
void updateRedoAction (QAction *redoAction)
 
void clearStack ()
 Clears the undo stack.
 
void legacyBackup (const QString &undoText)
 
bool legacyBackup (int backupLayer, int backupFrame, const QString &undoText)
 
void sanitizeLegacyBackupElementsAfterLayerDeletion (int layerIndex)
 Restores integrity of the backup elements after a layer has been deleted.
 
void restoreLegacyKey ()
 
void rememberLastModifiedFrame (int layerNumber, int frameNumber)
 
void onSettingChanged (SETTING setting)
 
- Public Member Functions inherited from BaseManager
Editor * editor () const
 
Object * object () const
 
virtual bool init ()=0
 
virtual Status load (Object *o)=0
 
virtual Status save (Object *o)=0
 
virtual void workingLayerChanged (Layer *)
 
- Public Member Functions inherited from QObject
virtual const QMetaObject * metaObject () const const
 
 QObject (QObject *parent)
 
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 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 &regExp, 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 &regExp)
 
 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_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 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
 

Private Member Functions

void replaceKeyFrame (const UndoSaveState &undoState, const QString &description)
 
void replaceBitmap (const UndoSaveState &undoState, const QString &description)
 
void replaceVector (const UndoSaveState &undoState, const QString &description)
 
void addKeyFrame (const UndoSaveState &undoState, const QString &description)
 
void removeKeyFrame (const UndoSaveState &undoState, const QString &description)
 
void moveKeyFrames (const UndoSaveState &undoState, const QString &description)
 
void initCommonKeyFrameState (UndoSaveState *undoSaveState) const
 
void pushCommand (QUndoCommand *command)
 
void clearState (UndoSaveState *&state)
 
void clearSaveStates ()
 
void legacyUndo ()
 
void legacyRedo ()
 

Private Attributes

QUndoStack mUndoStack
 
QMap< SAVESTATE_ID, UndoSaveState * > mSaveStates
 
int mLegacyBackupIndex = -1
 
LegacyBackupElement * mLegacyBackupAtSave = nullptr
 
QList< LegacyBackupElement * > mLegacyBackupList
 
int mLegacyLastModifiedLayer = -1
 
int mLegacyLastModifiedFrame = -1
 
SAVESTATE_ID mSaveStateId = 1
 
bool mNewBackupSystemEnabled = false
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
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)
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from BaseManager
 BaseManager (Editor *editor, const QString &name)
 
- Protected Member Functions inherited from QObject
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)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Definition at line 118 of file undoredomanager.h.

Constructor & Destructor Documentation

◆ UndoRedoManager()

UndoRedoManager::UndoRedoManager ( Editor *  editor)
explicit

Definition at line 45 of file undoredomanager.cpp.

◆ ~UndoRedoManager()

UndoRedoManager::~UndoRedoManager ( )
override

Definition at line 50 of file undoredomanager.cpp.

Member Function Documentation

◆ addKeyFrame()

void UndoRedoManager::addKeyFrame ( const UndoSaveState &  undoState,
const QString &  description 
)
private

Definition at line 187 of file undoredomanager.cpp.

◆ addUserState()

void UndoRedoManager::addUserState ( SAVESTATE_ID  SaveStateId,
const UserSaveState &  userState 
)

Adds userState to the saveState found at SaveStateId If no record is found matching the id, nothing happens.

Parameters
SaveStateIdThe id used to fetch the saveState
userStateThe data to be inserted onto on the saveState

Definition at line 274 of file undoredomanager.cpp.

◆ clearSaveStates()

void UndoRedoManager::clearSaveStates ( )
private

Definition at line 148 of file undoredomanager.cpp.

◆ clearStack()

void UndoRedoManager::clearStack ( )

Clears the undo stack.

Definition at line 396 of file undoredomanager.cpp.

◆ clearState()

void UndoRedoManager::clearState ( UndoSaveState *&  state)
private

Definition at line 140 of file undoredomanager.cpp.

◆ createRedoAction()

QAction * UndoRedoManager::createRedoAction ( QObject *  parent,
const QIcon &  icon 
)

Definition at line 329 of file undoredomanager.cpp.

◆ createState()

SAVESTATE_ID UndoRedoManager::createState ( UndoRedoRecordType  recordType)

Prepares and returns an save state with common data.

Returns
A UndoSaveState struct with common keyframe data

Definition at line 261 of file undoredomanager.cpp.

◆ createUndoAction()

QAction * UndoRedoManager::createUndoAction ( QObject *  parent,
const QIcon &  icon 
)

Definition at line 309 of file undoredomanager.cpp.

◆ hasUnsavedChanges()

bool UndoRedoManager::hasUnsavedChanges ( ) const

Checks whether there are unsaved changes.

Returns
true if there are unsaved changes, otherwise false

Definition at line 159 of file undoredomanager.cpp.

◆ init()

bool UndoRedoManager::init ( )
overridevirtual

Implements BaseManager.

Definition at line 60 of file undoredomanager.cpp.

◆ initCommonKeyFrameState()

void UndoRedoManager::initCommonKeyFrameState ( UndoSaveState *  undoSaveState) const
private

Definition at line 280 of file undoredomanager.cpp.

◆ legacyBackup() [1/2]

void UndoRedoManager::legacyBackup ( const QString &  undoText)

Definition at line 413 of file undoredomanager.cpp.

◆ legacyBackup() [2/2]

bool UndoRedoManager::legacyBackup ( int  backupLayer,
int  backupFrame,
const QString &  undoText 
)

Definition at line 455 of file undoredomanager.cpp.

◆ legacyRedo()

void UndoRedoManager::legacyRedo ( )
private

Definition at line 730 of file undoredomanager.cpp.

◆ legacyUndo()

void UndoRedoManager::legacyUndo ( )
private

Definition at line 689 of file undoredomanager.cpp.

◆ load()

Status UndoRedoManager::load ( Object *  )
overridevirtual

Implements BaseManager.

Definition at line 80 of file undoredomanager.cpp.

◆ moveKeyFrames()

void UndoRedoManager::moveKeyFrames ( const UndoSaveState &  undoState,
const QString &  description 
)
private

Definition at line 207 of file undoredomanager.cpp.

◆ onSettingChanged()

void UndoRedoManager::onSettingChanged ( SETTING  setting)

Definition at line 70 of file undoredomanager.cpp.

◆ pushCommand()

void UndoRedoManager::pushCommand ( QUndoCommand *  command)
private

Definition at line 171 of file undoredomanager.cpp.

◆ record()

void UndoRedoManager::record ( SAVESTATE_ID  SaveStateId,
const QString &  description 
)

Records the given save state.

The input save state is cleaned up and set to nullptr after use.

Parameters
SaveStateIdThe state that will be fetched and recorded based on the input SaveStateId.
descriptionThe description that will bound to the undo/redo action.

Definition at line 96 of file undoredomanager.cpp.

◆ rememberLastModifiedFrame()

void UndoRedoManager::rememberLastModifiedFrame ( int  layerNumber,
int  frameNumber 
)

Definition at line 741 of file undoredomanager.cpp.

◆ removeKeyFrame()

void UndoRedoManager::removeKeyFrame ( const UndoSaveState &  undoState,
const QString &  description 
)
private

Definition at line 178 of file undoredomanager.cpp.

◆ replaceBitmap()

void UndoRedoManager::replaceBitmap ( const UndoSaveState &  undoState,
const QString &  description 
)
private

Definition at line 218 of file undoredomanager.cpp.

◆ replaceKeyFrame()

void UndoRedoManager::replaceKeyFrame ( const UndoSaveState &  undoState,
const QString &  description 
)
private

Definition at line 196 of file undoredomanager.cpp.

◆ replaceVector()

void UndoRedoManager::replaceVector ( const UndoSaveState &  undoState,
const QString &  description 
)
private

Definition at line 240 of file undoredomanager.cpp.

◆ restoreLegacyKey()

void UndoRedoManager::restoreLegacyKey ( )

Definition at line 634 of file undoredomanager.cpp.

◆ sanitizeLegacyBackupElementsAfterLayerDeletion()

void UndoRedoManager::sanitizeLegacyBackupElementsAfterLayerDeletion ( int  layerIndex)

Restores integrity of the backup elements after a layer has been deleted.

Removes backup elements affecting the deleted layer and adjusts the layer index on other backup elements as necessary.

Parameters
layerIndexThe index of the layer that was deleted
Warning
This serves as a temporary hack to prevent crashes until #864 is done (see #1412).

Definition at line 569 of file undoredomanager.cpp.

◆ save()

Status UndoRedoManager::save ( Object *  )
overridevirtual

Implements BaseManager.

Definition at line 86 of file undoredomanager.cpp.

◆ updateRedoAction()

void UndoRedoManager::updateRedoAction ( QAction *  redoAction)

Definition at line 375 of file undoredomanager.cpp.

◆ updateUndoAction()

void UndoRedoManager::updateUndoAction ( QAction *  undoAction)

Definition at line 349 of file undoredomanager.cpp.

Member Data Documentation

◆ mLegacyBackupAtSave

LegacyBackupElement* UndoRedoManager::mLegacyBackupAtSave = nullptr
private

Definition at line 214 of file undoredomanager.h.

◆ mLegacyBackupIndex

int UndoRedoManager::mLegacyBackupIndex = -1
private

Definition at line 213 of file undoredomanager.h.

◆ mLegacyBackupList

QList<LegacyBackupElement*> UndoRedoManager::mLegacyBackupList
private

Definition at line 215 of file undoredomanager.h.

◆ mLegacyLastModifiedFrame

int UndoRedoManager::mLegacyLastModifiedFrame = -1
private

Definition at line 218 of file undoredomanager.h.

◆ mLegacyLastModifiedLayer

int UndoRedoManager::mLegacyLastModifiedLayer = -1
private

Definition at line 217 of file undoredomanager.h.

◆ mNewBackupSystemEnabled

bool UndoRedoManager::mNewBackupSystemEnabled = false
private

Definition at line 222 of file undoredomanager.h.

◆ mSaveStateId

SAVESTATE_ID UndoRedoManager::mSaveStateId = 1
private

Definition at line 220 of file undoredomanager.h.

◆ mSaveStates

QMap<SAVESTATE_ID, UndoSaveState*> UndoRedoManager::mSaveStates
private

Definition at line 210 of file undoredomanager.h.

◆ mUndoStack

QUndoStack UndoRedoManager::mUndoStack
private

Definition at line 208 of file undoredomanager.h.


The documentation for this class was generated from the following files:
  • core_lib/src/managers/undoredomanager.h
  • core_lib/src/managers/undoredomanager.cpp
Generated on Sun Apr 19 2026 11:29:09 for Pencil2D by doxygen 1.9.6 based on revision b701d7965064c33ede63718d846965b58fcaf29b