Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::gui::actions::UndoStack Class Referencefinal

Serializable stack for undoable actions. More...

#include <src/gui/backend/backend/actions/undo_stack.h>

Inheritance diagram for zrythm::gui::actions::UndoStack:
Collaboration diagram for zrythm::gui::actions::UndoStack:

Public Types

enum  UndoableActionRoles { UndoableActionPtrRole = Qt::UserRole + 1 }
 

Public Member Functions

 UndoStack (QObject *parent=nullptr)
 
QHash< int, QByteArray > roleNames () const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
Q_SIGNAL void rowCountChanged (int rowCount)
 
void init_loaded (sample_rate_t engine_sample_rate)
 
std::string get_as_string (int limit) const
 Gets the list of actions as a string.
 
template<UndoableActionSubclass T>
void push (T *action)
 Take ownership of the given action.
 
std::optional< UndoableActionPtrVariant > pop ()
 
std::optional< UndoableActionPtrVariant > pop_last ()
 Pops the last (first added) element and moves everything back.
 
auto size () const
 
bool is_empty () const
 
bool empty () const
 
bool is_full () const
 
std::optional< UndoableActionPtrVariant > peek () const
 
void clear ()
 
bool contains_clip (const AudioClip &clip) const
 
template<UndoableActionSubclass T>
bool contains_action (const T &ua) const
 Checks if the undo stack contains the given action pointer.
 
void get_plugins (std::vector< zrythm::gui::old_dsp::plugins::Plugin * > &arr) const
 Returns the plugins referred to in the undo stack.
 

Data Fields

std::vector< UndoableActionPtrVariant > actions_
 Actions on the stack.
 
size_t max_size_ = 0
 Max size of the stack (if 0, unlimited).
 

Properties

QML_ELEMENT int rowCount
 

Friends

void init_from (UndoStack &obj, const UndoStack &other, utils::ObjectCloneType clone_type)
 
void to_json (nlohmann::json &j, const UndoStack &stack)
 
void from_json (const nlohmann::json &j, UndoStack &stack)
 

Detailed Description

Serializable stack for undoable actions.

This is used for both undo and redo.

Definition at line 20 of file undo_stack.h.

Member Enumeration Documentation

◆ UndoableActionRoles

enum zrythm::gui::actions::UndoStack::UndoableActionRoles

Definition at line 35 of file undo_stack.h.

Member Function Documentation

◆ clear()

void zrythm::gui::actions::UndoStack::clear ( )
inline

Definition at line 93 of file undo_stack.h.

◆ empty()

bool zrythm::gui::actions::UndoStack::empty ( ) const
inline

Definition at line 81 of file undo_stack.h.

◆ is_empty()

bool zrythm::gui::actions::UndoStack::is_empty ( ) const
inline

Definition at line 80 of file undo_stack.h.

◆ is_full()

bool zrythm::gui::actions::UndoStack::is_full ( ) const
inline

Definition at line 82 of file undo_stack.h.

◆ peek()

std::optional< UndoableActionPtrVariant > zrythm::gui::actions::UndoStack::peek ( ) const
Note
The action is owned by the undo stack.
Returns
std::optional<UndoableActionPtrVariant>

◆ pop()

std::optional< UndoableActionPtrVariant > zrythm::gui::actions::UndoStack::pop ( )
Note
The caller takes ownership of the action.
Returns
std::optional<UndoableActionPtrVariant>

◆ pop_last()

std::optional< UndoableActionPtrVariant > zrythm::gui::actions::UndoStack::pop_last ( )

Pops the last (first added) element and moves everything back.

Note
The caller takes ownership of the action.

◆ push()

template<UndoableActionSubclass T>
template void zrythm::gui::actions::UndoStack::push ( T * action)

Take ownership of the given action.

Template Parameters
T
Parameters
action

◆ size()

auto zrythm::gui::actions::UndoStack::size ( ) const
inline

Definition at line 79 of file undo_stack.h.

Friends And Related Symbol Documentation

◆ from_json

void from_json ( const nlohmann::json & j,
UndoStack & stack )
friend

Definition at line 123 of file undo_stack.h.

◆ to_json

void to_json ( nlohmann::json & j,
const UndoStack & stack )
friend

Definition at line 118 of file undo_stack.h.

Field Documentation

◆ actions_

std::vector<UndoableActionPtrVariant> zrythm::gui::actions::UndoStack::actions_

Actions on the stack.

Definition at line 132 of file undo_stack.h.

◆ max_size_

size_t zrythm::gui::actions::UndoStack::max_size_ = 0

Max size of the stack (if 0, unlimited).

Definition at line 137 of file undo_stack.h.

Property Documentation

◆ rowCount

QML_ELEMENT int zrythm::gui::actions::UndoStack::rowCount
read

Definition at line 24 of file undo_stack.h.


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