]> Git trees. - libqmvoc.git/commitdiff
make the temperature update correctly in the small info dialog
authorAnne-Marie Mahfouf <annma@kde.org>
Sun, 13 Jun 2004 00:53:06 +0000 (00:53 +0000)
committerAnne-Marie Mahfouf <annma@kde.org>
Sun, 13 Jun 2004 00:53:06 +0000 (00:53 +0000)
svn path=/trunk/kdeedu/kalzium/src/element.cpp; revision=320141

kalzium/src/element.cpp

index 40e19a700c9d83938d9ca2341b865e5af4a437b0..aee8f52b53244765a91729993badc97dfdb54bc1 100644 (file)
@@ -104,17 +104,22 @@ const QString Element::adjustUnits( double val, const int type )
        }
        else if ( type == TEMPERATURE ) // convert a temperature
        {
-               if ( Prefs::temperature() == 0 )
-               {
-                       val+=272.25;
-                       v = QString::number( val );
-                       v.append( "°C" );
-               }
-               else // use Kelvin
-               {
-                       v = QString::number( val );
-                       v.append( "K" );
-               }
+                       switch (Prefs::temperature()) {
+                               case 0: //Kelvin
+                                       v = QString::number( val );
+                                       v.append( "K" );
+                                       break;
+                               case 1:// Kelvin to Fahrenheit
+                                       val = val * 1.8 - 459.67;
+                                       v = QString::number( val );
+                                       v.append( "F" );
+                                       break;
+                               case 2: //Kelvin to Celsius
+                                       val-=273.15;
+                                       v = QString::number( val );
+                                       v.append( "°C" );
+                                       break;
+                       }
        }
        else if ( type == LENGHT ) // its a length
        {