Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
315:c30a7cd29f4a | 316:c0b9eec70639 |
---|---|
20 | 20 |
21 #include <iostream> | 21 #include <iostream> |
22 | 22 |
23 #include <QMutexLocker> | 23 #include <QMutexLocker> |
24 #include <QMouseEvent> | 24 #include <QMouseEvent> |
25 #include <QTextStream> | |
25 | 26 |
26 #include "LayerFactory.h" | 27 #include "LayerFactory.h" |
27 #include "base/PlayParameterRepository.h" | 28 #include "base/PlayParameterRepository.h" |
28 | 29 |
29 #include <cmath> | 30 #include <cmath> |
165 } else { | 166 } else { |
166 return pixrect.y() < mr.pixrect.y(); | 167 return pixrect.y() < mr.pixrect.y(); |
167 } | 168 } |
168 } | 169 } |
169 | 170 |
170 QString | 171 void |
171 Layer::MeasureRect::toXmlString(QString indent) const | 172 Layer::MeasureRect::toXml(QTextStream &stream, QString indent) const |
172 { | 173 { |
173 QString s; | 174 stream << indent; |
174 | 175 stream << QString("<measurement "); |
175 s += indent; | |
176 s += QString("<measurement "); | |
177 | 176 |
178 if (haveFrames) { | 177 if (haveFrames) { |
179 s += QString("startFrame=\"%1\" endFrame=\"%2\" ") | 178 stream << QString("startFrame=\"%1\" endFrame=\"%2\" ") |
180 .arg(startFrame).arg(endFrame); | 179 .arg(startFrame).arg(endFrame); |
181 } else { | 180 } else { |
182 s += QString("startX=\"%1\" endX=\"%2\" ") | 181 stream << QString("startX=\"%1\" endX=\"%2\" ") |
183 .arg(pixrect.x()).arg(pixrect.x() + pixrect.width()); | 182 .arg(pixrect.x()).arg(pixrect.x() << pixrect.width()); |
184 } | 183 } |
185 | 184 |
186 s += QString("startY=\"%1\" endY=\"%2\"/>\n") | 185 stream << QString("startY=\"%1\" endY=\"%2\"/>\n") |
187 .arg(startY).arg(endY); | 186 .arg(startY).arg(endY); |
188 | |
189 return s; | |
190 } | 187 } |
191 | 188 |
192 void | 189 void |
193 Layer::addMeasurementRect(const QXmlAttributes &attributes) | 190 Layer::addMeasurementRect(const QXmlAttributes &attributes) |
194 { | 191 { |
462 } | 459 } |
463 | 460 |
464 v->drawMeasurementRect(paint, this, r.pixrect.normalized(), focus); | 461 v->drawMeasurementRect(paint, this, r.pixrect.normalized(), focus); |
465 } | 462 } |
466 | 463 |
467 QString | 464 void |
468 Layer::toXmlString(QString indent, QString extraAttributes) const | 465 Layer::toXml(QTextStream &stream, |
469 { | 466 QString indent, QString extraAttributes) const |
470 QString s; | 467 { |
471 | 468 stream << indent; |
472 s += indent; | 469 |
473 | 470 stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5") |
474 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5") | |
475 .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName | 471 .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName |
476 (LayerFactory::getInstance()->getLayerType(this)))) | 472 (LayerFactory::getInstance()->getLayerType(this)))) |
477 .arg(getObjectExportId(this)) | 473 .arg(getObjectExportId(this)) |
478 .arg(encodeEntities(objectName())) | 474 .arg(encodeEntities(objectName())) |
479 .arg(getObjectExportId(getModel())) | 475 .arg(getObjectExportId(getModel())) |
480 .arg(extraAttributes); | 476 .arg(extraAttributes); |
481 | 477 |
482 if (m_measureRects.empty()) { | 478 if (m_measureRects.empty()) { |
483 s += QString("/>\n"); | 479 stream << QString("/>\n"); |
484 return s; | 480 return; |
485 } | 481 } |
486 | 482 |
487 s += QString(">\n"); | 483 stream << QString(">\n"); |
488 | 484 |
489 for (MeasureRectSet::const_iterator i = m_measureRects.begin(); | 485 for (MeasureRectSet::const_iterator i = m_measureRects.begin(); |
490 i != m_measureRects.end(); ++i) { | 486 i != m_measureRects.end(); ++i) { |
491 s += i->toXmlString(indent + " "); | 487 i->toXml(stream, indent + " "); |
492 } | 488 } |
493 | 489 |
494 s += QString("</layer>\n"); | 490 stream << QString("</layer>\n"); |
495 | 491 } |
496 return s; | 492 |
497 } | 493 void |
498 | 494 Layer::toBriefXml(QTextStream &stream, |
499 QString | 495 QString indent, QString extraAttributes) const |
500 Layer::toBriefXmlString(QString indent, QString extraAttributes) const | 496 { |
501 { | 497 stream << indent; |
502 QString s; | 498 |
503 | 499 stream << QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") |
504 s += indent; | |
505 | |
506 s += QString("<layer id=\"%2\" type=\"%1\" name=\"%3\" model=\"%4\" %5/>\n") | |
507 .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName | 500 .arg(encodeEntities(LayerFactory::getInstance()->getLayerTypeName |
508 (LayerFactory::getInstance()->getLayerType(this)))) | 501 (LayerFactory::getInstance()->getLayerType(this)))) |
509 .arg(getObjectExportId(this)) | 502 .arg(getObjectExportId(this)) |
510 .arg(encodeEntities(objectName())) | 503 .arg(encodeEntities(objectName())) |
511 .arg(getObjectExportId(getModel())) | 504 .arg(getObjectExportId(getModel())) |
512 .arg(extraAttributes); | 505 .arg(extraAttributes); |
513 | 506 } |
514 return s; | 507 |
515 } | |
516 |