From: Carsten Niehaus Date: Sat, 23 Sep 2006 10:06:00 +0000 (+0000) Subject: * Ok, only took me one hour to find out that my code was fine, only the XML changed... X-Git-Tag: v3.80.2~27 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=5fc2a41f0a2d14aa96d2c510e733a88fe9027467;p=libqmvoc.git * Ok, only took me one hour to find out that my code was fine, only the XML changed again... svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=587588 --- diff --git a/libscience/chemicaldataobject.cpp b/libscience/chemicaldataobject.cpp index 76f7f3a..102920d 100644 --- a/libscience/chemicaldataobject.cpp +++ b/libscience/chemicaldataobject.cpp @@ -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; } diff --git a/libscience/chemicaldataobject.h b/libscience/chemicaldataobject.h index 1e66200..bf05fb2 100644 --- a/libscience/chemicaldataobject.h +++ b/libscience/chemicaldataobject.h @@ -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 */ }; diff --git a/libscience/elementparser.cpp b/libscience/elementparser.cpp index 80e06fb..0bb45c6 100644 --- a/libscience/elementparser.cpp +++ b/libscience/elementparser.cpp @@ -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; } diff --git a/libscience/xmlreadingtest.cpp b/libscience/xmlreadingtest.cpp index 1e629e1..10c8fda 100644 --- a/libscience/xmlreadingtest.cpp +++ b/libscience/xmlreadingtest.cpp @@ -22,6 +22,7 @@ int main(int argc, char *argv[]) reader.parse(source); QList v = parser->getElements(); + std::cout << "Found " << v.count() << " elements." << std::endl; foreach( Element* e, v ){ if ( e )