comparison data/model/SparseOneDimensionalModel.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
47 bool notifyOnAdd = true) : 47 bool notifyOnAdd = true) :
48 m_sampleRate(sampleRate), 48 m_sampleRate(sampleRate),
49 m_resolution(resolution), 49 m_resolution(resolution),
50 m_haveTextLabels(false), 50 m_haveTextLabels(false),
51 m_notifier(this, 51 m_notifier(this,
52 getId(),
52 notifyOnAdd ? 53 notifyOnAdd ?
53 DeferredNotifier::NOTIFY_ALWAYS : 54 DeferredNotifier::NOTIFY_ALWAYS :
54 DeferredNotifier::NOTIFY_DEFERRED), 55 DeferredNotifier::NOTIFY_DEFERRED),
55 m_completion(100) { 56 m_completion(100) {
56 PlayParameterRepository::getInstance()->addPlayable(this); 57 PlayParameterRepository::getInstance()->addPlayable
58 (getId().untyped, this);
57 } 59 }
58 60
59 virtual ~SparseOneDimensionalModel() { 61 virtual ~SparseOneDimensionalModel() {
60 PlayParameterRepository::getInstance()->removePlayable(this); 62 PlayParameterRepository::getInstance()->removePlayable
63 (getId().untyped);
61 } 64 }
62 65
63 QString getTypeName() const override { return tr("Sparse 1-D"); } 66 QString getTypeName() const override { return tr("Sparse 1-D"); }
64 bool isSparse() const override { return true; } 67 bool isSparse() const override { return true; }
65 bool isOK() const override { return true; } 68 bool isOK() const override { return true; }
93 96
94 if (update) { 97 if (update) {
95 m_notifier.makeDeferredNotifications(); 98 m_notifier.makeDeferredNotifications();
96 } 99 }
97 100
98 emit completionChanged(); 101 emit completionChanged(getId());
99 102
100 if (completion == 100) { 103 if (completion == 100) {
101 // henceforth: 104 // henceforth:
102 m_notifier.switchMode(DeferredNotifier::NOTIFY_ALWAYS); 105 m_notifier.switchMode(DeferredNotifier::NOTIFY_ALWAYS);
103 emit modelChanged(); 106 emit modelChanged(getId());
104 } 107 }
105 } 108 }
106 109
107 /** 110 /**
108 * Query methods. 111 * Query methods.
162 165
163 void remove(Event e) override { 166 void remove(Event e) override {
164 { QMutexLocker locker(&m_mutex); 167 { QMutexLocker locker(&m_mutex);
165 m_events.remove(e); 168 m_events.remove(e);
166 } 169 }
167 emit modelChangedWithin(e.getFrame(), e.getFrame() + m_resolution); 170 emit modelChangedWithin(getId(),
171 e.getFrame(), e.getFrame() + m_resolution);
168 } 172 }
169 173
170 /** 174 /**
171 * TabularModel methods. 175 * TabularModel methods.
172 */ 176 */
237 getSampleRate()))); break; 241 getSampleRate()))); break;
238 case 1: e1 = e0.withFrame(value.toInt()); break; 242 case 1: e1 = e0.withFrame(value.toInt()); break;
239 case 2: e1 = e0.withLabel(value.toString()); break; 243 case 2: e1 = e0.withLabel(value.toString()); break;
240 } 244 }
241 245
242 ChangeEventsCommand *command = 246 auto command = new ChangeEventsCommand(getId().untyped, tr("Edit Data"));
243 new ChangeEventsCommand(this, tr("Edit Data"));
244 command->remove(e0); 247 command->remove(e0);
245 command->add(e1); 248 command->add(e1);
246 return command->finish(); 249 return command->finish();
247 } 250 }
248 251