comparison data/model/NoteModel.h @ 1742:52705a328b34 by-id

Rejig ById so as to put everything in a single pool, so that at the core you can go from numeric id (untyped) to anything the object can be dynamic_cast to. Useful for building other abstractions like PlayParameter-type registrations that don't know about e.g. Models. Probably some more tweaking needed. Also add tests
author Chris Cannam
date Fri, 28 Jun 2019 17:36:30 +0100
parents 9d82b164f264
children 77543124651b
comparison
equal deleted inserted replaced
1741:9d82b164f264 1742:52705a328b34
64 m_completion(100) { 64 m_completion(100) {
65 if (subtype == FLEXI_NOTE) { 65 if (subtype == FLEXI_NOTE) {
66 m_valueMinimum = 33.f; 66 m_valueMinimum = 33.f;
67 m_valueMaximum = 88.f; 67 m_valueMaximum = 88.f;
68 } 68 }
69 PlayParameterRepository::getInstance()->addPlayable(this); 69 PlayParameterRepository::getInstance()->addPlayable(getId().untyped);
70 } 70 }
71 71
72 NoteModel(sv_samplerate_t sampleRate, int resolution, 72 NoteModel(sv_samplerate_t sampleRate, int resolution,
73 float valueMinimum, float valueMaximum, 73 float valueMinimum, float valueMaximum,
74 bool notifyOnAdd = true, 74 bool notifyOnAdd = true,
85 m_notifier(this, 85 m_notifier(this,
86 notifyOnAdd ? 86 notifyOnAdd ?
87 DeferredNotifier::NOTIFY_ALWAYS : 87 DeferredNotifier::NOTIFY_ALWAYS :
88 DeferredNotifier::NOTIFY_DEFERRED), 88 DeferredNotifier::NOTIFY_DEFERRED),
89 m_completion(100) { 89 m_completion(100) {
90 PlayParameterRepository::getInstance()->addPlayable(this); 90 PlayParameterRepository::getInstance()->addPlayable(getId().untyped);
91 } 91 }
92 92
93 virtual ~NoteModel() { 93 virtual ~NoteModel() {
94 PlayParameterRepository::getInstance()->removePlayable(this); 94 PlayParameterRepository::getInstance()->removePlayable(getId().untyped);
95 } 95 }
96 96
97 QString getTypeName() const override { return tr("Note"); } 97 QString getTypeName() const override { return tr("Note"); }
98 Subtype getSubtype() const { return m_subtype; } 98 Subtype getSubtype() const { return m_subtype; }
99 bool isSparse() const override { return true; } 99 bool isSparse() const override { return true; }
306 case 3: e1 = e0.withDuration(value.toInt()); break; 306 case 3: e1 = e0.withDuration(value.toInt()); break;
307 case 4: e1 = e0.withLevel(float(value.toDouble())); break; 307 case 4: e1 = e0.withLevel(float(value.toDouble())); break;
308 case 5: e1 = e0.withLabel(value.toString()); break; 308 case 5: e1 = e0.withLabel(value.toString()); break;
309 } 309 }
310 310
311 auto command = new ChangeEventsCommand<Model>(getId(), tr("Edit Data")); 311 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data"));
312 command->remove(e0); 312 command->remove(e0);
313 command->add(e1); 313 command->add(e1);
314 return command->finish(); 314 return command->finish();
315 } 315 }
316 316