kwave  18.07.70
Kwave::UndoManager Class Reference

#include <UndoManager.h>

Collaboration diagram for Kwave::UndoManager:
Collaboration graph

Public Member Functions

 UndoManager ()
 
virtual ~UndoManager ()
 
bool registerHandler (Kwave::UndoHandler *handler)
 
bool unregisterHandler (Kwave::UndoHandler *handler)
 
bool startUndoTransaction (Kwave::UndoTransaction *transaction)
 
bool closeUndoTransaction (Kwave::UndoTransaction *transaction)
 

Private Attributes

QList< Kwave::UndoHandler * > m_handlers
 

Detailed Description

Definition at line 32 of file UndoManager.h.

Constructor & Destructor Documentation

◆ UndoManager()

Kwave::UndoManager::UndoManager ( )

Constructor

Definition at line 24 of file UndoManager.cpp.

25  :m_handlers()
26 {
27 }
QList< Kwave::UndoHandler * > m_handlers
Definition: UndoManager.h:86

◆ ~UndoManager()

Kwave::UndoManager::~UndoManager ( )
virtual

Destructor

Definition at line 30 of file UndoManager.cpp.

References m_handlers.

31 {
32  m_handlers.clear();
33 }
QList< Kwave::UndoHandler * > m_handlers
Definition: UndoManager.h:86

Member Function Documentation

◆ closeUndoTransaction()

bool Kwave::UndoManager::closeUndoTransaction ( Kwave::UndoTransaction transaction)

Should be called when a undo transaction is completed

Parameters
transactionthe undo transaction that has been closed
Returns
true if successful, false if failed

Definition at line 70 of file UndoManager.cpp.

72 {
73  Q_UNUSED(transaction);
74  return true;
75 }

◆ registerHandler()

bool Kwave::UndoManager::registerHandler ( Kwave::UndoHandler handler)

Register an instance of an undo handler

Parameters
handlerthe undo handler to register
Returns
true if successful, false if failed (e.g. duplicate registration or null pointer)

Definition at line 36 of file UndoManager.cpp.

References m_handlers.

Referenced by Kwave::SelectionTracker::SelectionTracker().

37 {
38  if (!handler) return false;
39  if (m_handlers.contains(handler)) return false;
40  m_handlers.append(handler);
41  return true;
42 }
QList< Kwave::UndoHandler * > m_handlers
Definition: UndoManager.h:86
Here is the caller graph for this function:

◆ startUndoTransaction()

bool Kwave::UndoManager::startUndoTransaction ( Kwave::UndoTransaction transaction)

Should be called when a undo transaction has been started, calls saveUndoData of all undo handlers

Parameters
transactionthe newly created undo transaction (still empty)
Returns
true if successful, false if failed (e.g. one undo handler failed saving it's data)

Definition at line 54 of file UndoManager.cpp.

References m_handlers, and Kwave::UndoHandler::saveUndoData().

Referenced by Kwave::SignalManager::startUndoTransaction().

56 {
57  if (!transaction) return false;
58 
59  foreach (Kwave::UndoHandler *handler, m_handlers) {
60  Q_ASSERT(handler);
61  if (!handler) continue;
62  if (!(handler->saveUndoData(*transaction)))
63  return false;
64  }
65 
66  return true;
67 }
virtual bool saveUndoData(Kwave::UndoTransaction &undo)=0
QList< Kwave::UndoHandler * > m_handlers
Definition: UndoManager.h:86
Here is the call graph for this function:
Here is the caller graph for this function:

◆ unregisterHandler()

bool Kwave::UndoManager::unregisterHandler ( Kwave::UndoHandler handler)

Unregister an instance of an undo handler previously registered through registerHandler()

Parameters
handlerthe undo handler to unregister
Returns
true if successful, false if failed (e.g. if not registered or null pointer)

Definition at line 45 of file UndoManager.cpp.

References m_handlers.

Referenced by Kwave::SelectionTracker::~SelectionTracker().

46 {
47  if (!handler) return false;
48  if (!m_handlers.contains(handler)) return false;
49  m_handlers.removeAll(handler);
50  return true;
51 }
QList< Kwave::UndoHandler * > m_handlers
Definition: UndoManager.h:86
Here is the caller graph for this function:

Member Data Documentation

◆ m_handlers

QList<Kwave::UndoHandler *> Kwave::UndoManager::m_handlers
private

list of all registered undo handlers

Definition at line 86 of file UndoManager.h.

Referenced by registerHandler(), startUndoTransaction(), unregisterHandler(), and ~UndoManager().


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