]> Git trees. - libqmvoc.git/commitdiff
Make the ionisationenergies work again. No many how many ion.energies
authorCarsten Niehaus <cniehaus@gmx.de>
Sat, 21 May 2005 09:56:27 +0000 (09:56 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sat, 21 May 2005 09:56:27 +0000 (09:56 +0000)
Kalzium knows about :-)

svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=416353

kalzium/src/element.cpp
kalzium/src/element.h

index a493b3d3a5239cd6ceb91b38a2d4b84ec04d5aa1..a8e14ffafc6ab401f331a04a1952bcb07442976f 100644 (file)
@@ -83,37 +83,33 @@ double Element::meanweight()
        return m_weight/m_number;
 }
 
-const QString Element::adjustUnits( const int type )
+const QString Element::adjustUnits( const int type, double value )
 {
        QString v = QString::null;
-
-       double val = 0.0; //the value to convert
-       
-       if ( type == IE || type == IE2 ) //an ionization energy
+       if ( type == IE  ) //an ionization energy
        {
-               if ( type == IE )
-                       val = ie();
-               else
-                       val = ie2();
-       
-               if ( val == -1 )
-                       v = i18n( "Value unknown" );
-               else 
+               if ( Prefs::energies() == 0 )
                {
-                       if ( Prefs::energies() == 0 )
-                       {
-                               val*=96.6;
-                               v = QString::number( val );
-                               v.append( "kJ/mol" );
-                       }
-                       else // use electronvolt
-                       {
-                               v = QString::number( val );
-                               v.append( "eV" );
-                       }
+                       value*=96.6;
+                       v = QString::number( value );
+                       v.append( "kJ/mol" );
+               }
+               else // use electronvolt
+               {
+                       v = QString::number( value );
+                       v.append( "eV" );
                }
        }
-       else if ( type == BOILINGPOINT || type == MELTINGPOINT ) // convert a temperature
+       return v;
+}
+
+const QString Element::adjustUnits( const int type )
+{
+       QString v = QString::null;
+
+       double val = 0.0; //the value to convert
+       
+       if ( type == BOILINGPOINT || type == MELTINGPOINT ) // convert a temperature
        {
                if ( type == BOILINGPOINT )
                        val = boiling();
@@ -442,7 +438,7 @@ KalziumDataObject::KalziumDataObject()
        }
 
        if (!layoutFile.open(IO_ReadOnly))
-               KMessageBox::information( 0, i18n("data.xml io-errro"), i18n( "Loading File - IO_ReadOnly" ) );
+               KMessageBox::information( 0, i18n("data.xml IO-error"), i18n( "Loading File - IO_ReadOnly" ) );
 
        ///Check if document is well-formed
        if (!doc.setContent(&layoutFile))
@@ -502,6 +498,13 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                QString oxydation = domElement.namedItem( "oxydation" ).toElement().text();
                QString acidicbehaviour = domElement.namedItem( "acidicbehaviour" ).toElement().text();
                QString isotopes = domElement.namedItem( "isotopes" ).toElement().text();
+
+               QDomNodeList elist = domElement.elementsByTagName( "energy" );
+               QValueList<double> ionlist;
+               for( uint i = 0; i < elist.length(); i++ )
+               {
+                       ionlist.append( elist.item( i ).toElement().text().toDouble() );
+               }
        
                Element *e = new Element();
                e->setDate(date);
@@ -519,6 +522,7 @@ EList KalziumDataObject::readData(  QDomDocument &dataDocument )
                e->setOxydation(oxydation);
                e->setAcidicbehaviour(acidicbehaviour);
                e->setIsotopes(isotopes);
+               e->setIonisationList( ionlist );
                
                e->setWeight( weight ); 
                e->setEN( en );
index 11eaf9db97be2aeddb8afd86f6f92ef80de5860d..cbe74a8fe58cf45bd4aa5ef6ca128f259975b4a8 100644 (file)
@@ -33,6 +33,7 @@ struct coordinate;
 
 typedef QValueList<Element*> EList;
 typedef QValueList<coordinate> CList;
+typedef QValueList<double> doubleList;
 
 /**
  * @short this class contains all Element-objects as
@@ -104,6 +105,14 @@ class Element{
                void setOxydation( QString value ) { m_oxstage = value; }
                void setAcidicbehaviour( QString value ) { m_acidbeh = value; }
                void setIsotopes( QString value ) { m_isotopes = value; }
+
+               void setIonisationList( doubleList l ){
+                       m_ionenergies = l;
+               }
+
+               QValueList<double> ionisationList() const{
+                       return m_ionenergies;
+               }
                
                
                /**
@@ -278,6 +287,11 @@ class Element{
                 */
                const QString adjustUnits( const int type );
 
+               /**
+                * needed for values stored in a QValueList<double>
+                */
+               const QString adjustUnits( const int type, double value );
+
                /**
                 * missing
                 */
@@ -342,6 +356,8 @@ class Element{
                        m_orbits,
                        m_isotopes,
                        m_scientist;
+
+               doubleList m_ionenergies;
                
        public:
                /**