]> Git trees. - libqmvoc.git/commitdiff
* Ok, before I go crazy: The parser is now reading the first isotopeList... Why the...
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 19 Feb 2006 15:56:09 +0000 (15:56 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 19 Feb 2006 15:56:09 +0000 (15:56 +0000)
  he never entering the second or third or n-1 isotopeList?!?!?

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=511348

libscience/isotopeparser.cpp

index c7eb0863fcab7cdb3523ecf61324fcc7a9fc7172..286a3d13376c956f8c990c5ff8b81c501b467bf7 100644 (file)
@@ -27,6 +27,7 @@ public:
        currentElementSymbol(QString()),
        currentIsotope(0),
        inIsotope(false),
+       inElement(false),
        inAtomicNumber(false),
        inExactMass(false),
        inSpin(false),
@@ -53,6 +54,7 @@ public:
        QList<Isotope*> isotopes;
        
        bool inIsotope;
+       bool inElement;
        bool inAtomicNumber;
        bool inExactMass;
        bool inSpin;
@@ -81,41 +83,49 @@ IsotopeParser::~IsotopeParser()
 
 bool IsotopeParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
 {
-       if (localName == "isotope") 
+       kDebug() << "IsotopeParser::startElement(), localName " << localName << endl;
+       if (localName == "isotopeList") 
        {
-               d->currentIsotope = new Isotope();
-               d->inIsotope = true;
+               kDebug() << "setting inElement true! ========================== NEW ELEMENT ========= " << endl;
+               d->inElement = true;
                
                //now save the symbol of the current element
                for (int i = 0; i < attrs.length(); ++i) 
                {
-                       if ( attrs.localName( i ) == "elementType" )
+                       if ( attrs.localName( i ) == "id" )
                                d->currentElementSymbol = attrs.value( i );
+
+                       kDebug() << "Symbol of the current Element: " << attrs.value( i ) << endl;
                }
+       } else if ( d->inElement && localName == "isotope") 
+       {
+               kDebug() << "setting inIsotope true!" << endl;
+               d->currentIsotope = new Isotope();
+               d->inIsotope = true;
        } else if (d->inIsotope && localName == "bo:spin") {
-               kDebug() << "bo:spin" << endl;
+//X            kDebug() << "bo:spin" << endl;
                d->inSpin = true;
        } else if (d->inIsotope && localName == "bo:magneticMoment") {
-               kDebug() << "bo:magneticMoment" << endl;
+//X            kDebug() << "bo:magneticMoment" << endl;
                d->inMagMoment = true;
        } else if (d->inIsotope && localName == "bo:halfLife") {
-               kDebug() << "bo:halfLife" << endl;
+//X            kDebug() << "bo:halfLife" << endl;
                d->inHalfLife = true;
                if ( d->currentUnit != ChemicalDataObject::noUnit )
                        d->currentDataObject->setUnit( d->currentUnit );
 
                d->currentUnit = ChemicalDataObject::noUnit;
        } else if (d->inIsotope && localName == "bo:alphaDecay"){
-               kDebug() << "bo:alphaDecay" << endl;
+//X            kDebug() << "bo:alphaDecay" << endl;
                d->inAlphaDecay = true;
        } else if (d->inIsotope && localName == "bo:betaplusDecay"){
-               kDebug() << "bo:betaplusDecay" << endl;
+//X            kDebug() << "bo:betaplusDecay" << endl;
                d->inBetaplusDecay = true;
        } else if (d->inIsotope && localName == "bo:betaminusDecay"){
-               kDebug() << "bo:betaminusDecay" << endl;
+//X            kDebug() << "bo:betaminusDecay" << endl;
                d->inBetaminusDecay = true;
        } else if (d->inIsotope && localName == "bo:ecDecay"){
-               kDebug() << "bo:ecDecay" << endl;
+//X            kDebug() << "bo:ecDecay" << endl;
                d->inECDecay = true;
        } else if (d->inIsotope && localName == "scalar")
        {
@@ -133,9 +143,9 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const
                                d->inExactMass = true;
                }
        } else if (d->inIsotope && localName == "bo:relativeAbundance") {
-               kDebug() << "bo:relativeAbundance" << endl;
+//X            kDebug() << "bo:relativeAbundance" << endl;
                d->inAbundance = true;
-       }
+       }       
        return true;
 }
 
@@ -156,6 +166,11 @@ bool IsotopeParser::endElement( const QString&, const QString& localName, const
                        d->currentDataObject->setErrorValue( d->currentErrorValue );
                }
        }
+       else if ( localName == "isotopeList" )
+       {//a new list of isotopes start...
+               kDebug() << "setting d->inElement FALSE" << endl;
+               d->inElement = false;
+       }
 
        return true;
 }