changeset 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 e251c3599ea8
files layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/ImageLayer.cpp layer/ImageLayer.h layer/Layer.cpp layer/Layer.h layer/NoteLayer.cpp layer/NoteLayer.h layer/SingleColourLayer.cpp layer/SingleColourLayer.h layer/SliceLayer.cpp layer/SliceLayer.h layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/SpectrumLayer.cpp layer/SpectrumLayer.h layer/TextLayer.cpp layer/TextLayer.h layer/TimeInstantLayer.cpp layer/TimeInstantLayer.h layer/TimeRulerLayer.cpp layer/TimeRulerLayer.h layer/TimeValueLayer.cpp layer/TimeValueLayer.h layer/WaveformLayer.cpp layer/WaveformLayer.h view/Pane.cpp view/Pane.h view/View.cpp view/View.h
diffstat 30 files changed, 167 insertions(+), 151 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -23,6 +23,7 @@
 #include <QPainter>
 #include <QImage>
 #include <QRect>
+#include <QTextStream>
 
 #include <iostream>
 
@@ -779,21 +780,20 @@
     return true;
 }
 
-QString
-Colour3DPlotLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+Colour3DPlotLayer::toXml(QTextStream &stream,
+                         QString indent, QString extraAttributes) const
 {
-    QString s;
-    
-    s += QString("scale=\"%1\" "
-                 "colourScheme=\"%2\" "
-		 "normalizeColumns=\"%3\" "
-                 "normalizeVisibleArea=\"%4\"")
+    QString s = QString("scale=\"%1\" "
+                        "colourScheme=\"%2\" "
+                        "normalizeColumns=\"%3\" "
+                        "normalizeVisibleArea=\"%4\"")
 	.arg((int)m_colourScale)
         .arg(m_colourMap)
         .arg(m_normalizeColumns ? "true" : "false")
         .arg(m_normalizeVisibleArea ? "true" : "false");
 
-    return Layer::toXmlString(indent, extraAttributes + " " + s);
+    Layer::toXml(stream, indent, extraAttributes + " " + s);
 }
 
 void
--- a/layer/Colour3DPlotLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/Colour3DPlotLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -99,8 +99,8 @@
 
     virtual const Model *getSliceableModel() const { return m_model; }
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
 protected slots:
     void cacheInvalid();
--- a/layer/ImageLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/ImageLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -29,6 +29,7 @@
 #include <QMouseEvent>
 #include <QInputDialog>
 #include <QMutexLocker>
+#include <QTextStream>
 
 #include <iostream>
 #include <cmath>
@@ -944,10 +945,11 @@
     }
 }
 
-QString
-ImageLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+ImageLayer::toXml(QTextStream &stream,
+                  QString indent, QString extraAttributes) const
 {
-    return Layer::toXmlString(indent, extraAttributes);
+    Layer::toXml(stream, indent, extraAttributes);
 }
 
 void
--- a/layer/ImageLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/ImageLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -89,8 +89,8 @@
     virtual bool getValueExtents(float &min, float &max,
                                  bool &logarithmic, QString &unit) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     virtual void setLayerDormant(const View *v, bool dormant);
 
--- 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;
 }
 
--- a/layer/Layer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/Layer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -280,29 +280,30 @@
 
     /**
      * Convert the layer's data (though not those of the model it
-     * refers to) into an XML string for file output.  This class
-     * implements the basic name/type/model-id output; subclasses will
-     * typically call this superclass implementation with extra
-     * attributes describing their particular properties.
+     * refers to) into XML for file output.  This class implements the
+     * basic name/type/model-id output; subclasses will typically call
+     * this superclass implementation with extra attributes describing
+     * their particular properties.
      */
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     /**
      * Set the particular properties of a layer (those specific to the
      * subclass) from a set of XML attributes.  This is the effective
-     * inverse of the toXmlString method.
+     * inverse of the toXml method.
      */
     virtual void setProperties(const QXmlAttributes &) = 0;
 
     /**
-     * Produce an XML string containing the layer's ID and type.  This
-     * is used to refer to the layer in the display section of the SV
-     * session file, for a layer that has already been described in
-     * the data section.
+     * Produce XML containing the layer's ID and type.  This is used
+     * to refer to the layer in the display section of the SV session
+     * file, for a layer that has already been described in the data
+     * section.
      */
-    virtual QString toBriefXmlString(QString indent = "",
-                                     QString extraAttributes = "") const;
+    virtual void toBriefXml(QTextStream &stream,
+                            QString indent = "",
+                            QString extraAttributes = "") const;
 
     /**
      * Add a measurement rectangle from the given XML attributes
@@ -467,7 +468,7 @@
         double endY;
 
         bool operator<(const MeasureRect &mr) const;
-        QString toXmlString(QString indent) const;
+        void toXml(QTextStream &stream, QString indent) const;
     };
 
     class AddMeasurementRectCommand : public Command
--- a/layer/NoteLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/NoteLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -32,6 +32,7 @@
 #include <QPainter>
 #include <QPainterPath>
 #include <QMouseEvent>
+#include <QTextStream>
 
 #include <iostream>
 #include <cmath>
@@ -948,12 +949,13 @@
         (QString(darkbg ? "White" : "Black"));
 }
 
-QString
-NoteLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+NoteLayer::toXml(QTextStream &stream,
+                 QString indent, QString extraAttributes) const
 {
-    return SingleColourLayer::toXmlString(indent, extraAttributes +
-                                          QString(" verticalScale=\"%1\"")
-                                          .arg(m_verticalScale));
+    SingleColourLayer::toXml(stream, indent, extraAttributes +
+                             QString(" verticalScale=\"%1\"")
+                             .arg(m_verticalScale));
 }
 
 void
--- a/layer/NoteLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/NoteLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -92,8 +92,8 @@
 
     virtual bool getDisplayExtents(float &min, float &max) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/SingleColourLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SingleColourLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -19,6 +19,7 @@
 
 #include <iostream>
 
+#include <QTextStream>
 #include <QApplication>
 
 SingleColourLayer::ColourRefCount 
@@ -254,8 +255,9 @@
     return s;
 }
 
-QString
-SingleColourLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+SingleColourLayer::toXml(QTextStream &stream,
+                         QString indent, QString extraAttributes) const
 {
     QString s;
     
@@ -270,7 +272,7 @@
         .arg(colourSpec)
         .arg(darkbg);
 
-    return Layer::toXmlString(indent, extraAttributes + " " + s);
+    Layer::toXml(stream, indent, extraAttributes + " " + s);
 }
 
 void
--- a/layer/SingleColourLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SingleColourLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -46,8 +46,8 @@
     virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
     virtual void setProperty(const PropertyName &, int value);
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     virtual void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/SliceLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SliceLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -27,6 +27,8 @@
 
 #include <QPainter>
 #include <QPainterPath>
+#include <QTextStream>
+
 
 SliceLayer::SliceLayer() :
     m_sliceableModel(0),
@@ -870,8 +872,9 @@
         (QString(darkbg ? "Bright Blue" : "Blue"));
 }
 
-QString
-SliceLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+SliceLayer::toXml(QTextStream &stream,
+                  QString indent, QString extraAttributes) const
 {
     QString s;
     
@@ -886,7 +889,7 @@
         .arg(m_gain)
         .arg(m_normalize ? "true" : "false");
 
-    return SingleColourLayer::toXmlString(indent, extraAttributes + " " + s);
+    SingleColourLayer::toXml(stream, indent, extraAttributes + " " + s);
 }
 
 void
--- a/layer/SliceLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SliceLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -101,8 +101,8 @@
     void setNormalize(bool n);
     bool getNormalize() const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
 public slots:
     void sliceableModelReplaced(const Model *, const Model *);
--- a/layer/SpectrogramLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SpectrogramLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -35,6 +35,7 @@
 #include <QApplication>
 #include <QMessageBox>
 #include <QMouseEvent>
+#include <QTextStream>
 
 #include <iostream>
 
@@ -3133,8 +3134,9 @@
 
 }
 
-QString
-SpectrogramLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+SpectrogramLayer::toXml(QTextStream &stream,
+                        QString indent, QString extraAttributes) const
 {
     QString s;
     
@@ -3168,7 +3170,7 @@
 	.arg(m_normalizeColumns ? "true" : "false")
         .arg(m_normalizeVisibleArea ? "true" : "false");
 
-    return Layer::toXmlString(indent, extraAttributes + " " + s);
+    Layer::toXml(stream, indent, extraAttributes + " " + s);
 }
 
 void
--- a/layer/SpectrogramLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SpectrogramLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -207,8 +207,8 @@
 
     virtual bool getYScaleValue(const View *, int, float &, QString &) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/SpectrumLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SpectrumLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -24,6 +24,8 @@
 #include "base/ColourMapper.h"
 
 #include <QPainter>
+#include <QTextStream>
+
 
 SpectrumLayer::SpectrumLayer() :
     m_originModel(0),
@@ -795,17 +797,16 @@
     curve = m_biasCurve;
 }
 
-QString
-SpectrumLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+SpectrumLayer::toXml(QTextStream &stream,
+                     QString indent, QString extraAttributes) const
 {
-    QString s;
-    
-    s += QString("windowSize=\"%1\" "
-		 "windowHopLevel=\"%2\"")
+    QString s = QString("windowSize=\"%1\" "
+                        "windowHopLevel=\"%2\"")
         .arg(m_windowSize)
         .arg(m_windowHopLevel);
 
-    return SliceLayer::toXmlString(indent, extraAttributes + " " + s);
+    SliceLayer::toXml(stream, indent, extraAttributes + " " + s);
 }
 
 void
--- a/layer/SpectrumLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/SpectrumLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -91,8 +91,8 @@
     void setShowPeaks(bool);
     bool getShowPeaks() const { return m_showPeaks; }
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
 protected slots:
     void preferenceChanged(PropertyContainer::PropertyName name);
--- a/layer/TextLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TextLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -26,6 +26,7 @@
 #include <QPainter>
 #include <QMouseEvent>
 #include <QInputDialog>
+#include <QTextStream>
 
 #include <iostream>
 #include <cmath>
@@ -705,10 +706,11 @@
         (QString(darkbg ? "Bright Orange" : "Orange"));
 }
 
-QString
-TextLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+TextLayer::toXml(QTextStream &stream,
+                 QString indent, QString extraAttributes) const
 {
-    return SingleColourLayer::toXmlString(indent, extraAttributes);
+    SingleColourLayer::toXml(stream, indent, extraAttributes);
 }
 
 void
--- a/layer/TextLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TextLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -79,8 +79,8 @@
     virtual bool getValueExtents(float &min, float &max,
                                  bool &logarithmic, QString &unit) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/TimeInstantLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TimeInstantLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -28,6 +28,7 @@
 
 #include <QPainter>
 #include <QMouseEvent>
+#include <QTextStream>
 
 #include <iostream>
 #include <cmath>
@@ -727,12 +728,14 @@
         (QString(darkbg ? "Bright Purple" : "Purple"));
 }
 
-QString
-TimeInstantLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+TimeInstantLayer::toXml(QTextStream &stream,
+                        QString indent, QString extraAttributes) const
 {
-    return SingleColourLayer::toXmlString(indent, extraAttributes +
-                                          QString(" plotStyle=\"%1\"")
-                                          .arg(m_plotStyle));
+    SingleColourLayer::toXml(stream, indent,
+                             extraAttributes +
+                             QString(" plotStyle=\"%1\"")
+                             .arg(m_plotStyle));
 }
 
 void
--- a/layer/TimeInstantLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TimeInstantLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -91,8 +91,8 @@
         return false;
     }
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/TimeRulerLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TimeRulerLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -314,10 +314,11 @@
         (QString(darkbg ? "White" : "Black"));
 }
 
-QString
-TimeRulerLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+TimeRulerLayer::toXml(QTextStream &stream,
+                      QString indent, QString extraAttributes) const
 {
-    return SingleColourLayer::toXmlString(indent, extraAttributes);
+    SingleColourLayer::toXml(stream, indent, extraAttributes);
 }
 
 void
--- a/layer/TimeRulerLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TimeRulerLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -51,8 +51,8 @@
         return false;
     }
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/TimeValueLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TimeValueLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -34,6 +34,7 @@
 #include <QPainterPath>
 #include <QMouseEvent>
 #include <QRegExp>
+#include <QTextStream>
 
 #include <iostream>
 #include <cmath>
@@ -1389,14 +1390,16 @@
     return true;
 }
 
-QString
-TimeValueLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+TimeValueLayer::toXml(QTextStream &stream,
+                      QString indent, QString extraAttributes) const
 {
-    return SingleColourLayer::toXmlString(indent, extraAttributes +
-                                          QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\"")
-                                          .arg(m_colourMap)
-                                          .arg(m_plotStyle)
-                                          .arg(m_verticalScale));
+    SingleColourLayer::toXml(stream, indent,
+                             extraAttributes +
+                             QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\"")
+                             .arg(m_colourMap)
+                             .arg(m_plotStyle)
+                             .arg(m_verticalScale));
 }
 
 void
--- a/layer/TimeValueLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/TimeValueLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -114,8 +114,8 @@
 
     virtual bool getDisplayExtents(float &min, float &max) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     void setProperties(const QXmlAttributes &attributes);
 
--- a/layer/WaveformLayer.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/WaveformLayer.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -23,6 +23,7 @@
 
 #include <QPainter>
 #include <QPixmap>
+#include <QTextStream>
 
 #include <iostream>
 #include <cmath>
@@ -1248,8 +1249,9 @@
     }
 }
 
-QString
-WaveformLayer::toXmlString(QString indent, QString extraAttributes) const
+void
+WaveformLayer::toXml(QTextStream &stream,
+                     QString indent, QString extraAttributes) const
 {
     QString s;
     
@@ -1274,7 +1276,7 @@
 	.arg(m_aggressive)
         .arg(m_autoNormalize);
 
-    return SingleColourLayer::toXmlString(indent, extraAttributes + " " + s);
+    SingleColourLayer::toXml(stream, indent, extraAttributes + " " + s);
 }
 
 void
--- a/layer/WaveformLayer.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/layer/WaveformLayer.h	Thu Oct 18 10:15:07 2007 +0000
@@ -179,8 +179,8 @@
     virtual bool getYScaleDifference(const View *v, int y0, int y1,
                                      float &diff, QString &unit) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     virtual void setProperties(const QXmlAttributes &attributes);
 
--- a/view/Pane.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/view/Pane.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -30,6 +30,8 @@
 #include <QDragEnterEvent>
 #include <QDropEvent>
 #include <QCursor>
+#include <QTextStream>
+
 #include <iostream>
 #include <cmath>
 
@@ -2237,11 +2239,12 @@
     emit contextHelpChanged("");
 }
 
-QString
-Pane::toXmlString(QString indent, QString extraAttributes) const
+void
+Pane::toXml(QTextStream &stream,
+            QString indent, QString extraAttributes) const
 {
-    return View::toXmlString
-	(indent,
+    View::toXml
+        (stream, indent,
 	 QString("type=\"pane\" centreLineVisible=\"%1\" height=\"%2\" %3")
 	 .arg(m_centreLineVisible).arg(height()).arg(extraAttributes));
 }
--- a/view/Pane.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/view/Pane.h	Thu Oct 18 10:15:07 2007 +0000
@@ -58,8 +58,8 @@
     virtual QSize getImageSize(size_t f0, size_t f1);
     virtual QSize getImageSize() { return View::getImageSize(); }
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     static void registerShortcuts(KeyReference &kr);
 
--- a/view/View.cpp	Wed Oct 17 12:58:45 2007 +0000
+++ b/view/View.cpp	Thu Oct 18 10:15:07 2007 +0000
@@ -30,6 +30,7 @@
 #include <QRect>
 #include <QApplication>
 #include <QProgressDialog>
+#include <QTextStream>
 
 #include <iostream>
 #include <cassert>
@@ -2128,20 +2129,19 @@
     return QSize(x1 - x0, height());
 }
 
-QString
-View::toXmlString(QString indent, QString extraAttributes) const
+void
+View::toXml(QTextStream &stream,
+            QString indent, QString extraAttributes) const
 {
-    QString s;
+    stream << indent;
 
-    s += indent;
-
-    s += QString("<view "
-		 "centre=\"%1\" "
-		 "zoom=\"%2\" "
-		 "followPan=\"%3\" "
-		 "followZoom=\"%4\" "
-		 "tracking=\"%5\" "
-		 " %6>\n")
+    stream << QString("<view "
+                      "centre=\"%1\" "
+                      "zoom=\"%2\" "
+                      "followPan=\"%3\" "
+                      "followZoom=\"%4\" "
+                      "tracking=\"%5\" "
+                      " %6>\n")
 	.arg(m_centreFrame)
 	.arg(m_zoomLevel)
 	.arg(m_followPan)
@@ -2152,14 +2152,12 @@
 
     for (size_t i = 0; i < m_layers.size(); ++i) {
         bool visible = !m_layers[i]->isLayerDormant(this);
-	s += m_layers[i]->toBriefXmlString(indent + "  ",
-                                           QString("visible=\"%1\"")
-                                           .arg(visible ? "true" : "false"));
+        m_layers[i]->toBriefXml(stream, indent + "  ",
+                                QString("visible=\"%1\"")
+                                .arg(visible ? "true" : "false"));
     }
 
-    s += indent + "</view>\n";
-
-    return s;
+    stream << indent + "</view>\n";
 }
 
 ViewPropertyContainer::ViewPropertyContainer(View *v) :
--- a/view/View.h	Wed Oct 17 12:58:45 2007 +0000
+++ b/view/View.h	Thu Oct 18 10:15:07 2007 +0000
@@ -243,8 +243,8 @@
     virtual bool getValueExtents(QString unit, float &min, float &max,
                                  bool &log) const;
 
-    virtual QString toXmlString(QString indent = "",
-				QString extraAttributes = "") const;
+    virtual void toXml(QTextStream &stream, QString indent = "",
+                       QString extraAttributes = "") const;
 
     // First frame actually in model, to right of scale, if present
     virtual size_t getFirstVisibleFrame() const;