comparison data/model/SparseModel.h @ 314:70a232b1f12a

* Make XmlExportable::toXml the function that is universally overridden (and pure virtual) instead of toXmlString. Tidies up some classes, notably the model classes, significantly. Closes #1794561.
author Chris Cannam
date Thu, 18 Oct 2007 10:15:07 +0000
parents 73537d900d4b
children 7a4bd2c8585c
comparison
equal deleted inserted replaced
313:29485aa03da4 314:70a232b1f12a
134 134
135 virtual void toXml(QTextStream &out, 135 virtual void toXml(QTextStream &out,
136 QString indent = "", 136 QString indent = "",
137 QString extraAttributes = "") const; 137 QString extraAttributes = "") const;
138 138
139 virtual QString toXmlString(QString indent = "",
140 QString extraAttributes = "") const;
141
142 virtual QString toDelimitedDataString(QString delimiter) const 139 virtual QString toDelimitedDataString(QString delimiter) const
143 { 140 {
144 QString s; 141 QString s;
145 for (PointListIterator i = m_points.begin(); i != m_points.end(); ++i) { 142 for (PointListIterator i = m_points.begin(); i != m_points.end(); ++i) {
146 s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n"; 143 s += i->toDelimitedDataString(delimiter, m_sampleRate) + "\n";
565 out << QString("<dataset id=\"%1\" dimensions=\"%2\">\n") 562 out << QString("<dataset id=\"%1\" dimensions=\"%2\">\n")
566 .arg(getObjectExportId(&m_points)) 563 .arg(getObjectExportId(&m_points))
567 .arg(PointType(0).getDimensions()); 564 .arg(PointType(0).getDimensions());
568 565
569 for (PointListIterator i = m_points.begin(); i != m_points.end(); ++i) { 566 for (PointListIterator i = m_points.begin(); i != m_points.end(); ++i) {
570 out << i->toXmlString(indent + " "); 567 i->toXml(out, indent + " ");
571 } 568 }
572 569
573 out << indent; 570 out << indent;
574 out << "</dataset>\n"; 571 out << "</dataset>\n";
575 } 572 }
576 573
577 template <typename PointType>
578 QString
579 SparseModel<PointType>::toXmlString(QString indent,
580 QString extraAttributes) const
581 {
582 QString s;
583
584 {
585 QTextStream out(&s);
586 toXml(out, indent, extraAttributes);
587 }
588
589 return s;
590 }
591
592 template <typename PointType> 574 template <typename PointType>
593 SparseModel<PointType>::EditCommand::EditCommand(SparseModel *model, 575 SparseModel<PointType>::EditCommand::EditCommand(SparseModel *model,
594 QString commandName) : 576 QString commandName) :
595 MacroCommand(commandName), 577 MacroCommand(commandName),
596 m_model(model) 578 m_model(model)