summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Cord-Landwehr <cordlandwehr@kde.org>2015-09-27 16:53:11 (GMT)
committerAndreas Cord-Landwehr <cordlandwehr@kde.org>2015-09-27 16:53:11 (GMT)
commit3b0bcbf80c0a3636695a4d3d3a2a0e16e0acedbe (patch)
tree7be16295a4bb085938034ce387093962502fbcd0
parent1190ea4de7aaff1a016114c2c88ede127d55a3a4 (diff)
Fix porting of unit conversions in calculator.
-rw-r--r--src/calculator/gasCalculator.cpp24
-rw-r--r--src/kalziumutils.cpp4
2 files changed, 14 insertions, 14 deletions
diff --git a/src/calculator/gasCalculator.cpp b/src/calculator/gasCalculator.cpp
index fc7a2af..378d897 100644
--- a/src/calculator/gasCalculator.cpp
+++ b/src/calculator/gasCalculator.cpp
@@ -145,7 +145,7 @@ void gasCalculator::calculatePressure()
double pressure = m_moles * R * temp / (volume - m_moles * b) - m_moles * m_moles * m_Vand_a / volume / volume;
m_pressure = Value(pressure, KUnitConversion::Atmosphere);
- //m_pressure = m_pressure.convertTo(getCurrentUnitId(KUnitConversion::UnitId(ui.pressure_unit->value())));
+ m_pressure = m_pressure.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.pressure_unit)));
ui.pressure->setValue(m_pressure.number());
}
@@ -170,7 +170,7 @@ void gasCalculator::calculateVol()
double volume = m_moles * R * temp / pressure + (m_moles * b);
m_vol = Value(volume, KUnitConversion::Liter);
- // m_vol = m_vol.convertTo(getCurrentUnitId(KUnitConversion::UnitId(ui.volume_unit->value())));
+ m_vol = m_vol.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.volume_unit)));
ui.volume->setValue(m_vol.number());
}
@@ -183,7 +183,7 @@ void gasCalculator::calculateTemp()
double temp = (pressure + (m_moles * m_moles * m_Vand_a / volume / volume))\
* (volume - m_moles * b) / m_moles / R;
m_temp = Value(temp, KUnitConversion::Kelvin);
- // m_temp = m_temp.convertTo(getCurrentUnitId(ui.temp_unit->value()));
+ m_temp = m_temp.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.temp_unit)));
ui.temp->setValue(m_temp.number());
}
@@ -209,32 +209,32 @@ void gasCalculator::calculateMass()
double mass = (pressure + m_moles * m_moles * m_Vand_a / volume / volume)\
* (volume - m_moles * b) * m_molarMass / R / temp;
m_mass = Value(mass, KUnitConversion::Gram);
- // m_mass = m_mass.convertTo(getCurrentUnitId(KUnitConversion::UnitId(ui.mass_unit->value())));
+ m_mass = m_mass.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.mass_unit)));
ui.mass->setValue(m_mass.number());
}
void gasCalculator::volChanged()
{
- //m_vol = Value(ui.volume->value(), getCurrentUnitId(KUnitConversion::UnitId(ui.volume_unit->value())));
+ m_vol = Value(ui.volume->value(), KUnitConversion::UnitId(getCurrentUnitId(ui.volume_unit)));
calculate();
}
void gasCalculator::tempChanged()
{
- // m_temp = Value(ui.temp->value(), getCurrentUnitId(ui.temp_unit->value()));
+ m_temp = Value(ui.temp->value(), KUnitConversion::UnitId(getCurrentUnitId(ui.temp_unit)));
calculate();
}
void gasCalculator::pressureChanged()
{
- // m_pressure = Value(ui.pressure->value(), getCurrentUnitId(ui.pressure_unit->value()));
+ m_pressure = Value(ui.pressure->value(), KUnitConversion::UnitId(getCurrentUnitId(ui.pressure_unit)));
calculate();
}
void gasCalculator::massChanged()
{
- //m_mass = Value(ui.mass->value(), getCurrentUnitId(ui.mass_unit->value()));
+ m_mass = Value(ui.mass->value(), KUnitConversion::UnitId(getCurrentUnitId(ui.mass_unit)));
m_moles = m_mass.convertTo(KUnitConversion::Gram).number() / m_molarMass;
ui.moles->setValue(m_moles);
calculate();
@@ -244,7 +244,7 @@ void gasCalculator::molesChanged(double value)
{
m_moles = value;
m_mass = Value(m_moles * m_molarMass, KUnitConversion::Gram);
- // m_mass = m_mass.convertTo(getCurrentUnitId(ui.mass_unit->value()));
+ m_mass = m_mass.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.mass_unit)));
ui.mass->setValue(m_mass.number());
calculate();
}
@@ -257,7 +257,7 @@ void gasCalculator::molarMassChanged(double value)
}
m_molarMass = value;
m_mass = Value(m_molarMass * m_moles, KUnitConversion::Gram);
- // m_mass = m_mass.convertTo(getCurrentUnitId(ui.mass_unit->value()));
+ m_mass = m_mass.convertTo(KUnitConversion::UnitId(getCurrentUnitId(ui.mass_unit)));
ui.mass->setValue(m_mass.number());
calculate();
}
@@ -270,7 +270,7 @@ void gasCalculator::Vand_aChanged()
void gasCalculator::Vand_bChanged()
{
- // m_Vand_b = Value(ui.b->value(), getCurrentUnitId(ui.b_unit->value()));
+ m_Vand_b = Value(ui.b->value(), KUnitConversion::UnitId(getCurrentUnitId(ui.b_unit)));
calculate();
}
@@ -327,7 +327,7 @@ void gasCalculator::error(int mode)
{
switch (mode) { // Depending on the mode, set the error messages.
case RESET_GAS_MESSAGE:
- ui.error->setText("");
+ ui.error->setText(QString());
break;
case VOL_ZERO :
ui.error->setText(i18n("Volume cannot be zero, please enter a valid value."));
diff --git a/src/kalziumutils.cpp b/src/kalziumutils.cpp
index 12000c9..5109d10 100644
--- a/src/kalziumutils.cpp
+++ b/src/kalziumutils.cpp
@@ -179,9 +179,9 @@ void KalziumUtils::populateUnitCombobox(QComboBox *comboBox, const QList<int> &u
QString unitString;
foreach (int unit, unitList) {
- //unitString = KUnitConversion::Converter().unit(unit).data()->description();
+ unitString = KUnitConversion::Converter().unit(KUnitConversion::UnitId(unit)).description();
unitString.append(" (");
- //unitString.append(KUnitConversion::Converter().unit(unit).data()->symbol());
+ unitString.append(KUnitConversion::Converter().unit(KUnitConversion::UnitId(unit)).symbol());
unitString.append(")");
comboBox->addItem(unitString, unit);
}