diff layer/WaveformLayer.cpp @ 11:2d5005f2b3d9

* Rework handling of layer properties in file I/O -- we now get the individual layers to load and save them rather than doing it via generic property lists in the base class, so as to ensure we read and write meaningful values rather than generic int values requiring conversion.
author Chris Cannam
date Thu, 19 Jan 2006 12:54:38 +0000
parents 8f5b812baaee
children 01849cd277e6
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp	Tue Jan 17 17:45:55 2006 +0000
+++ b/layer/WaveformLayer.cpp	Thu Jan 19 12:54:38 2006 +0000
@@ -768,6 +768,46 @@
     return Layer::toXmlString(indent, extraAttributes + " " + s);
 }
 
+void
+WaveformLayer::setProperties(const QXmlAttributes &attributes)
+{
+    bool ok = false;
+
+    float gain = attributes.value("gain").toFloat(&ok);
+    if (ok) setGain(gain);
+
+    QString colourSpec = attributes.value("colour");
+    if (colourSpec != "") {
+	QColor colour(colourSpec);
+	if (colour.isValid()) {
+	    setBaseColour(QColor(colourSpec));
+	}
+    }
+
+    bool showMeans = (attributes.value("showMeans") == "1" ||
+		      attributes.value("showMeans") == "true");
+    setShowMeans(showMeans);
+
+    bool greyscale = (attributes.value("greyscale") == "1" ||
+		      attributes.value("greyscale") == "true");
+    setUseGreyscale(greyscale);
+
+    ChannelMode channelMode = (ChannelMode)
+	attributes.value("channelMode").toInt(&ok);
+    if (ok) setChannelMode(channelMode);
+
+    int channel = attributes.value("channel").toInt(&ok);
+    if (ok) setChannel(channel);
+
+    Scale scale = (Scale)
+	attributes.value("scale").toInt(&ok);
+    if (ok) setScale(scale);
+
+    bool aggressive = (attributes.value("aggressive") == "1" ||
+		       attributes.value("aggressive") == "true");
+    setUseGreyscale(aggressive);
+}
+
 #ifdef INCLUDE_MOCFILES
 #include "WaveformLayer.moc.cpp"
 #endif