kwave  18.07.70
SelectionTracker.h
Go to the documentation of this file.
1 /***************************************************************************
2  SelectionTracker.h - tracker for selection changes
3  -------------------
4  begin : Tue Feb 25 2014
5  copyright : (C) 2014 by Thomas Eschenbacher
6  email : 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 #ifndef SELECTION_TRACKER_H
19 #define SELECTION_TRACKER_H
20 
21 #include "config.h"
22 
23 #include <QtGlobal>
24 #include <QList>
25 #include <QObject>
26 #include <QPointer>
27 #include <QUuid>
28 
29 #include "libkwave/Sample.h"
30 #include "libkwave/SignalManager.h"
33 
34 namespace Kwave
35 {
36 
37  class Track;
38  class UndoTransaction;
39 
40  class Q_DECL_EXPORT SelectionTracker: public QObject,
41  private Kwave::UndoHandler
42  {
43  Q_OBJECT
44  public:
53  sample_index_t offset,
54  sample_index_t length,
55  const QList<unsigned int> *tracks);
56 
58  virtual ~SelectionTracker() Q_DECL_OVERRIDE;
59 
63  QList<QUuid> allTracks();
64 
72  void selectRange(QList<QUuid> tracks,
73  sample_index_t offset, sample_index_t length);
74 
79  sample_index_t offset() const { return m_offset; }
80 
85  sample_index_t length() const { return m_length; }
86 
92  sample_index_t first() const { return m_offset; }
93 
98  sample_index_t last() const {
99  return m_offset + ((m_length) ? (m_length - 1) : 0);
100  }
101 
102  signals:
103 
108  void sigTrackInserted(const QUuid &uuid);
109 
114  void sigTrackDeleted(const QUuid &uuid);
115 
120  void sigOffsetChanged(sample_index_t offset);
121 
126  void sigLengthChanged(sample_index_t length);
127 
134  void sigInvalidated(const QUuid *track,
135  sample_index_t first,
136  sample_index_t last);
137 
138  private slots:
139 
147  void slotTrackInserted(unsigned int index, Kwave::Track *track);
148 
156  void slotTrackDeleted(unsigned int index, Kwave::Track *track);
157 
166  void slotSamplesInserted(unsigned int track, sample_index_t offset,
167  sample_index_t length);
168 
177  void slotSamplesDeleted(unsigned int track, sample_index_t offset,
178  sample_index_t length);
179 
188  void slotSamplesModified(unsigned int track, sample_index_t offset,
189  sample_index_t length);
190 
191  protected:
192 
202  virtual bool saveUndoData(Kwave::UndoTransaction &undo) Q_DECL_OVERRIDE;
203 
204  private:
205 
209  class Q_DECL_EXPORT Undo: public Kwave::UndoAction
210  {
211  public:
212 
217  explicit Undo(Kwave::SelectionTracker *selection);
218 
220  virtual ~Undo() Q_DECL_OVERRIDE;
221 
225  virtual QString description() Q_DECL_OVERRIDE;
226 
233  virtual qint64 undoSize() Q_DECL_OVERRIDE;
234 
239  virtual qint64 redoSize() Q_DECL_OVERRIDE;
240 
247  virtual bool store(Kwave::SignalManager &manager) Q_DECL_OVERRIDE;
248 
259  virtual Kwave::UndoAction *undo(Kwave::SignalManager &manager,
260  bool with_redo) Q_DECL_OVERRIDE;
261 
267  virtual bool containsModification() const Q_DECL_OVERRIDE {
268  return false;
269  }
270 
272  virtual void dump(const QString &indent) Q_DECL_OVERRIDE {
273  qDebug("%s%s", DBG(indent), DBG(description()));
274  }
275 
276  private:
277 
279  QPointer<Kwave::SelectionTracker> m_tracker;
280 
282  QList<QUuid> m_tracks;
283 
286 
289 
290  };
291 
292  private:
293 
295  QPointer<Kwave::SignalManager> m_signal;
296 
299 
302 
304  QList<QUuid> m_tracks;
305 
308 
310  QMutex m_lock;
311  };
312 }
313 
314 #endif /* SELECTION_TRACKER_H */
virtual void dump(const QString &indent) Q_DECL_OVERRIDE
sample_index_t offset() const
virtual bool containsModification() const Q_DECL_OVERRIDE
Definition: App.h:33
sample_index_t first() const
quint64 sample_index_t
Definition: Sample.h:28
QPointer< Kwave::SignalManager > m_signal
QPointer< Kwave::SelectionTracker > m_tracker
sample_index_t last() const
#define DBG(qs)
Definition: String.h:55
sample_index_t length() const