kwave  18.07.70
UndoInsertAction.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  UndoInsertAction.cpp - UndoAction for insertion of a range of samples
3  -------------------
4  begin : Jun 14 2001
5  copyright : (C) 2001 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <new>
21 
22 #include <KLocalizedString>
23 
24 #include "libkwave/SignalManager.h"
28 
29 //***************************************************************************
31  const QList<unsigned int> &track_list,
32  sample_index_t offset,
33  sample_index_t length)
34  :QObject(), UndoAction(),
35  m_parent_widget(parent_widget),
36  m_track_list(track_list),
37  m_offset(offset), m_length(length)
38 {
39 }
40 
41 //***************************************************************************
43 {
44  return i18n("Insert");
45 }
46 
47 //***************************************************************************
49 {
50  return sizeof(*this);
51 }
52 
53 //***************************************************************************
55 {
56  return sizeof(UndoDeleteAction) +
57  (m_length * sizeof(sample_t) * m_track_list.count());
58 }
59 
60 //***************************************************************************
62 {
63  // we delete -> nothing to store
64  return true;
65 }
66 
67 //***************************************************************************
69  Kwave::SignalManager &manager, bool with_redo)
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 }
87 
88 //***************************************************************************
90 {
91  m_length = length;
92 }
93 
94 //***************************************************************************
95 void Kwave::UndoInsertAction::dump(const QString &indent)
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 }
103 
104 //***************************************************************************
105 //***************************************************************************
void setLength(sample_index_t length)
virtual qint64 redoSize() Q_DECL_OVERRIDE
virtual bool store(Kwave::SignalManager &manager) Q_DECL_OVERRIDE
QList< unsigned int > m_track_list
quint64 sample_index_t
Definition: Sample.h:28
bool deleteRange(sample_index_t offset, sample_index_t length, const QList< unsigned int > &track_list)
virtual QString description() Q_DECL_OVERRIDE
virtual void dump(const QString &indent) Q_DECL_OVERRIDE
UndoInsertAction(QWidget *parent_widget, const QList< unsigned int > &track_list, sample_index_t offset, sample_index_t length)
virtual qint64 undoSize() Q_DECL_OVERRIDE
#define DBG(qs)
Definition: String.h:55
virtual Kwave::UndoAction * undo(Kwave::SignalManager &manager, bool with_redo) Q_DECL_OVERRIDE
virtual bool store(Kwave::SignalManager &manager)=0
qint32 sample_t
Definition: Sample.h:37