kwave  18.07.70
Kwave::UndoInsertAction Class Reference

#include <UndoInsertAction.h>

Inheritance diagram for Kwave::UndoInsertAction:
Inheritance graph
Collaboration diagram for Kwave::UndoInsertAction:
Collaboration graph

Public Slots

void setLength (sample_index_t length)
 

Public Member Functions

 UndoInsertAction (QWidget *parent_widget, const QList< unsigned int > &track_list, sample_index_t offset, sample_index_t length)
 
virtual QString description () Q_DECL_OVERRIDE
 
virtual qint64 undoSize () Q_DECL_OVERRIDE
 
virtual qint64 redoSize () Q_DECL_OVERRIDE
 
virtual bool store (Kwave::SignalManager &manager) Q_DECL_OVERRIDE
 
virtual Kwave::UndoActionundo (Kwave::SignalManager &manager, bool with_redo) Q_DECL_OVERRIDE
 
virtual void dump (const QString &indent) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::UndoAction
virtual ~UndoAction ()
 
virtual bool containsModification () const
 

Protected Attributes

QWidget * m_parent_widget
 
QList< unsigned int > m_track_list
 
sample_index_t m_offset
 
sample_index_t m_length
 

Detailed Description

Definition at line 37 of file UndoInsertAction.h.

Constructor & Destructor Documentation

◆ UndoInsertAction()

Kwave::UndoInsertAction::UndoInsertAction ( QWidget *  parent_widget,
const QList< unsigned int > &  track_list,
sample_index_t  offset,
sample_index_t  length 
)

Constructor.

Parameters
parent_widgetthe widget used as parent for displaying error messages
track_listlist of affected tracks
offsetindex of the first inserted sample
lengthnumber of inserted samples

Definition at line 30 of file UndoInsertAction.cpp.

34  :QObject(), UndoAction(),
35  m_parent_widget(parent_widget),
36  m_track_list(track_list),
37  m_offset(offset), m_length(length)
38 {
39 }
QList< unsigned int > m_track_list

Member Function Documentation

◆ description()

QString Kwave::UndoInsertAction::description ( )
virtual
See also
UndoAction::description()

Implements Kwave::UndoAction.

Definition at line 42 of file UndoInsertAction.cpp.

43 {
44  return i18n("Insert");
45 }

◆ dump()

void Kwave::UndoInsertAction::dump ( const QString &  indent)
virtual

dump, for debugging purposes

Reimplemented from Kwave::UndoAction.

Definition at line 95 of file UndoInsertAction.cpp.

References DBG, m_length, and m_offset.

96 {
97  qDebug("%sundo insert from [%lu ... %lu] (%lu)", DBG(indent),
98  static_cast<unsigned long int>(m_offset),
99  static_cast<unsigned long int>(m_offset + ((m_length) ?
100  (m_length - 1) : m_length)),
101  static_cast<unsigned long int>(m_length));
102 }
#define DBG(qs)
Definition: String.h:55

◆ redoSize()

qint64 Kwave::UndoInsertAction::redoSize ( )
virtual
See also
UndoAction::redoSize()

Implements Kwave::UndoAction.

Definition at line 54 of file UndoInsertAction.cpp.

References m_length, and m_track_list.

55 {
56  return sizeof(UndoDeleteAction) +
57  (m_length * sizeof(sample_t) * m_track_list.count());
58 }
QList< unsigned int > m_track_list
qint32 sample_t
Definition: Sample.h:37

◆ setLength

void Kwave::UndoInsertAction::setLength ( sample_index_t  length)
slot

Can be connected to a Writer's sigSamplesWritten signal if the writer has been opened in insert or append mode. In these cases the undo action's length only is determined when the writer gets closed.

See also
Kwave::Writer::sigSamplesWritten

Definition at line 89 of file UndoInsertAction.cpp.

References m_length.

90 {
91  m_length = length;
92 }

◆ store()

bool Kwave::UndoInsertAction::store ( Kwave::SignalManager manager)
virtual
See also
UndoAction::store()

Implements Kwave::UndoAction.

Definition at line 61 of file UndoInsertAction.cpp.

62 {
63  // we delete -> nothing to store
64  return true;
65 }

◆ undo()

Kwave::UndoAction * Kwave::UndoInsertAction::undo ( Kwave::SignalManager manager,
bool  with_redo 
)
virtual

Removes samples from the track.

See also
UndoAction::undo()

Implements Kwave::UndoAction.

Definition at line 68 of file UndoInsertAction.cpp.

References Kwave::SignalManager::deleteRange(), m_length, m_offset, m_parent_widget, m_track_list, and Kwave::UndoAction::store().

70 {
71  Kwave::UndoAction *redo_action = Q_NULLPTR;
72 
73  // store data for redo
74  if (with_redo) {
75  redo_action = new(std::nothrow) Kwave::UndoDeleteAction(
77  Q_ASSERT(redo_action);
78  if (!redo_action) return Q_NULLPTR;
79  redo_action->store(manager);
80  }
81 
82  // now delete the samples
84 
85  return redo_action;
86 }
QList< unsigned int > m_track_list
bool deleteRange(sample_index_t offset, sample_index_t length, const QList< unsigned int > &track_list)
virtual bool store(Kwave::SignalManager &manager)=0
Here is the call graph for this function:

◆ undoSize()

qint64 Kwave::UndoInsertAction::undoSize ( )
virtual
See also
UndoAction::undoSize()

Implements Kwave::UndoAction.

Definition at line 48 of file UndoInsertAction.cpp.

49 {
50  return sizeof(*this);
51 }

Member Data Documentation

◆ m_length

sample_index_t Kwave::UndoInsertAction::m_length
protected

number of samples

Definition at line 102 of file UndoInsertAction.h.

Referenced by dump(), redoSize(), setLength(), and undo().

◆ m_offset

sample_index_t Kwave::UndoInsertAction::m_offset
protected

first sample

Definition at line 99 of file UndoInsertAction.h.

Referenced by dump(), and undo().

◆ m_parent_widget

QWidget* Kwave::UndoInsertAction::m_parent_widget
protected

parent widget for showing error messages

Definition at line 93 of file UndoInsertAction.h.

Referenced by undo().

◆ m_track_list

QList<unsigned int> Kwave::UndoInsertAction::m_track_list
protected

list of affected tracks

Definition at line 96 of file UndoInsertAction.h.

Referenced by redoSize(), and undo().


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