Mercurial > hg > svgui
comparison view/View.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 | c30a7cd29f4a |
children | 984c1975f1ff |
comparison
equal
deleted
inserted
replaced
315:c30a7cd29f4a | 316:c0b9eec70639 |
---|---|
28 #include <QPainter> | 28 #include <QPainter> |
29 #include <QPaintEvent> | 29 #include <QPaintEvent> |
30 #include <QRect> | 30 #include <QRect> |
31 #include <QApplication> | 31 #include <QApplication> |
32 #include <QProgressDialog> | 32 #include <QProgressDialog> |
33 #include <QTextStream> | |
33 | 34 |
34 #include <iostream> | 35 #include <iostream> |
35 #include <cassert> | 36 #include <cassert> |
36 #include <math.h> | 37 #include <math.h> |
37 | 38 |
2126 size_t x1 = f1 / getZoomLevel(); | 2127 size_t x1 = f1 / getZoomLevel(); |
2127 | 2128 |
2128 return QSize(x1 - x0, height()); | 2129 return QSize(x1 - x0, height()); |
2129 } | 2130 } |
2130 | 2131 |
2131 QString | 2132 void |
2132 View::toXmlString(QString indent, QString extraAttributes) const | 2133 View::toXml(QTextStream &stream, |
2133 { | 2134 QString indent, QString extraAttributes) const |
2134 QString s; | 2135 { |
2135 | 2136 stream << indent; |
2136 s += indent; | 2137 |
2137 | 2138 stream << QString("<view " |
2138 s += QString("<view " | 2139 "centre=\"%1\" " |
2139 "centre=\"%1\" " | 2140 "zoom=\"%2\" " |
2140 "zoom=\"%2\" " | 2141 "followPan=\"%3\" " |
2141 "followPan=\"%3\" " | 2142 "followZoom=\"%4\" " |
2142 "followZoom=\"%4\" " | 2143 "tracking=\"%5\" " |
2143 "tracking=\"%5\" " | 2144 " %6>\n") |
2144 " %6>\n") | |
2145 .arg(m_centreFrame) | 2145 .arg(m_centreFrame) |
2146 .arg(m_zoomLevel) | 2146 .arg(m_zoomLevel) |
2147 .arg(m_followPan) | 2147 .arg(m_followPan) |
2148 .arg(m_followZoom) | 2148 .arg(m_followZoom) |
2149 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : | 2149 .arg(m_followPlay == PlaybackScrollContinuous ? "scroll" : |
2150 m_followPlay == PlaybackScrollPage ? "page" : "ignore") | 2150 m_followPlay == PlaybackScrollPage ? "page" : "ignore") |
2151 .arg(extraAttributes); | 2151 .arg(extraAttributes); |
2152 | 2152 |
2153 for (size_t i = 0; i < m_layers.size(); ++i) { | 2153 for (size_t i = 0; i < m_layers.size(); ++i) { |
2154 bool visible = !m_layers[i]->isLayerDormant(this); | 2154 bool visible = !m_layers[i]->isLayerDormant(this); |
2155 s += m_layers[i]->toBriefXmlString(indent + " ", | 2155 m_layers[i]->toBriefXml(stream, indent + " ", |
2156 QString("visible=\"%1\"") | 2156 QString("visible=\"%1\"") |
2157 .arg(visible ? "true" : "false")); | 2157 .arg(visible ? "true" : "false")); |
2158 } | 2158 } |
2159 | 2159 |
2160 s += indent + "</view>\n"; | 2160 stream << indent + "</view>\n"; |
2161 | |
2162 return s; | |
2163 } | 2161 } |
2164 | 2162 |
2165 ViewPropertyContainer::ViewPropertyContainer(View *v) : | 2163 ViewPropertyContainer::ViewPropertyContainer(View *v) : |
2166 m_v(v) | 2164 m_v(v) |
2167 { | 2165 { |