Mercurial > hg > svgui
diff layer/Layer.cpp @ 316:c0b9eec70639
* 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 | 86a112b5b319 |
children | 984c1975f1ff |
line wrap: on
line diff
--- a/layer/Layer.cpp Wed Oct 17 12:58:45 2007 +0000 +++ b/layer/Layer.cpp Thu Oct 18 10:15:07 2007 +0000 @@ -22,6 +22,7 @@ #include <QMutexLocker> #include <QMouseEvent> +#include <QTextStream> #include "LayerFactory.h" #include "base/PlayParameterRepository.h" @@ -167,26 +168,22 @@ } } -QString -Layer::MeasureRect::toXmlString(QString indent) const +void +Layer::MeasureRect::toXml(QTextStream &stream, QString indent) const { - QString s; - - s += indent; - s += QString("<measurement "); + stream << indent; + stream << QString("<measurement "); if (haveFrames) { - s += QString("startFrame=\"%1\" endFrame=\"%2\" ") + stream << QString("startFrame=\"%1\" endFrame=\"%2\" ") .arg(startFrame).arg(endFrame); } else { - s += QString("startX=\"%1\" endX=\"%2\" ") - .arg(pixrect.x()).arg(pixrect.x() + pixrect.width()); + stream << QString("startX=\"%1\" endX=\"%2\" ") + .arg(pixrect.x()).arg(pixrect.x() << pixrect.width()); } - s += QString("startY=\"%1\" endY=\"%2\"/>\n") + stream << QString("startY=\"%1\" endY=\"%2\"/>\n") .arg(startY).arg(endY); - - return s; } void @@ -464,14 +461,13 @@ v->drawMeasurementRect(paint, this, r.pixrect.normalized(), focus); } -QString -Layer::toXmlString(QString indent, QString extraAttributes) const +void +Layer::toXml(QTextStream &stream, + QString indent, QString extraAttributes) const { - QString s; - - s += indent; + stream << indent; - s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5") + stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5") .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName (LayerFactory::getInstance()->getLayerType(this)))) .arg(getObjectExportId(this)) @@ -480,37 +476,32 @@ .arg(extraAttributes); if (m_measureRects.empty()) { - s += QString("/>\n"); - return s; + stream << QString("/>\n"); + return; } - s += QString(">\n"); + stream << QString(">\n"); for (MeasureRectSet::const_iterator i = m_measureRects.begin(); i != m_measureRects.end(); ++i) { - s += i->toXmlString(indent + " "); + i->toXml(stream, indent + " "); } - s += QString("</layer>\n"); - - return s; + stream << QString("</layer>\n"); } -QString -Layer::toBriefXmlString(QString indent, QString extraAttributes) const +void +Layer::toBriefXml(QTextStream &stream, + QString indent, QString extraAttributes) const { - QString s; - - s += indent; + stream << indent; - s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") + stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName (LayerFactory::getInstance()->getLayerType(this)))) .arg(getObjectExportId(this)) .arg(encodeEntities(objectName())) .arg(getObjectExportId(getModel())) .arg(extraAttributes); - - return s; }