[Kst] branches/work/kst/portto4/kst/src

Adam Treat treat at kde.org
Wed Jul 18 21:39:08 CEST 2007


SVN commit 689647 by treat:

* Sync loading with saving of equations.


 M  +4 -3      libkst/kstsvector.cpp  
 M  +13 -5     libkstmath/equationfactory.cpp  


--- branches/work/kst/portto4/kst/src/libkst/kstsvector.cpp #689646:689647
@@ -19,15 +19,16 @@
 #include <qtextstream.h>
 #include <QXmlStreamWriter>
 
-KstSVector::KstSVector(const QString &tag, const QByteArray &data, double x0, double x1, int n) : KstVector(tag, data) {
+KstSVector::KstSVector(const QString &tag, const QByteArray &data, double x0, double x1, int n)
+  : KstVector(tag, data) {
   _saveable = true;
   _saveData = false;
   changeRange( x0,  x1,  n );
 }
 
 
-KstSVector::KstSVector(double x0, double x1, int n, KstObjectTag tag) :
-    KstVector(tag, n) {
+KstSVector::KstSVector(double x0, double x1, int n, KstObjectTag tag)
+  : KstVector(tag, n) {
   _saveable = true;
   _saveData = false;
   changeRange( x0, x1, n );
--- branches/work/kst/portto4/kst/src/libkstmath/equationfactory.cpp #689646:689647
@@ -28,7 +28,7 @@
 
 
 KstDataObjectPtr EquationFactory::generateObject(QXmlStreamReader& xml) {
-  QString eq, name, xVector, output;
+  QString tag, expression, xVector, output;
   bool interpolate = false;
 
   while (!xml.atEnd()) {
@@ -36,7 +36,8 @@
     if (xml.isStartElement()) {
       if (n == "equation") {
         QXmlStreamAttributes attrs = xml.attributes();
-        name = attrs.value("name").toString();
+        tag = attrs.value("tag").toString();
+        expression = attrs.value("expression").toString();
         interpolate = attrs.value("interpolate").toString().toLower() == "true";
         xVector = attrs.value("xvector").toString();
         output = attrs.value("output").toString();
@@ -61,10 +62,17 @@
     return 0;
   }
 
-  //FIXME verify this works when we get real vectors loading
-  KstVectorPtr vector = KST::vectorList.retrieveObject(QStringList(xVector));
+  KstVectorPtr vector = 0;
+  if (!xVector.isEmpty()) {
+    vector = *KST::vectorList.findTag(xVector);
+  }
 
-  KstEquationPtr ep = new KstEquation(name, eq, vector, interpolate);
+  if (!vector) {
+    KstDebug::self()->log(QObject::tr("Error creating equation from Kst file.  Could not find xVector."), KstDebug::Warning);
+    return 0;
+  }
+
+  KstEquationPtr ep = new KstEquation(tag, expression, vector, interpolate);
   return ep.data();
 }
 


More information about the Kst mailing list