]> Git trees. - libqmvoc.git/commitdiff
Yeah, found the bugs :) Everything back to normal
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 3 Sep 2006 11:30:52 +0000 (11:30 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 3 Sep 2006 11:30:52 +0000 (11:30 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=580371

libscience/elementparser.cpp
libscience/xmlreadingtest.cpp

index b9230a4984e236d31993746e2cef74a455b5455b..eb07bf51cfdf2865904adae4e3c7ddd217a1949e 100644 (file)
@@ -177,6 +177,9 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co
                     if (attrs.localName(i) == "value") {
                         d->currentDataObject->setData( attrs.value(i) );
                         d->currentDataObject->setType( ChemicalDataObject::symbol );
+                        
+                        if ( d->currentElement )
+                            d->currentElement->addData( d->currentDataObject );
                     }
                 }
             }
@@ -186,6 +189,9 @@ bool ElementSaxParser::startElement(const QString&, const QString &localName, co
                     if (attrs.localName(i) == "value") {
                         d->currentDataObject->setData( attrs.value(i) );
                         d->currentDataObject->setType( ChemicalDataObject::name );
+    
+                        if ( d->currentElement )
+                            d->currentElement->addData( d->currentDataObject );
                     }
                 }
             }
@@ -199,17 +205,7 @@ bool ElementSaxParser::endElement( const QString &, const QString& localName, co
     if ( localName == "atom" )
     {
         if ( d->currentElement->dataAsString( ChemicalDataObject::symbol ) != "Xx" )
-        {
             d->elements.append(d->currentElement);
-            
-            QList<ChemicalDataObject*> list = d->currentElement->data();
-            foreach( ChemicalDataObject*o, list )
-            {
-                if ( o ) { 
-                    kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString() << endl;
-                }
-            }
-        }
 
         d->currentElement = 0;
         d->currentDataObject = 0;
index e7ae096a19eece9dac17e3e040be635a6ed1e162..1e629e1d6fce234baafce4bf05db2b5e8902d1c9 100644 (file)
@@ -14,11 +14,6 @@ int main(int argc, char *argv[])
 
     ElementSaxParser * parser = new ElementSaxParser();
     QFile xmlFile(argv[1]);
-    
-    if (xmlFile.exists())
-        kDebug() << "file exists" << endl;
-    else
-        kDebug() << "file DOES NOT exist" << endl;
 
     QXmlInputSource source(&xmlFile);
     QXmlSimpleReader reader;
@@ -28,24 +23,24 @@ int main(int argc, char *argv[])
 
     QList<Element*> v = parser->getElements();
 
-//X     foreach( Element* e, v ){
-//X         if ( e )
-//X         {
-//X             QList<ChemicalDataObject*> list = e->data();
-//X 
-//X             //Test: give me all data available
-//X             foreach( ChemicalDataObject*o, list ){
-//X                 if ( o )
-//X                 {
-//X                     QString unit = o->unitAsString();
-//X                     if ( unit == "bo:noUnit" )
-//X                         unit = "";
-//X                     kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  <<" "  << unit << endl;
-//X                 }
-//X             }
-//X         }
-//X 
-//X     }
+    foreach( Element* e, v ){
+        if ( e )
+        {
+            QList<ChemicalDataObject*> list = e->data();
+
+            //Test: give me all data available
+            foreach( ChemicalDataObject*o, list ){
+                if ( o )
+                {
+                    QString unit = o->unitAsString();
+                    if ( unit == "bo:noUnit" )
+                        unit = "";
+                    kDebug() << "Name: " << o->dictRef() << " " << o->valueAsString()  <<" "  << unit << endl;
+                }
+            }
+        }
+
+    }
 
     return 0;
 }