]> Git trees. - libqmvoc.git/commitdiff
puts the parent element symbol as ChemicalDataObject too
authorPino Toscano <pino@kde.org>
Sat, 29 Oct 2005 23:31:08 +0000 (23:31 +0000)
committerPino Toscano <pino@kde.org>
Sat, 29 Oct 2005 23:31:08 +0000 (23:31 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=475643

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

index 8c3badfecaeaff3ef821bd1098498e53d71d04f9..9ee1de9d4f424975ce04b653e98f2f5ade2a1aa0 100644 (file)
@@ -28,11 +28,11 @@ Isotope::Isotope()
 { 
 }
 
-Isotope::Isotope( ChemicalDataObject* mass,
-               ChemicalDataObject* ID )
+Isotope::Isotope( ChemicalDataObject* mass, ChemicalDataObject* ID )
+       : m_mass( 0 ), m_identifier( 0 )
 {
-       m_mass = mass;
-       m_identifier = ID;
+       addData( mass );
+       addData( ID );
 }
 
 Isotope::~Isotope(){}
@@ -49,8 +49,8 @@ void Isotope::addData( ChemicalDataObject* o )
                m_mass = o;
        else if ( o->type() == ChemicalDataObject::atomicNumber )
                m_identifier = o;
-
-       return;
+       else if ( o->type() == ChemicalDataObject::symbol )
+               m_parentElementSymbol = o;
 }
 
 double Isotope::mass() const
@@ -70,10 +70,5 @@ int Isotope::parentElementNumber() const
 
 QString Isotope::parentElementSymbol() const
 {
-       return m_parentElementSymbol;
-}
-
-void Isotope::setParentSymbol( const QString& symbol )
-{
-       m_parentElementSymbol = symbol;
+       return m_parentElementSymbol->value().toString();
 }
index 6396bc7d764915185157ccf5ef45b483c06f11cb..fe19d1e8d53b5c4e12ad82aeeda89db2f5ea2138 100644 (file)
@@ -48,13 +48,11 @@ class Isotope
 
                void addData( ChemicalDataObject* o );
 
-               void setParentSymbol( const QString& symbol );
-
        private:
                /**
                 * the symbol of the element the isotope belongs to
                 */
-               QString m_parentElementSymbol;
+               ChemicalDataObject* m_parentElementSymbol;
                
                /**
                 * stores the infomation about the mass of the Isotope
index c54099090ed53fdecc759c6b0ea49c3e9a9eb3b4..5345bea85515b0bc16a561d324f6a171dbc8cae8 100644 (file)
@@ -69,7 +69,7 @@ bool IsotopeParser::endElement( const QString&, const QString& localName, const
 {
        if ( localName == "isotope" )
        {
-               currentIsotope_->setParentSymbol( currentElementSymbol_ );
+               currentIsotope_->addData( new ChemicalDataObject( QVariant( currentElementSymbol_ ), ChemicalDataObject::symbol ) );
                isotopes_.append(currentIsotope_);
                
                currentIsotope_ = 0;