]> Git trees. - libqmvoc.git/commitdiff
keep it up with the current 3.5 branch
authorPino Toscano <pino@kde.org>
Thu, 8 Sep 2005 13:06:11 +0000 (13:06 +0000)
committerPino Toscano <pino@kde.org>
Thu, 8 Sep 2005 13:06:11 +0000 (13:06 +0000)
svn path=/trunk/KDE/kdeedu/kalzium/src/element.cpp; revision=458550

kalzium/src/element.cpp

index 0367c0950d95f2bdfe69aa6137faea37e94b8dc2..8b6d3f2e4e7a9c677542aa8f9fdc0d843f9b8f75 100644 (file)
@@ -24,6 +24,7 @@
 #include "isotope.h"
 #include "kalziumdataobject.h"
 #include "kalziumutils.h"
+#include "tempunit.h"
 
 #include <qdom.h>
 #include <qfile.h>
@@ -146,17 +147,23 @@ const QString Element::adjustUnits( const int type )
                        v = i18n( "Value unknown" );
                else
                {
+                       int newvalue = (int)TempUnit::convert( val, Prefs::temperature(), (int)TempUnit::Kelvin );
+                       QString value = QString::number( newvalue );
                        switch (Prefs::temperature()) {
                                case 0: //Kelvin
                                        v = i18n( "%1 is the temperature in Kelvin", "%1 K" ).arg( QString::number( val ) );
                                        break;
                                case 1://Kelvin to Celsius
-                                       val-=273.15;
-                                       v = i18n( "%1 is the temperature in Celsius", "%1 %2C" ).arg( QString::number( val ) ).arg( "\xB0" );
+                                       v = i18n( "%1 is the temperature in Celsius", "%1 %2C" ).arg( val ).arg(  "\xB0" );
                                        break;
                                case 2: // Kelvin to Fahrenheit
-                                       val = val * 1.8 - 459.67;
-                                       v = i18n( "%1 is the temperature in Fahrenheit", "%1 %2F" ).arg( QString::number( val ) ).arg("\xB0");
+                                       v = i18n( "%1 is the temperature in Fahrenheit", "%1 %2F" ).arg( val ).arg(  "\xB0" );
+                                       break;
+                               case 3: // Kelvin to Rankine
+                                       v = i18n( "%1 is the temperature in Rankine", "%1 %2Ra" ).arg( val ).arg(  "\xB0" );
+                                       break;
+                               case 4: // Kelvin to Reamur
+                                       v = i18n( "%1 is the temperature in Reamur", "%1 %2R" ).arg( val ).arg(  "\xB0" );
                                        break;
                        }
                }
@@ -280,8 +287,8 @@ QColor Element::currentColor( const double temp )
 
        //If either the mp or bp is not known return
        //This is to avoid undefined behaviour
-       if ( iButton_boiling <= 0.0 || iButton_melting <= 0.0 )
-               return Qt::lightGray;
+//     if ( iButton_boiling <= 0.0 || iButton_melting <= 0.0 )
+//             return Qt::lightGray;
 
        if ( temp < iButton_melting )
        { //the element is solid
@@ -292,7 +299,7 @@ QColor Element::currentColor( const double temp )
        { //the element is liquid
                color= Prefs::color_liquid();
        }
-       else if ( temp > iButton_boiling )
+       else if ( temp > iButton_boiling && iButton_boiling > 0.0 )
        { //the element is vaporous
                color= Prefs::color_vapor();
        }