kwave  18.07.70
Kwave::SelectionTracker::Undo Class Reference
Inheritance diagram for Kwave::SelectionTracker::Undo:
Inheritance graph
Collaboration diagram for Kwave::SelectionTracker::Undo:
Collaboration graph

Public Member Functions

 Undo (Kwave::SelectionTracker *selection)
 
virtual ~Undo () 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

QPointer< Kwave::SelectionTrackerm_tracker
 
QList< QUuid > m_tracks
 
sample_index_t m_offset
 
sample_index_t m_length
 

Detailed Description

Undo action for tracking selection changes

Definition at line 209 of file SelectionTracker.h.

Constructor & Destructor Documentation

◆ Undo()

Kwave::SelectionTracker::Undo::Undo ( Kwave::SelectionTracker selection)
explicit

Constructor

Parameters
selectionpointer to the corresponding selection tracker

Definition at line 385 of file SelectionTracker.cpp.

387  m_tracker(selection),
388  m_tracks(selection ? selection->allTracks() : QList<QUuid>()),
389  m_offset(selection ? selection->offset() : 0),
390  m_length(selection ? selection->length() : 0)
391 {
392 }
sample_index_t offset() const
QList< QUuid > allTracks()
QPointer< Kwave::SelectionTracker > m_tracker
sample_index_t length() const

◆ ~Undo()

Kwave::SelectionTracker::Undo::~Undo ( )
virtual

Destructor

Definition at line 395 of file SelectionTracker.cpp.

396 {
397 }

Member Function Documentation

◆ containsModification()

virtual bool Kwave::SelectionTracker::Undo::containsModification ( ) const
inlinevirtual

This undo action does not contribute to the modification of the signal.

Returns
true always

Reimplemented from Kwave::UndoAction.

Definition at line 267 of file SelectionTracker.h.

267  {
268  return false;
269  }

◆ description()

QString Kwave::SelectionTracker::Undo::description ( )
virtual

Returns a verbose short description of the action.

Implements Kwave::UndoAction.

Definition at line 400 of file SelectionTracker.cpp.

401 {
402  return QString();
403 }

◆ dump()

virtual void Kwave::SelectionTracker::Undo::dump ( const QString &  indent)
inlinevirtual

dump, for debugging purposes

Reimplemented from Kwave::UndoAction.

Definition at line 272 of file SelectionTracker.h.

References DBG.

272  {
273  qDebug("%s%s", DBG(indent), DBG(description()));
274  }
virtual QString description() Q_DECL_OVERRIDE
#define DBG(qs)
Definition: String.h:55

◆ redoSize()

qint64 Kwave::SelectionTracker::Undo::redoSize ( )
virtual

Returns the difference of needed memory that is needed for redo.

Implements Kwave::UndoAction.

Definition at line 412 of file SelectionTracker.cpp.

413 {
414  return 0;
415 }

◆ store()

bool Kwave::SelectionTracker::Undo::store ( Kwave::SignalManager manager)
virtual

Stores the data needed for undo.

Parameters
managerthe SignalManager for modifying the signal
Note
this is the second step, after size() has been called
Returns
true if successful, false if failed (e.g. out of memory)

Implements Kwave::UndoAction.

Definition at line 418 of file SelectionTracker.cpp.

419 {
420  Q_UNUSED(manager); // data has already been stored in the constructor
421  return true;
422 }

◆ undo()

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

Takes back an action by creating a new undo action (for further redo) and restoring the previous state.

Parameters
managerthe SignalManager for modifying the signal
with_redoif true a UndoAction for redo will be created
Note
The return value is allowed to be the same object. This is useful for objects that can re-use their data for undo/redo. You have to check for this when deleting an UndoAction object after undo.

Implements Kwave::UndoAction.

Definition at line 425 of file SelectionTracker.cpp.

References m_length, m_offset, m_tracker, and m_tracks.

427 {
428  Q_UNUSED(manager);
429 
430  if (!m_tracker.isNull()) {
431  QList<QUuid> tracks = m_tracks;
432  sample_index_t ofs = m_offset;
433  sample_index_t len = m_length;
434 
435  m_tracks = m_tracker->allTracks();
436  m_offset = m_tracker->offset();
437  m_length = m_tracker->length();
438 
439  m_tracker->selectRange(tracks, ofs, len);
440  }
441 
442  return (with_redo) ? this : Q_NULLPTR;
443 }
quint64 sample_index_t
Definition: Sample.h:28
QPointer< Kwave::SelectionTracker > m_tracker

◆ undoSize()

qint64 Kwave::SelectionTracker::Undo::undoSize ( )
virtual

Returns the required amount of memory that is needed for storing undo data for the operation. This will be called to determine the free memory to be reserved.

Note
this is the first step (after the constructor)

Implements Kwave::UndoAction.

Definition at line 406 of file SelectionTracker.cpp.

407 {
408  return sizeof(*this);
409 }

Member Data Documentation

◆ m_length

sample_index_t Kwave::SelectionTracker::Undo::m_length
private

number of selected samples

Definition at line 288 of file SelectionTracker.h.

Referenced by undo().

◆ m_offset

sample_index_t Kwave::SelectionTracker::Undo::m_offset
private

start of the selection, first sample

Definition at line 285 of file SelectionTracker.h.

Referenced by undo().

◆ m_tracker

QPointer<Kwave::SelectionTracker> Kwave::SelectionTracker::Undo::m_tracker
private

pointer to the overview cache

Definition at line 279 of file SelectionTracker.h.

Referenced by undo().

◆ m_tracks

QList<QUuid> Kwave::SelectionTracker::Undo::m_tracks
private

list of selected tracks

Definition at line 282 of file SelectionTracker.h.

Referenced by undo().


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