[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/kalzium/src/calculator
From:       Kashyap Ramesh Puranik <kashthealien () gmail ! com>
Date:       2009-07-03 11:22:43
Message-ID: 1246620163.731390.19766.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 990809 by kashyappuranik:

Fixing a few more bugs with the error messages.


 M  +16 -3     concCalculator.cpp  
 M  +2 -1      concCalculator.h  
 M  +18 -1     gasCalculator.cpp  
 M  +2 -1      gasCalculator.h  
 M  +15 -2     nuclearCalculator.cpp  
 M  +2 -1      nuclearCalculator.h  


--- trunk/KDE/kdeedu/kalzium/src/calculator/concCalculator.cpp #990808:990809
@@ -82,6 +82,8 @@
 // Initialises values and GUI.
 void concCalculator::init()
 {
+	error(RESET_CONC_MESSAGE);
+		
     ui.amtSolute            -> setValue(117.0);
     ui.molarMass            -> setValue(58.5);
     ui.eqtMass              -> setValue(58.5);
@@ -90,6 +92,15 @@
     ui.molarMassSolvent     -> setValue(18.0);
     ui.densitySolvent       -> setValue(1000.0);
     ui.concentration        -> setValue(2.0);
+    
+    ui.amtSltType	->setCurrentIndex(0);
+    ui.amtSlt_unit	->setCurrentIndex(0);
+    ui.densSlt_unit ->setCurrentIndex(0);
+    ui.amtSlvtType  ->setCurrentIndex(0);
+    ui.amtSlvt_unit ->setCurrentIndex(0);
+    ui.densSlvt_unit->setCurrentIndex(0);
+    ui.conc_unit	->setCurrentIndex(0);
+    
     // Setup of the UI done
 
     // Initialise values
@@ -804,6 +815,7 @@
 // occurs when any quantity is changed
 void concCalculator::calculate()
 {
+	error(RESET_CONC_MESSAGE);
     // Calculate the amount of solute
     switch (m_mode)
 	{
@@ -837,8 +849,10 @@
 // This function puts the error messages on the screen depending on the mode.
 void concCalculator::error(int mode)
 {
-	
-    switch (mode) {
+    switch (mode) { // Depending on the mode, set the error messages.
+	case RESET_CONC_MESSAGE:
+		ui.error->setText("");
+		break;
     case PERCENTAGE:
         ui.error->setText(i18n("Percentage should be less than 100.0, please enter \
valid data!"));  break;
@@ -866,7 +880,6 @@
     case INSUFFICIENT_DATA_EQT:
         ui.error->setText(i18n("Insufficient data! to calculate the required, please \
specify normality!"));  break;
-
     case INSUFFICIENT_DATA_MOLE:
         ui.error->setText(i18n("Insufficient data, specify molarity / molefraction / \
molality to calculate!"));  break;
--- trunk/KDE/kdeedu/kalzium/src/calculator/concCalculator.h #990808:990809
@@ -25,7 +25,8 @@
 
 // Enumeration for type of error used in the error() function
 enum ERROR_TYPE_CONC {
-    PERCENTAGE = 0,
+	RESET_CONC_MESSAGE = 0,
+    PERCENTAGE,
     DENSITY_ZERO,
     MASS_ZERO,
     VOLUME_ZERO,
--- trunk/KDE/kdeedu/kalzium/src/calculator/gasCalculator.cpp #990808:990809
@@ -74,6 +74,8 @@
 
 void gasCalculator::init()
 {
+	error(RESET_GAS_MESSAGE);
+	
 	ui.molarMass-> setValue(2.008);
     ui.temp     -> setValue(273.0);
     ui.volume   -> setValue(22.400);
@@ -82,8 +84,17 @@
     ui.b        -> setValue(0.0);
     ui.mass     -> setValue(2.016);
     ui.moles    -> setValue(1.0);
+    
+    ui.mass_unit	->setCurrentIndex(0);
+    ui.pressure_unit->setCurrentIndex(0);
+    ui.temp_unit	->setCurrentIndex(0);
+    ui.volume_unit	->setCurrentIndex(0);
+    ui.b_unit		->setCurrentIndex(0);
+    ui.a_unit		->setCurrentIndex(0);
+    
     // Setup of the UI done
 
+	
     // Initialise values
     m_temp = Value(273.0, "kelvins");
     m_molarMass = 2.016;
@@ -306,6 +317,8 @@
 // occurs when any quantity is changed
 void gasCalculator::calculate()
 {
+	error(RESET_GAS_MESSAGE);
+		
     switch(m_mode)
     {
 	case MOLES:
@@ -325,9 +338,13 @@
 
 void gasCalculator::error(int mode)
 {
-    switch (mode) {
+    switch (mode) { // Depending on the mode, set the error messages.
+	case RESET_GAS_MESSAGE:
+		ui.error->setText("");
+		break;
     case VOL_ZERO :
         ui.error->setText(i18n("Volume cannot be zero, please correct the error!"));
+        break;
     default:
         break;
     }
--- trunk/KDE/kdeedu/kalzium/src/calculator/gasCalculator.h #990808:990809
@@ -30,7 +30,8 @@
 using namespace Conversion;
 
 enum ERROR_TYPE_GAS {
-    VOL_ZERO = 0
+	RESET_GAS_MESSAGE = 0,
+    VOL_ZERO
 };
 
 enum MODE_CALCULATION_GAS {
--- trunk/KDE/kdeedu/kalzium/src/calculator/nuclearCalculator.cpp #990808:990809
@@ -102,6 +102,13 @@
     ui.finalAmt   -> setValue(3.0);
     ui.time		  -> setValue(list.at(18) -> halflife());
     
+    ui.halfLife_unit	->setCurrentIndex(0);
+    ui.initAmtType		->setCurrentIndex(0);
+    ui.finalAmtType		->setCurrentIndex(0);
+    ui.initAmt_unit		->setCurrentIndex(0);
+    ui.finalAmt_unit	->setCurrentIndex(0);
+    ui.time_unit		->setCurrentIndex(0);
+    
     QString tempStr;
     tempStr.setNum(list.at(18) -> mass());
     ui.mass -> setText(tempStr);
@@ -253,7 +260,8 @@
 }
 void  nuclearCalculator::calculate()
 {
-
+	error(RESET_NUKE_MESSAGE);
+	
     // Validate the values involved in calculation
     if (m_halfLife.number() == 0.0)
     {
@@ -303,6 +311,8 @@
 
 void nuclearCalculator::calculateInitAmount()
 {
+	error(RESET_NUKE_MESSAGE);
+	
     // If no time has elapsed, initial and final amounts are the same
     m_initAmount = m_finalAmount;
     if (m_time.number() == 0.0) {
@@ -362,7 +372,10 @@
 
 void nuclearCalculator::error (int mode)
 {
-	switch (mode) {
+	switch (mode) { // Depending on the mode, set the error messages.
+		case RESET_NUKE_MESSAGE:
+			ui.error->setText("");
+			break;
 		case INIT_AMT_ZERO:
 			ui.error->setText(i18n("Initial amount can not be zero!"));
 			break;
--- trunk/KDE/kdeedu/kalzium/src/calculator/nuclearCalculator.h #990808:990809
@@ -27,7 +27,8 @@
 using namespace Conversion;
 
 enum ERROR_MODE_NUKE {
-	INIT_AMT_ZERO = 0,
+	RESET_NUKE_MESSAGE = 0,
+	INIT_AMT_ZERO,
 	FINAL_AMT_ZERO,
 	HALFLIFE_ZERO,
 	FINAL_AMT_GREATER


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic