comparison data/model/SparseTimeValueModel.h @ 1655:0cfb882155a6 single-point

Fixes: completion should default to 100 (it never gets set if we aren't a transform target); events added to time-value model should be denied durations; forward the overspill and matching search functions
author Chris Cannam
date Wed, 20 Mar 2019 11:14:36 +0000
parents 7a56bb85030f
children e4084bc60fe8
comparison
equal deleted inserted replaced
1654:26aa42fd60e9 1655:0cfb882155a6
49 m_haveTextLabels(false), 49 m_haveTextLabels(false),
50 m_notifier(this, 50 m_notifier(this,
51 notifyOnAdd ? 51 notifyOnAdd ?
52 DeferredNotifier::NOTIFY_ALWAYS : 52 DeferredNotifier::NOTIFY_ALWAYS :
53 DeferredNotifier::NOTIFY_DEFERRED), 53 DeferredNotifier::NOTIFY_DEFERRED),
54 m_completion(0) { 54 m_completion(100) {
55 // Model is playable, but may not sound (if units not Hz or 55 // Model is playable, but may not sound (if units not Hz or
56 // range unsuitable) 56 // range unsuitable)
57 PlayParameterRepository::getInstance()->addPlayable(this); 57 PlayParameterRepository::getInstance()->addPlayable(this);
58 } 58 }
59 59
68 m_haveTextLabels(false), 68 m_haveTextLabels(false),
69 m_notifier(this, 69 m_notifier(this,
70 notifyOnAdd ? 70 notifyOnAdd ?
71 DeferredNotifier::NOTIFY_ALWAYS : 71 DeferredNotifier::NOTIFY_ALWAYS :
72 DeferredNotifier::NOTIFY_DEFERRED), 72 DeferredNotifier::NOTIFY_DEFERRED),
73 m_completion(0) { 73 m_completion(100) {
74 // Model is playable, but may not sound (if units not Hz or 74 // Model is playable, but may not sound (if units not Hz or
75 // range unsuitable) 75 // range unsuitable)
76 PlayParameterRepository::getInstance()->addPlayable(this); 76 PlayParameterRepository::getInstance()->addPlayable(this);
77 } 77 }
78 78
103 float getValueMaximum() const { return m_valueMaximum; } 103 float getValueMaximum() const { return m_valueMaximum; }
104 104
105 int getCompletion() const { return m_completion; } 105 int getCompletion() const { return m_completion; }
106 106
107 void setCompletion(int completion, bool update = true) { 107 void setCompletion(int completion, bool update = true) {
108 108
109 { QMutexLocker locker(&m_mutex); 109 { QMutexLocker locker(&m_mutex);
110 if (m_completion == completion) return; 110 if (m_completion == completion) return;
111 m_completion = completion; 111 m_completion = completion;
112 } 112 }
113 113
141 return m_events.getAllEvents(); 141 return m_events.getAllEvents();
142 } 142 }
143 EventVector getEventsSpanning(sv_frame_t f, sv_frame_t duration) const { 143 EventVector getEventsSpanning(sv_frame_t f, sv_frame_t duration) const {
144 return m_events.getEventsSpanning(f, duration); 144 return m_events.getEventsSpanning(f, duration);
145 } 145 }
146 EventVector getEventsWithin(sv_frame_t f, sv_frame_t duration) const { 146 EventVector getEventsWithin(sv_frame_t f, sv_frame_t duration,
147 return m_events.getEventsWithin(f, duration); 147 int overspill = 0) const {
148 return m_events.getEventsWithin(f, duration, overspill);
148 } 149 }
149 EventVector getEventsStartingWithin(sv_frame_t f, sv_frame_t duration) const { 150 EventVector getEventsStartingWithin(sv_frame_t f, sv_frame_t duration) const {
150 return m_events.getEventsStartingWithin(f, duration); 151 return m_events.getEventsStartingWithin(f, duration);
151 } 152 }
152 EventVector getEventsCovering(sv_frame_t f) const { 153 EventVector getEventsCovering(sv_frame_t f) const {
153 return m_events.getEventsCovering(f); 154 return m_events.getEventsCovering(f);
155 }
156 bool getNearestEventMatching(sv_frame_t startSearchAt,
157 std::function<bool(Event)> predicate,
158 EventSeries::Direction direction,
159 Event &found) const {
160 return m_events.getNearestEventMatching
161 (startSearchAt, predicate, direction, found);
154 } 162 }
155 163
156 /** 164 /**
157 * Editing methods. 165 * Editing methods.
158 */ 166 */
160 168
161 bool allChange = false; 169 bool allChange = false;
162 170
163 { 171 {
164 QMutexLocker locker(&m_mutex); 172 QMutexLocker locker(&m_mutex);
165 m_events.add(e); 173 m_events.add(e.withoutDuration()); // can't have duration here
166 174
167 if (e.getLabel() != "") { 175 if (e.getLabel() != "") {
168 m_haveTextLabels = true; 176 m_haveTextLabels = true;
169 } 177 }
170 178