comparison data/model/SparseTimeValueModel.h @ 1766:85b9b466a59f

Merge from branch by-id
author Chris Cannam
date Wed, 17 Jul 2019 14:24:51 +0100
parents 6d09d68165a4
children 13bd41bd8a17
comparison
equal deleted inserted replaced
1730:649ac57c5a2d 1766:85b9b466a59f
46 m_valueMinimum(0.f), 46 m_valueMinimum(0.f),
47 m_valueMaximum(0.f), 47 m_valueMaximum(0.f),
48 m_haveExtents(false), 48 m_haveExtents(false),
49 m_haveTextLabels(false), 49 m_haveTextLabels(false),
50 m_notifier(this, 50 m_notifier(this,
51 getId(),
51 notifyOnAdd ? 52 notifyOnAdd ?
52 DeferredNotifier::NOTIFY_ALWAYS : 53 DeferredNotifier::NOTIFY_ALWAYS :
53 DeferredNotifier::NOTIFY_DEFERRED), 54 DeferredNotifier::NOTIFY_DEFERRED),
54 m_completion(100) { 55 m_completion(100) {
55 // Model is playable, but may not sound (if units not Hz or 56 // Model is playable, but may not sound (if units not Hz or
56 // range unsuitable) 57 // range unsuitable)
57 PlayParameterRepository::getInstance()->addPlayable(this); 58 PlayParameterRepository::getInstance()->addPlayable
59 (getId().untyped, this);
58 } 60 }
59 61
60 SparseTimeValueModel(sv_samplerate_t sampleRate, int resolution, 62 SparseTimeValueModel(sv_samplerate_t sampleRate, int resolution,
61 float valueMinimum, float valueMaximum, 63 float valueMinimum, float valueMaximum,
62 bool notifyOnAdd = true) : 64 bool notifyOnAdd = true) :
65 m_valueMinimum(valueMinimum), 67 m_valueMinimum(valueMinimum),
66 m_valueMaximum(valueMaximum), 68 m_valueMaximum(valueMaximum),
67 m_haveExtents(true), 69 m_haveExtents(true),
68 m_haveTextLabels(false), 70 m_haveTextLabels(false),
69 m_notifier(this, 71 m_notifier(this,
72 getId(),
70 notifyOnAdd ? 73 notifyOnAdd ?
71 DeferredNotifier::NOTIFY_ALWAYS : 74 DeferredNotifier::NOTIFY_ALWAYS :
72 DeferredNotifier::NOTIFY_DEFERRED), 75 DeferredNotifier::NOTIFY_DEFERRED),
73 m_completion(100) { 76 m_completion(100) {
74 // Model is playable, but may not sound (if units not Hz or 77 // Model is playable, but may not sound (if units not Hz or
75 // range unsuitable) 78 // range unsuitable)
76 PlayParameterRepository::getInstance()->addPlayable(this); 79 PlayParameterRepository::getInstance()->addPlayable
80 (getId().untyped, this);
77 } 81 }
78 82
79 virtual ~SparseTimeValueModel() { 83 virtual ~SparseTimeValueModel() {
80 PlayParameterRepository::getInstance()->removePlayable(this); 84 PlayParameterRepository::getInstance()->removePlayable
85 (getId().untyped);
81 } 86 }
82 87
83 QString getTypeName() const override { return tr("Sparse Time-Value"); } 88 QString getTypeName() const override { return tr("Sparse Time-Value"); }
84 bool isSparse() const override { return true; } 89 bool isSparse() const override { return true; }
85 bool isOK() const override { return true; } 90 bool isOK() const override { return true; }
122 127
123 if (update) { 128 if (update) {
124 m_notifier.makeDeferredNotifications(); 129 m_notifier.makeDeferredNotifications();
125 } 130 }
126 131
127 emit completionChanged(); 132 emit completionChanged(getId());
128 133
129 if (completion == 100) { 134 if (completion == 100) {
130 // henceforth: 135 // henceforth:
131 m_notifier.switchMode(DeferredNotifier::NOTIFY_ALWAYS); 136 m_notifier.switchMode(DeferredNotifier::NOTIFY_ALWAYS);
132 emit modelChanged(); 137 emit modelChanged(getId());
133 } 138 }
134 } 139 }
135 140
136 /** 141 /**
137 * Query methods. 142 * Query methods.
200 } 205 }
201 206
202 m_notifier.update(e.getFrame(), m_resolution); 207 m_notifier.update(e.getFrame(), m_resolution);
203 208
204 if (allChange) { 209 if (allChange) {
205 emit modelChanged(); 210 emit modelChanged(getId());
206 } 211 }
207 } 212 }
208 213
209 void remove(Event e) override { 214 void remove(Event e) override {
210 { 215 {
211 QMutexLocker locker(&m_mutex); 216 QMutexLocker locker(&m_mutex);
212 m_events.remove(e); 217 m_events.remove(e);
213 } 218 }
214 emit modelChangedWithin(e.getFrame(), e.getFrame() + m_resolution); 219 emit modelChangedWithin(getId(),
220 e.getFrame(), e.getFrame() + m_resolution);
215 } 221 }
216 222
217 /** 223 /**
218 * TabularModel methods. 224 * TabularModel methods.
219 */ 225 */
287 case 1: e1 = e0.withFrame(value.toInt()); break; 293 case 1: e1 = e0.withFrame(value.toInt()); break;
288 case 2: e1 = e0.withValue(float(value.toDouble())); break; 294 case 2: e1 = e0.withValue(float(value.toDouble())); break;
289 case 3: e1 = e0.withLabel(value.toString()); break; 295 case 3: e1 = e0.withLabel(value.toString()); break;
290 } 296 }
291 297
292 ChangeEventsCommand *command = 298 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data"));
293 new ChangeEventsCommand(this, tr("Edit Data"));
294 command->remove(e0); 299 command->remove(e0);
295 command->add(e1); 300 command->add(e1);
296 return command->finish(); 301 return command->finish();
297 } 302 }
298 303