]> Git trees. - libqmvoc.git/commitdiff
* Ok, only took me one hour to find out that my code was fine, only the XML changed...
authorCarsten Niehaus <cniehaus@gmx.de>
Sat, 23 Sep 2006 10:06:00 +0000 (10:06 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sat, 23 Sep 2006 10:06:00 +0000 (10:06 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=587588

libscience/chemicaldataobject.cpp
libscience/chemicaldataobject.h
libscience/elementparser.cpp
libscience/xmlreadingtest.cpp

index 76f7f3ac24ced21a579d4cfe0be088ad576d23a1..102920d5e2094edf0daae94b673cc4f12c8b4b91 100644 (file)
@@ -275,20 +275,14 @@ QString ChemicalDataObject::unitAsString() const
 
 ChemicalDataObject::BlueObeliskUnit ChemicalDataObject::unit( const QString& unit )
 {
-       if ( unit == "bo:kelvin" ) 
-               return ChemicalDataObject::kelvin;
-       else if ( unit == "bo:ev" )
-               return ChemicalDataObject::ev;
-       else if ( unit == "bo:nm" )
-               return ChemicalDataObject::nm;
-       else if ( unit == "bo:pm" )
-               return ChemicalDataObject::pm;
-       else if ( unit == "bo:y" )
-               return ChemicalDataObject::y;   
-       else if ( unit == "bo:s" )
-               return ChemicalDataObject::s;   
-       else if ( unit == "bo:noUnit" )
-               return ChemicalDataObject::noUnit;
-       else
-               return ChemicalDataObject::noUnit;
+    if ( unit == "siUnits:kelvin" ) 
+        return ChemicalDataObject::kelvin;
+    else if ( unit == "units:ev" )
+        return ChemicalDataObject::ev;
+    else if ( unit == "units:ang" )
+        return ChemicalDataObject::ang;
+    else if ( unit == "bo:noUnit" )
+        return ChemicalDataObject::noUnit;
+    else
+        return ChemicalDataObject::noUnit;
 }
index 1e66200246b66854afc621d775cf0fbc90215f64..bf05fb282d29ef8069362b6fad85b78fb831f858 100644 (file)
@@ -88,10 +88,6 @@ class EDUSCIENCE_EXPORT ChemicalDataObject
       discoveryCountry
                };
 
-               /**
-                * The BlueObelisk-project defines in their XML file the dataset
-                * with the units in the namespace "bo". 
-                */
                enum BlueObeliskUnit
                {
                        kelvin = 0/**< Degree Kelvin */,
@@ -100,6 +96,7 @@ class EDUSCIENCE_EXPORT ChemicalDataObject
                        pm/**< picometer */,
                        y/**< years */,
                        s/**< seconds */,
+      ang/**< angstrom */,
                        noUnit/**< no unit */
                };
 
index 80e06fbdf97b7d197328611e37f99367d345e079..0bb45c641b8b55d7db3d0cd77f67fe52c4dd8954 100644 (file)
@@ -111,9 +111,11 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co
     {
         for (int i = 0; i < attrs.length(); ++i) 
         {
-            if ( attrs.localName( i ) == "unit" )
+            if ( attrs.localName( i ) == "units" )
             {
+                //kDebug() << "value of the unit: " << attrs.value(i) << endl;
                 d->currentUnit = ChemicalDataObject::unit( attrs.value( i ) );
+                //kDebug() << "Took " << d->currentUnit << endl;
                 continue;
             }
 
@@ -217,10 +219,8 @@ bool ElementSaxParser::endElement( const QString &, const QString& localName, co
     }
     else if ( localName == "scalar" || localName == "label" || localName == "array" )
     {
-        if ( d->currentUnit != ChemicalDataObject::noUnit )
-            d->currentDataObject->setUnit( d->currentUnit );
-
-        d->currentUnit = ChemicalDataObject::noUnit;
+        //kDebug() << "Check unit " << d->currentUnit << endl;
+        d->currentDataObject->setUnit( d->currentUnit );
     }
     return true;
 }
index 1e629e1d6fce234baafce4bf05db2b5e8902d1c9..10c8fda70e359199bd74fd33edc6d484aacec851 100644 (file)
@@ -22,6 +22,7 @@ int main(int argc, char *argv[])
     reader.parse(source);
 
     QList<Element*> v = parser->getElements();
+    std::cout << "Found " << v.count() << " elements." << std::endl;
 
     foreach( Element* e, v ){
         if ( e )