]> Git trees. - libqmvoc.git/commitdiff
Add support for the elementsymbol
authorCarsten Niehaus <cniehaus@gmx.de>
Mon, 24 Oct 2005 13:14:21 +0000 (13:14 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Mon, 24 Oct 2005 13:14:21 +0000 (13:14 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=473682

libscience/isotope.cpp
libscience/isotope.h
libscience/isotopeparser.cpp
libscience/isotopeparser.h

index b55b54c3ba6fd7a61b019c3a8c7a72fe000cb980..8c3badfecaeaff3ef821bd1098498e53d71d04f9 100644 (file)
@@ -72,3 +72,8 @@ QString Isotope::parentElementSymbol() const
 {
        return m_parentElementSymbol;
 }
+
+void Isotope::setParentSymbol( const QString& symbol )
+{
+       m_parentElementSymbol = symbol;
+}
index 07a7e1a34915485f0b4dfb01a5b6838254fc20ba..6396bc7d764915185157ccf5ef45b483c06f11cb 100644 (file)
@@ -48,6 +48,8 @@ class Isotope
 
                void addData( ChemicalDataObject* o );
 
+               void setParentSymbol( const QString& symbol );
+
        private:
                /**
                 * the symbol of the element the isotope belongs to
index 0aae9d36af2d527c3a72db5acc98a39c9528d4ae..50a25e6f5892a0382d7c3351b3017ec7fdf61273 100644 (file)
@@ -26,6 +26,7 @@ IsotopeParser::IsotopeParser()
        inAtomicNumber_(false),
        inExactMass_(false)
 {
+       currentElementSymbol_ = "";
 }
 
 bool IsotopeParser::startElement(const QString&, const QString &localName, const QString&, const QXmlAttributes &attrs)
@@ -34,6 +35,13 @@ bool IsotopeParser::startElement(const QString&, const QString &localName, const
        {
                currentIsotope_ = new Isotope();
                inIsotope_ = true;
+               
+               //now save the symbol of the current element
+               for (int i = 0; i < attrs.length(); ++i) 
+               {
+                       if ( attrs.localName( i ) == "elementType" )
+                               currentElementSymbol_ = attrs.value( i );
+               }
        } else if (inIsotope_ && localName == "scalar") 
        {
                for (int i = 0; i < attrs.length(); ++i) 
@@ -58,6 +66,7 @@ bool IsotopeParser::endElement (  const QString & namespaceURI, const QString &
 {
        if ( localName == "isotope" )
        {
+               currentIsotope_->setParentSymbol( currentElementSymbol_ );
                isotopes_.append(currentIsotope_);
                
                currentIsotope_ = 0;
index d34d0229569aa2b661eb275b54854b80700194fa..f2c58b6b76c8f41490f5e43ced633106cd7d244c 100644 (file)
@@ -44,6 +44,8 @@ class IsotopeParser : public QXmlDefaultHandler
                ChemicalDataObject::BlueObeliskUnit currentUnit_;
 
                QVariant currentErrorValue_;
+
+               QString currentElementSymbol_;
                
                Isotope* currentIsotope_;
                QList<Isotope*> isotopes_;