kwave  18.07.70
Kwave::UndoTransactionGuard Class Reference

#include <UndoTransactionGuard.h>

Collaboration diagram for Kwave::UndoTransactionGuard:
Collaboration graph

Public Member Functions

 UndoTransactionGuard (Kwave::SignalManager &manager, const QString &name=QString())
 
 UndoTransactionGuard (Kwave::Plugin &plugin, const QString &name=QString())
 
virtual ~UndoTransactionGuard ()
 
bool registerUndoAction (UndoAction *action)
 
void abort ()
 

Private Attributes

Kwave::SignalManagerm_manager
 
bool m_initial_modified
 

Detailed Description

A simple guard class for opening and closing an undo transaction operating on a SignalManager. Several nested UndoTransactionGuards (or undo transactions) are allowed.

Definition at line 40 of file UndoTransactionGuard.h.

Constructor & Destructor Documentation

◆ UndoTransactionGuard() [1/2]

Kwave::UndoTransactionGuard::UndoTransactionGuard ( Kwave::SignalManager manager,
const QString &  name = QString() 
)
explicit

Constructor. Also determines the name of the transaction if it is the first of several nested transactions.

Parameters
managerreference to the SignalManager we operate on
namethe name of the transaction as a user-readable and localized string. [optional]

Definition at line 32 of file UndoTransactionGuard.cpp.

References m_manager, and Kwave::SignalManager::startUndoTransaction().

34  :m_manager(manager),
36 {
38 }
const char name[16]
Definition: memcpy.c:510
void startUndoTransaction(const QString &name=QString())
Kwave::SignalManager & m_manager
Here is the call graph for this function:

◆ UndoTransactionGuard() [2/2]

Kwave::UndoTransactionGuard::UndoTransactionGuard ( Kwave::Plugin plugin,
const QString &  name = QString() 
)
explicit

Constructor for use from a plugin. Also determines the name of the transaction if it is the first of several nested transactions.

Parameters
pluginreference to the plugin (you should pass *this.
namethe name of the transaction as a user-readable and localized string. [optional] If you pass null or omit this parameter, the name of the plugin will be used instead.

Definition at line 41 of file UndoTransactionGuard.cpp.

References m_manager, Kwave::Plugin::name(), Kwave::SignalManager::startUndoTransaction(), and UTF8.

43  :m_manager(plugin.manager().signalManager()),
45 {
46  QString description = (name.length()) ?
47  name : i18n(UTF8(plugin.name()));
48  m_manager.startUndoTransaction(description);
49 }
virtual QString name() const
Definition: Plugin.cpp:196
Kwave::PluginManager & manager() const
Definition: Plugin.cpp:437
Kwave::SignalManager & signalManager()
const char name[16]
Definition: memcpy.c:510
void startUndoTransaction(const QString &name=QString())
Kwave::SignalManager & m_manager
#define UTF8(qs)
Definition: String.h:48
Here is the call graph for this function:

◆ ~UndoTransactionGuard()

Kwave::UndoTransactionGuard::~UndoTransactionGuard ( )
virtual

Destructor.

Definition at line 52 of file UndoTransactionGuard.cpp.

References Kwave::SignalManager::closeUndoTransaction(), and m_manager.

53 {
55 }
Kwave::SignalManager & m_manager
Here is the call graph for this function:

Member Function Documentation

◆ abort()

void Kwave::UndoTransactionGuard::abort ( )

Aborts the undo transaction, discards all undo data and restores the previous "modified" state of the signal.

Definition at line 64 of file UndoTransactionGuard.cpp.

References Kwave::SignalManager::abortUndoTransaction(), Kwave::SignalManager::isModified(), m_initial_modified, m_manager, and Kwave::SignalManager::setModified().

Referenced by Kwave::LabelItem::done(), and Kwave::LabelItem::~LabelItem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerUndoAction()

bool Kwave::UndoTransactionGuard::registerUndoAction ( UndoAction action)

Tries to free memory for a new undo action and stores all needed data if successful.

Parameters
actionUndoAction to that is to be registered
Returns
true if the action is allowed, false if the user has chosen to abort the operation if the memory limit of the undo buffer would be exceeded. The return value will also be false if the action is null.
Note
If undo is currently not enabled, the passed UndoAction will be ignored and not freed, the return value will be false. So it is safer not to call this function if undo is not enabled.

Definition at line 58 of file UndoTransactionGuard.cpp.

References m_manager, and Kwave::SignalManager::registerUndoAction().

Referenced by Kwave::LabelItem::moveTo().

59 {
60  return m_manager.registerUndoAction(action);
61 }
bool registerUndoAction(Kwave::UndoAction *action)
Kwave::SignalManager & m_manager
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_initial_modified

bool Kwave::UndoTransactionGuard::m_initial_modified
private

the initial "modified" state of the signal

Definition at line 96 of file UndoTransactionGuard.h.

Referenced by abort().

◆ m_manager

Kwave::SignalManager& Kwave::UndoTransactionGuard::m_manager
private

Reference to the responsible SignalManager

Definition at line 93 of file UndoTransactionGuard.h.

Referenced by abort(), registerUndoAction(), UndoTransactionGuard(), and ~UndoTransactionGuard().


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