From: Carsten Niehaus Date: Wed, 19 Jan 2005 12:39:03 +0000 (+0000) Subject: fixing 90330 for head as well X-Git-Tag: v3.80.2~300^2~161 X-Git-Url: https://git.rmz.fi/?a=commitdiff_plain;h=5bfb0d41ec6147cdb6b6726c21e6995eebe3cea0;p=libqmvoc.git fixing 90330 for head as well svn path=/trunk/kdeedu/kalzium/src/element.cpp; revision=380057 --- diff --git a/kalzium/src/element.cpp b/kalzium/src/element.cpp index e98627a..a32be67 100644 --- a/kalzium/src/element.cpp +++ b/kalzium/src/element.cpp @@ -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/cm3" ); + 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/cm3" ); + } } else if ( type == DATE ) //its a date { + val = date(); if ( val < 1600 ) { v = i18n( "This element was known to ancient cultures" ); diff --git a/kalzium/src/element.h b/kalzium/src/element.h index 137ea0a..57e742b 100644 --- a/kalzium/src/element.h +++ b/kalzium/src/element.h @@ -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,