kwave  18.07.70
Kwave::UndoSelection Class Reference

#include <UndoSelection.h>

Inheritance diagram for Kwave::UndoSelection:
Inheritance graph
Collaboration diagram for Kwave::UndoSelection:
Collaboration graph

Public Member Functions

 UndoSelection (Kwave::SignalManager &manager)
 
 UndoSelection (Kwave::SignalManager &manager, QList< unsigned int > selected_tracks, sample_index_t offset, sample_index_t length)
 
virtual ~UndoSelection () Q_DECL_OVERRIDE
 
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 bool containsModification () const Q_DECL_OVERRIDE
 
virtual void dump (const QString &indent) Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::UndoAction
virtual ~UndoAction ()
 

Private Attributes

Kwave::SignalManagerm_manager
 
sample_index_t m_offset
 
sample_index_t m_length
 
QList< unsigned int > m_selected_tracks
 

Detailed Description

This Undo action simply stores the combination of the currently selected tracks and the currently selected range of samples.

Definition at line 37 of file UndoSelection.h.

Constructor & Destructor Documentation

◆ UndoSelection() [1/2]

Kwave::UndoSelection::UndoSelection ( Kwave::SignalManager manager)
explicit

Constructor.

Parameters
managerreference to the SignalManager

Definition at line 26 of file UndoSelection.cpp.

27  :UndoAction(),
28  m_manager(manager), m_offset(0), m_length(0), m_selected_tracks()
29 {
30 }
sample_index_t m_offset
Definition: UndoSelection.h:93
sample_index_t m_length
Definition: UndoSelection.h:96
QList< unsigned int > m_selected_tracks
Definition: UndoSelection.h:99
Kwave::SignalManager & m_manager
Definition: UndoSelection.h:90

◆ UndoSelection() [2/2]

Kwave::UndoSelection::UndoSelection ( Kwave::SignalManager manager,
QList< unsigned int >  selected_tracks,
sample_index_t  offset,
sample_index_t  length 
)

Constructor.

Parameters
managerreference to the SignalManager
selected_trackslist of selected tracks
offsetstart of the selection
lengthnumber of selected samples

Definition at line 33 of file UndoSelection.cpp.

37  :UndoAction(),
38  m_manager(manager), m_offset(offset), m_length(length),
39  m_selected_tracks(selected_tracks)
40 {
41 }
sample_index_t m_offset
Definition: UndoSelection.h:93
sample_index_t m_length
Definition: UndoSelection.h:96
QList< unsigned int > m_selected_tracks
Definition: UndoSelection.h:99
Kwave::SignalManager & m_manager
Definition: UndoSelection.h:90

◆ ~UndoSelection()

Kwave::UndoSelection::~UndoSelection ( )
virtual

virtual destructor

Definition at line 44 of file UndoSelection.cpp.

45 {
46 }

Member Function Documentation

◆ containsModification()

virtual bool Kwave::UndoSelection::containsModification ( ) const
inlinevirtual
See also
UndoAction::containsModification()

Reimplemented from Kwave::UndoAction.

Definition at line 80 of file UndoSelection.h.

References dump().

80  {
81  return false;
82  }
Here is the call graph for this function:

◆ description()

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

Implements Kwave::UndoAction.

Definition at line 49 of file UndoSelection.cpp.

50 {
51  return i18n("Selection");
52 }

◆ dump()

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

dump, for debugging purposes

Reimplemented from Kwave::UndoAction.

Definition at line 103 of file UndoSelection.cpp.

References DBG, m_length, and m_offset.

Referenced by containsModification().

104 {
105  qDebug("%sselect from [%lu ... %lu] (%lu)", DBG(indent),
106  static_cast<unsigned long int>(m_offset),
107  static_cast<unsigned long int>(m_offset + ((m_length) ?
108  (m_length - 1) : m_length)),
109  static_cast<unsigned long int>(m_length));
110 }
sample_index_t m_offset
Definition: UndoSelection.h:93
sample_index_t m_length
Definition: UndoSelection.h:96
#define DBG(qs)
Definition: String.h:55
Here is the caller graph for this function:

◆ redoSize()

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

Implements Kwave::UndoAction.

Definition at line 62 of file UndoSelection.cpp.

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

63 {
64  return sizeof(*this) +
65  (m_manager.selectedTracks().count() * sizeof(unsigned int));
66 }
const QList< unsigned int > selectedTracks()
Kwave::SignalManager & m_manager
Definition: UndoSelection.h:90
Here is the call graph for this function:

◆ store()

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

Implements Kwave::UndoAction.

Definition at line 69 of file UndoSelection.cpp.

References Kwave::Selection::length(), m_length, m_offset, m_selected_tracks, Kwave::Selection::offset(), Kwave::SignalManager::selectedTracks(), and Kwave::SignalManager::selection().

70 {
71  m_offset = manager.selection().offset();
72  m_length = manager.selection().length();
74 
75  return true;
76 }
sample_index_t m_offset
Definition: UndoSelection.h:93
sample_index_t m_length
Definition: UndoSelection.h:96
Kwave::Selection & selection()
sample_index_t length() const
Definition: Selection.h:66
QList< unsigned int > m_selected_tracks
Definition: UndoSelection.h:99
const QList< unsigned int > selectedTracks()
sample_index_t offset() const
Definition: Selection.h:61
Here is the call graph for this function:

◆ undo()

Kwave::UndoAction * Kwave::UndoSelection::undo ( Kwave::SignalManager manager,
bool  with_redo 
)
virtual
See also
UndoAction::undo()

Implements Kwave::UndoAction.

Definition at line 79 of file UndoSelection.cpp.

References Kwave::Selection::length(), m_length, m_offset, m_selected_tracks, Kwave::Selection::offset(), Kwave::SignalManager::selectedTracks(), Kwave::SignalManager::selection(), Kwave::SignalManager::selectRange(), and Kwave::SignalManager::selectTracks().

81 {
82  // store current selection for later redo
83  sample_index_t old_offset = manager.selection().offset();
84  sample_index_t old_length = manager.selection().length();
85  QList<unsigned int> old_selected_tracks = manager.selectedTracks();
86 
87  // restore the previous selection
88  manager.selectRange(m_offset, m_length);
90 
91  // store data for redo
92  if (with_redo) {
93  m_offset = old_offset;
94  m_length = old_length;
95  m_selected_tracks = old_selected_tracks;
96  return this;
97  } else {
98  return Q_NULLPTR;
99  }
100 }
sample_index_t m_offset
Definition: UndoSelection.h:93
sample_index_t m_length
Definition: UndoSelection.h:96
void selectRange(sample_index_t offset, sample_index_t length)
Kwave::Selection & selection()
quint64 sample_index_t
Definition: Sample.h:28
sample_index_t length() const
Definition: Selection.h:66
QList< unsigned int > m_selected_tracks
Definition: UndoSelection.h:99
const QList< unsigned int > selectedTracks()
void selectTracks(QList< unsigned int > &track_list)
sample_index_t offset() const
Definition: Selection.h:61
Here is the call graph for this function:

◆ undoSize()

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

Implements Kwave::UndoAction.

Definition at line 55 of file UndoSelection.cpp.

References m_selected_tracks.

56 {
57  return sizeof(*this) +
58  (m_selected_tracks.count() * sizeof(unsigned int));
59 }
QList< unsigned int > m_selected_tracks
Definition: UndoSelection.h:99

Member Data Documentation

◆ m_length

sample_index_t Kwave::UndoSelection::m_length
private

Number of selected samples

Definition at line 96 of file UndoSelection.h.

Referenced by dump(), store(), and undo().

◆ m_manager

Kwave::SignalManager& Kwave::UndoSelection::m_manager
private

reference to the SignalManager is needed in redoSize()

Definition at line 90 of file UndoSelection.h.

Referenced by redoSize().

◆ m_offset

sample_index_t Kwave::UndoSelection::m_offset
private

First selected sample

Definition at line 93 of file UndoSelection.h.

Referenced by dump(), store(), and undo().

◆ m_selected_tracks

QList<unsigned int> Kwave::UndoSelection::m_selected_tracks
private

Array with indices of selected tracks.

Definition at line 99 of file UndoSelection.h.

Referenced by store(), undo(), and undoSize().


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