]> Git trees. - libqmvoc.git/commitdiff
fixing 90330 for head as well
authorCarsten Niehaus <cniehaus@gmx.de>
Wed, 19 Jan 2005 12:39:03 +0000 (12:39 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Wed, 19 Jan 2005 12:39:03 +0000 (12:39 +0000)
svn path=/trunk/kdeedu/kalzium/src/element.cpp; revision=380057

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

index e98627a9abb3391f352a1a59906de62ca78a9d4b..a32be67fc2a3a4652905fc376616dfc01776fad1 100644 (file)
@@ -81,64 +81,84 @@ double Element::meanweight()
        return m_weight/m_number;
 }
 
-const QString Element::adjustUnits( double val, const int type )
+const QString Element::adjustUnits( const int type )
 {
        QString v = QString::null;
+
+       double val = 0.0; //the value to convert
        
-       if ( type == ENERGY ) // convert an energy
+       if ( type == IE || type == IE2 ) //an ionization energy
        {
+               if ( type == IE )
+                       val = ie();
+               else
+                       val = ie2();
+       
                if ( val == -1 )
                        v = i18n( "Value unknown" );
-               else {
-                       if ( Prefs::units() == 0 )
-                       {
-                               val*=96.6;
-                               v = QString::number( val );
-                               v.append( "kj/mol" );
-                       }
-                       else // use electronvolt
-                       {
-                               v = QString::number( val );
-                               v.append( "eV" );
-                       }
+               else 
+               {
+                       v = QString::number( val );
+                       v.append( "eV" );
                }
        }
-       else if ( type == TEMPERATURE ) // convert a temperature
+       else if ( type == BOILINGPOINT || type == MELTINGPOINT ) // convert a temperature
        {
-                       switch (Prefs::temperature()) {
-                               case 0: //Kelvin
-                                       v = QString::number( val );
-                                       v.append( "K" );
-                                       break;
-                               case 1://Kelvin to Celsius
-                                       val-=273.15;
-                                       v = QString::number( val );
-                                       v.append( "C" );
-                                       break;
-                               case 2: // Kelvin to Fahrenheit
-                                       val = val * 1.8 - 459.67;
-                                       v = QString::number( val );
-                                       v.append( "F" );
-                                       break;
-                       }
+               if ( type == BOILINGPOINT )
+                       val = boiling();
+               else
+                       val = melting();
+
+               switch (Prefs::temperature()) {
+                       case 0: //Kelvin
+                               v = QString::number( val );
+                               v.append( "K" );
+                               break;
+                       case 1://Kelvin to Celsius
+                               val-=273.15;
+                               v = QString::number( val );
+                               v.append( "C" );
+                               break;
+                       case 2: // Kelvin to Fahrenheit
+                               val = val * 1.8 - 459.67;
+                               v = QString::number( val );
+                               v.append( "F" );
+                               break;
+               }
        }
-       else if ( type == LENGHT ) // its a length
+       else if ( type == RADIUS ) // its a length
        {
+               val = radius();
+
                v = QString::number( val );
-               v.append( " pm" );
+
+               v.append( i18n( " pm" ) );
        }
        else if ( type == WEIGHT ) // its a weight
        {
+               val = weight();
+
                v = QString::number( val );
-               v.append( " u" );
+               v.append( i18n( " u" ) );
        }
        else if ( type == DENSITY ) // its a density
        {
-               v = QString::number( val );
-               v.append( " g/cm<sup>3</sup>" );
+               val = density();
+
+               if ( az() == 2 )//gasoline
+               {
+                       v = QString::number( val );
+                       v.append( " g/L" );
+               }
+               else//liquid or solid
+               {
+                       v = QString::number( val );
+                       v.append( " g/cm<sup>3</sup>" );
+               }
        }
        else if ( type == DATE ) //its a date
        {
+               val = date();
                if ( val < 1600 )
                {
                        v = i18n( "This element was known to ancient cultures" );
index 137ea0a5a6b63dee1a346e68aa078755b47e5526..57e742bbfd5fbac320fed0dd6b32219b64a83998 100644 (file)
@@ -147,8 +147,6 @@ class Element{
                 */
                QString parsedOrbits();
                
-//XXX check if its really kelvin!!!
-               
                /**
                 * @return the boiling point of the element in Kelvin
                 */
@@ -223,19 +221,21 @@ class Element{
                 * @param type the TYPE of the data
                 * @return the adjusted datastring
                 */
-               static const QString adjustUnits( double val, const int type );
+               const QString adjustUnits( const int type );
 
                /**
                 * missing
                 */
                enum TYPE
                {
-                       TEMPERATURE = 0,
-                       ENERGY = 1,
-                       LENGHT = 2,
-                       WEIGHT = 3,
-                       DENSITY = 4,
-                       DATE = 5
+                       RADIUS = 0,
+                       WEIGHT,
+                       DENSITY,
+                       DATE,
+                       BOILINGPOINT,
+                       MELTINGPOINT,
+                       IE,
+                       IE2
                };
 
 
@@ -244,6 +244,7 @@ class Element{
 
        private:
                void setupXY();
+               
 
                double  m_weight,
                        m_MP,