Bug 109081

Summary: Temparature setting change is not applied when you are in State of Matter
Product: [Applications] kalzium Reporter: Anne-Marie Mahfouf <annma>
Component: generalAssignee: Kalzium Developers <kalzium>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Anne-Marie Mahfouf 2005-07-14 15:43:55 UTC
Version:           1.4.2pre3 (using KDE 3.4.89 (>= 20050615), compiled sources)
Compiler:          Target: i586-mandriva-linux-gnu
OS:                Linux (i686) release 2.6.11-9.mm.6mdk

This report has 2 points:
1) the current temperature should be shown in the statusbar when in the State of Matter. Only units is not quite enough.
2) when you are in F for example, in State of Matter and you open Settings -> Configure Kalzium -> Units and you change the temperature here, when you Apply, the temperature is not changed in the State of Matter.
Comment 1 Inge Wallin 2005-08-17 00:52:35 UTC
And neither are they changed in the details window -> the Energies page.

The same is probably true also for changes in energy unit from kJ/mol to eV.
Comment 2 cniehaus 2005-08-20 14:43:24 UTC
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();
 
Comment 3 cniehaus 2005-09-05 14:20:56 UTC
Pino and I disagree about the statusbar: If you have that information you need 
all information to be consitent. But as Kalzium is getting more and complex 
that would mean the statusbar will be full soon. My poposal of having 
comboboxes in the statusbar was not accepted.

The temperature-unit is now displayed in the state-of-matter feature.
Comment 4 Pino Toscano 2005-10-30 11:18:15 UTC
This bug can be closed, as we fixed both the points reported by the reporter:

> 1) the current temperature should be shown in the statusbar when in the
> State of Matter. Only units is not quite enough.

The temperature settings have "sense" only in the detail dialog or in the State of Matter mode: in this mode, there are both the current temperature value and the symbol of the current unit temperature next to the value.

> 2) when you are in F for example, in State of Matter and you open Settings
> -> Configure Kalzium -> Units and you change the temperature here, when you
> Apply, the temperature is not changed in the State of Matter. 
 
This is fixed too, changing the temperature in the settings will produce the immediate update in the State of Matter tab of the sidebar.