Mercurial > hg > svcore
comparison data/model/Model.h @ 319:3ff8f571da09
* Hoist alignment model set/query up to Model, so any models can be aligned
* Add Model::aboutToDelete and aboutToBeDeleted for management of models that
are contained by or referred to by other models instead of only the document
author | Chris Cannam |
---|---|
date | Wed, 24 Oct 2007 15:21:38 +0000 |
parents | 70a232b1f12a |
children | 1afaf98dbf11 |
comparison
equal
deleted
inserted
replaced
318:7a4bd2c8585c | 319:3ff8f571da09 |
---|---|
22 #include "base/XmlExportable.h" | 22 #include "base/XmlExportable.h" |
23 | 23 |
24 typedef std::vector<float> SampleBlock; | 24 typedef std::vector<float> SampleBlock; |
25 | 25 |
26 class ZoomConstraint; | 26 class ZoomConstraint; |
27 class AlignmentModel; | |
27 | 28 |
28 /** | 29 /** |
29 * Model is the base class for all data models that represent any sort | 30 * Model is the base class for all data models that represent any sort |
30 * of data on a time scale based on an audio frame rate. | 31 * of data on a time scale based on an audio frame rate. |
31 */ | 32 */ |
112 | 113 |
113 /** | 114 /** |
114 * If this model was derived from another, return the model it was | 115 * If this model was derived from another, return the model it was |
115 * derived from. The assumption is that the source model's | 116 * derived from. The assumption is that the source model's |
116 * alignment will also apply to this model, unless some other | 117 * alignment will also apply to this model, unless some other |
117 * property indicates otherwise. | 118 * property (such as a specific alignment model set on this model) |
119 * indicates otherwise. | |
118 */ | 120 */ |
119 virtual Model *getSourceModel() const { | 121 virtual Model *getSourceModel() const { |
120 return m_sourceModel; | 122 return m_sourceModel; |
121 } | 123 } |
122 | 124 |
123 /** | 125 /** |
124 * Set the source model for this model. | 126 * Set the source model for this model. |
125 */ | 127 */ |
126 //!!! No way to handle source model deletion &c yet | 128 virtual void setSourceModel(Model *model); |
127 virtual void setSourceModel(Model *model) { | 129 |
128 m_sourceModel = model; | 130 /** |
129 } | 131 * Specify an aligment between this model's timeline and that of a |
132 * reference model. The alignment model records both the | |
133 * reference and the alignment. This model takes ownership of the | |
134 * alignment model. | |
135 */ | |
136 virtual void setAlignment(AlignmentModel *alignment); | |
137 | |
138 /** | |
139 * Return the reference model for the current alignment timeline, | |
140 * if any. | |
141 */ | |
142 virtual const Model *getAlignmentReference() const; | |
143 | |
144 /** | |
145 * Return the frame number of the reference model that corresponds | |
146 * to the given frame number in this model. | |
147 */ | |
148 virtual size_t alignToReference(size_t frame) const; | |
149 | |
150 /** | |
151 * Return the frame number in this model that corresponds to the | |
152 * given frame number of the reference model. | |
153 */ | |
154 virtual size_t alignFromReference(size_t referenceFrame) const; | |
155 | |
156 /** | |
157 * Return the completion percentage for the alignment model: 100 | |
158 * if there is no alignment model or it has been entirely | |
159 * calculated, or less than 100 if it is still being calculated. | |
160 */ | |
161 virtual int getAlignmentCompletion() const; | |
130 | 162 |
131 virtual void toXml(QTextStream &stream, | 163 virtual void toXml(QTextStream &stream, |
132 QString indent = "", | 164 QString indent = "", |
133 QString extraAttributes = "") const; | 165 QString extraAttributes = "") const; |
134 | 166 |
135 virtual QString toDelimitedDataString(QString) const { return ""; } | 167 virtual QString toDelimitedDataString(QString) const { return ""; } |
168 | |
169 public slots: | |
170 void aboutToDelete(); | |
171 void sourceModelAboutToBeDeleted(); | |
136 | 172 |
137 signals: | 173 signals: |
138 /** | 174 /** |
139 * Emitted when a model has been edited (or more data retrieved | 175 * Emitted when a model has been edited (or more data retrieved |
140 * from cache, in the case of a cached model that generates slowly) | 176 * from cache, in the case of a cached model that generates slowly) |
153 * updating any progress meters or other monitoring, but not | 189 * updating any progress meters or other monitoring, but not |
154 * refreshing the actual view. | 190 * refreshing the actual view. |
155 */ | 191 */ |
156 void completionChanged(); | 192 void completionChanged(); |
157 | 193 |
194 /** | |
195 * Emitted when the completion percentage changes for the | |
196 * calculation of this model's alignment model. | |
197 */ | |
198 void alignmentCompletionChanged(); | |
199 | |
200 /** | |
201 * Emitted when something notifies this model (through calling | |
202 * aboutToDelete() that it is about to delete it. Note that this | |
203 * depends on an external agent such as a Document object or | |
204 * owning model telling the model that it is about to delete it; | |
205 * there is nothing in the model to guarantee that this signal | |
206 * will be emitted before the actual deletion. | |
207 */ | |
208 void aboutToBeDeleted(); | |
209 | |
158 protected: | 210 protected: |
159 Model() : m_sourceModel(0) { } | 211 Model() : m_sourceModel(0), m_alignment(0), m_aboutToDelete(false) { } |
160 | 212 |
161 // Not provided. | 213 // Not provided. |
162 Model(const Model &); | 214 Model(const Model &); |
163 Model &operator=(const Model &); | 215 Model &operator=(const Model &); |
164 | 216 |
165 Model *m_sourceModel; | 217 Model *m_sourceModel; |
218 AlignmentModel *m_alignment; | |
219 bool m_aboutToDelete; | |
166 }; | 220 }; |
167 | 221 |
168 #endif | 222 #endif |