comparison base/Event.h @ 1674:69ab62d378bf osc-script

Ensure image & text models get the proper attribute names (which are not the same as the default event ones)
author Chris Cannam
date Wed, 27 Mar 2019 16:06:35 +0000
parents a77a7e8c085c
children 4ca784e5033e
comparison
equal deleted inserted replaced
1673:dfcd05e8bd2f 1674:69ab62d378bf
254 return m_label < p.m_label; 254 return m_label < p.m_label;
255 } 255 }
256 return m_uri < p.m_uri; 256 return m_uri < p.m_uri;
257 } 257 }
258 258
259 struct ExportNameOptions {
260
261 ExportNameOptions() :
262 valueAtttributeName("value"),
263 uriAttributeName("uri") { }
264
265 QString valueAtttributeName;
266 QString uriAttributeName;
267 };
268
259 void toXml(QTextStream &stream, 269 void toXml(QTextStream &stream,
260 QString indent = "", 270 QString indent = "",
261 QString extraAttributes = "") const { 271 QString extraAttributes = "",
272 ExportNameOptions opts = ExportNameOptions()) const {
262 273
263 // For I/O purposes these are points, not events 274 // For I/O purposes these are points, not events
264 stream << indent << QString("<point frame=\"%1\" ").arg(m_frame); 275 stream << indent << QString("<point frame=\"%1\" ").arg(m_frame);
265 if (m_haveValue) stream << QString("value=\"%1\" ").arg(m_value); 276 if (m_haveValue) {
266 if (m_haveDuration) stream << QString("duration=\"%1\" ").arg(m_duration); 277 stream << QString("%1=\"%2\" ")
267 if (m_haveLevel) stream << QString("level=\"%1\" ").arg(m_level); 278 .arg(opts.valueAtttributeName).arg(m_value);
268 if (m_haveReferenceFrame) stream << QString("referenceFrame=\"%1\" ") 279 }
269 .arg(m_referenceFrame); 280 if (m_haveDuration) {
270 stream << QString("label=\"%1\" ") 281 stream << QString("duration=\"%1\" ").arg(m_duration);
271 .arg(XmlExportable::encodeEntities(m_label)); 282 }
283 if (m_haveLevel) {
284 stream << QString("level=\"%1\" ").arg(m_level);
285 }
286 if (m_haveReferenceFrame) {
287 stream << QString("referenceFrame=\"%1\" ")
288 .arg(m_referenceFrame);
289 }
290 if (m_label != "") {
291 stream << QString("label=\"%1\" ")
292 .arg(XmlExportable::encodeEntities(m_label));
293 }
272 if (m_uri != QString()) { 294 if (m_uri != QString()) {
273 stream << QString("uri=\"%1\" ") 295 stream << QString("%1=\"%2\" ")
296 .arg(opts.uriAttributeName)
274 .arg(XmlExportable::encodeEntities(m_uri)); 297 .arg(XmlExportable::encodeEntities(m_uri));
275 } 298 }
276 stream << extraAttributes << "/>\n"; 299 stream << extraAttributes << "/>\n";
277 } 300 }
278 301