Mercurial > hg > svcore
comparison data/model/DeferredNotifier.h @ 1766:85b9b466a59f
Merge from branch by-id
author | Chris Cannam |
---|---|
date | Wed, 17 Jul 2019 14:24:51 +0100 |
parents | 6d09d68165a4 |
children |
comparison
equal
deleted
inserted
replaced
1730:649ac57c5a2d | 1766:85b9b466a59f |
---|---|
28 enum Mode { | 28 enum Mode { |
29 NOTIFY_ALWAYS, | 29 NOTIFY_ALWAYS, |
30 NOTIFY_DEFERRED | 30 NOTIFY_DEFERRED |
31 }; | 31 }; |
32 | 32 |
33 DeferredNotifier(Model *m, Mode mode) : m_model(m), m_mode(mode) { } | 33 DeferredNotifier(Model *m, ModelId id, Mode mode) : |
34 m_model(m), m_modelId(id), m_mode(mode) { } | |
34 | 35 |
35 Mode getMode() const { | 36 Mode getMode() const { |
36 return m_mode; | 37 return m_mode; |
37 } | 38 } |
38 void switchMode(Mode newMode) { | 39 void switchMode(Mode newMode) { |
39 m_mode = newMode; | 40 m_mode = newMode; |
40 } | 41 } |
41 | 42 |
42 void update(sv_frame_t frame, sv_frame_t duration) { | 43 void update(sv_frame_t frame, sv_frame_t duration) { |
43 if (m_mode == NOTIFY_ALWAYS) { | 44 if (m_mode == NOTIFY_ALWAYS) { |
44 m_model->modelChangedWithin(frame, frame + duration); | 45 m_model->modelChangedWithin(m_modelId, frame, frame + duration); |
45 } else { | 46 } else { |
46 QMutexLocker locker(&m_mutex); | 47 QMutexLocker locker(&m_mutex); |
47 m_extents.sample(frame); | 48 m_extents.sample(frame); |
48 m_extents.sample(frame + duration); | 49 m_extents.sample(frame + duration); |
49 } | 50 } |
58 from = m_extents.getMin(); | 59 from = m_extents.getMin(); |
59 to = m_extents.getMax(); | 60 to = m_extents.getMax(); |
60 } | 61 } |
61 } | 62 } |
62 if (shouldEmit) { | 63 if (shouldEmit) { |
63 m_model->modelChangedWithin(from, to); | 64 m_model->modelChangedWithin(m_modelId, from, to); |
64 QMutexLocker locker(&m_mutex); | 65 QMutexLocker locker(&m_mutex); |
65 m_extents.reset(); | 66 m_extents.reset(); |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 private: | 70 private: |
70 Model *m_model; | 71 Model *m_model; |
72 ModelId m_modelId; | |
71 Mode m_mode; | 73 Mode m_mode; |
72 QMutex m_mutex; | 74 QMutex m_mutex; |
73 Extents<sv_frame_t> m_extents; | 75 Extents<sv_frame_t> m_extents; |
74 }; | 76 }; |
75 | 77 |