[Kalzium] [Bug 109081] Temparature setting change is not applied when you are in State of Matter

cniehaus@gmx.de cniehaus at gmx.de
Sat Aug 20 14:43:25 CEST 2005


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=109081         




------- Additional Comments From cniehaus gmx de  2005-08-20 14:43 -------
SVN commit 451327 by cniehaus:

First fix for this bug: Now the correct temperatures are displayed/calculated

Two problems remain:
1. The QSpingBox is to small (<-- Pino)
2. The min/max values need to be adjusted:
   For Kelvin the scale starts a 0 and end at 5000K
   For Celsius: -273 -> also 5000
   For Fahrenheit: Don't know off hand

CCBUG:109081


 M  +2 -2      element.cpp  
 M  +3 -0      somwidget.ui  
 M  +23 -0     somwidget_impl.cpp  


--- branches/KDE/3.5/kdeedu/kalzium/src/element.cpp #451326:451327
 @ -151,11 +151,11  @
 					break;
 				case 1://Kelvin to Celsius
 					val-=273.15;
-					v = i18n( "%1 is the temperature in Celsius", "%1 C" ).arg( QString::number( val ) );
+					v = i18n( "%1 is the temperature in Celsius", "%1 %2C" ).arg( QString::number( val ) ).arg( "\xB0" );
 					break;
 				case 2: // Kelvin to Fahrenheit
 					val = val * 1.8 - 459.67;
-					v = i18n( "%1 is the temperature in Fahrenheit", "%1 F" ).arg( QString::number( val ) );
+					v = i18n( "%1 is the temperature in Fahrenheit", "%1 %2F" ).arg( QString::number( val ) ).arg("\xB0");
 					break;
 			}
 		}
--- branches/KDE/3.5/kdeedu/kalzium/src/somwidget.ui #451326:451327
 @ -152,6 +152,9  @
                     <property name="name">
                         <cstring>Number1</cstring>
                     </property>
+                    <property name="suffix">
+                        <string>K</string>
+                    </property>
                     <property name="maxValue">
                         <number>5000</number>
                     </property>
--- branches/KDE/3.5/kdeedu/kalzium/src/somwidget_impl.cpp #451326:451327
 @ -12,6 +12,7  @
  ***************************************************************************/
 
 #include "somwidget_impl.h"
+#include "prefs.h"
 
 #include <qslider.h>
 #include <qtextedit.h>
 @ -48,6 +49,28  @
 {
 	static const int threshold = 25;
 
+	double temp_ = ( double )temp;
+			
+	//We won't to use the user's settings for the temperature here.
+	switch (Prefs::temperature()) {
+		case 0: //Kelvin
+			//The tempearature is already Kelin, doesn't need to
+			//be adjusted...
+			Number1->setSuffix( "K" );
+			break;
+		case 1: //convert from Celsius to Kelvin
+			temp_ += 273.15;
+			Number1->setSuffix( i18n("%1C").arg( "\xB0" ) );
+			break;
+		case 2: //convert from Fahrenheit to Kelvin
+			temp_ = ( int )( temp_ + 459.67 ) / 1.8;
+			Number1->setSuffix( i18n("%1C").arg( "\xB0" ) );
+			break;
+	}
+
+	//Ok, now make 'temp' store the temperature in Kelvin
+	temp = ( int )temp_;
+
 	QValueList<Element*>::ConstIterator it = m_list.begin();
 	const QValueList<Element*>::ConstIterator itEnd = m_list.end();


More information about the Kalzium mailing list