comparison data/model/NoteModel.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
56 m_haveExtents(false), 56 m_haveExtents(false),
57 m_valueQuantization(0), 57 m_valueQuantization(0),
58 m_units(""), 58 m_units(""),
59 m_extendTo(0), 59 m_extendTo(0),
60 m_notifier(this, 60 m_notifier(this,
61 getId(),
61 notifyOnAdd ? 62 notifyOnAdd ?
62 DeferredNotifier::NOTIFY_ALWAYS : 63 DeferredNotifier::NOTIFY_ALWAYS :
63 DeferredNotifier::NOTIFY_DEFERRED), 64 DeferredNotifier::NOTIFY_DEFERRED),
64 m_completion(100) { 65 m_completion(100) {
65 if (subtype == FLEXI_NOTE) { 66 if (subtype == FLEXI_NOTE) {
66 m_valueMinimum = 33.f; 67 m_valueMinimum = 33.f;
67 m_valueMaximum = 88.f; 68 m_valueMaximum = 88.f;
68 } 69 }
69 PlayParameterRepository::getInstance()->addPlayable(this); 70 PlayParameterRepository::getInstance()->addPlayable
71 (getId().untyped, this);
70 } 72 }
71 73
72 NoteModel(sv_samplerate_t sampleRate, int resolution, 74 NoteModel(sv_samplerate_t sampleRate, int resolution,
73 float valueMinimum, float valueMaximum, 75 float valueMinimum, float valueMaximum,
74 bool notifyOnAdd = true, 76 bool notifyOnAdd = true,
81 m_haveExtents(true), 83 m_haveExtents(true),
82 m_valueQuantization(0), 84 m_valueQuantization(0),
83 m_units(""), 85 m_units(""),
84 m_extendTo(0), 86 m_extendTo(0),
85 m_notifier(this, 87 m_notifier(this,
88 getId(),
86 notifyOnAdd ? 89 notifyOnAdd ?
87 DeferredNotifier::NOTIFY_ALWAYS : 90 DeferredNotifier::NOTIFY_ALWAYS :
88 DeferredNotifier::NOTIFY_DEFERRED), 91 DeferredNotifier::NOTIFY_DEFERRED),
89 m_completion(100) { 92 m_completion(100) {
90 PlayParameterRepository::getInstance()->addPlayable(this); 93 PlayParameterRepository::getInstance()->addPlayable
94 (getId().untyped, this);
91 } 95 }
92 96
93 virtual ~NoteModel() { 97 virtual ~NoteModel() {
94 PlayParameterRepository::getInstance()->removePlayable(this); 98 PlayParameterRepository::getInstance()->removePlayable
99 (getId().untyped);
95 } 100 }
96 101
97 QString getTypeName() const override { return tr("Note"); } 102 QString getTypeName() const override { return tr("Note"); }
98 Subtype getSubtype() const { return m_subtype; } 103 Subtype getSubtype() const { return m_subtype; }
99 bool isSparse() const override { return true; } 104 bool isSparse() const override { return true; }
140 145
141 if (update) { 146 if (update) {
142 m_notifier.makeDeferredNotifications(); 147 m_notifier.makeDeferredNotifications();
143 } 148 }
144 149
145 emit completionChanged(); 150 emit completionChanged(getId());
146 151
147 if (completion == 100) { 152 if (completion == 100) {
148 // henceforth: 153 // henceforth:
149 m_notifier.switchMode(DeferredNotifier::NOTIFY_ALWAYS); 154 m_notifier.switchMode(DeferredNotifier::NOTIFY_ALWAYS);
150 emit modelChanged(); 155 emit modelChanged(getId());
151 } 156 }
152 } 157 }
153 158
154 /** 159 /**
155 * Query methods. 160 * Query methods.
214 } 219 }
215 220
216 m_notifier.update(e.getFrame(), e.getDuration() + m_resolution); 221 m_notifier.update(e.getFrame(), e.getDuration() + m_resolution);
217 222
218 if (allChange) { 223 if (allChange) {
219 emit modelChanged(); 224 emit modelChanged(getId());
220 } 225 }
221 } 226 }
222 227
223 void remove(Event e) override { 228 void remove(Event e) override {
224 { 229 {
225 QMutexLocker locker(&m_mutex); 230 QMutexLocker locker(&m_mutex);
226 m_events.remove(e); 231 m_events.remove(e);
227 } 232 }
228 emit modelChangedWithin(e.getFrame(), 233 emit modelChangedWithin(getId(),
234 e.getFrame(),
229 e.getFrame() + e.getDuration() + m_resolution); 235 e.getFrame() + e.getDuration() + m_resolution);
230 } 236 }
231 237
232 /** 238 /**
233 * TabularModel methods. 239 * TabularModel methods.
306 case 3: e1 = e0.withDuration(value.toInt()); break; 312 case 3: e1 = e0.withDuration(value.toInt()); break;
307 case 4: e1 = e0.withLevel(float(value.toDouble())); break; 313 case 4: e1 = e0.withLevel(float(value.toDouble())); break;
308 case 5: e1 = e0.withLabel(value.toString()); break; 314 case 5: e1 = e0.withLabel(value.toString()); break;
309 } 315 }
310 316
311 ChangeEventsCommand *command = 317 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data"));
312 new ChangeEventsCommand(this, tr("Edit Data"));
313 command->remove(e0); 318 command->remove(e0);
314 command->add(e1); 319 command->add(e1);
315 return command->finish(); 320 return command->finish();
316 } 321 }
317 322