desktop UI: remove strange sprintf calls

I'm rather upset that I never noticed this in a review. That's just not how you
print numbers.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2020-01-04 16:04:36 -08:00
parent b12d0b1840
commit 4e7adcf96a

View file

@ -161,9 +161,7 @@ void TabDiveInformation::updateProfile()
ui->atmPressVal->clear(); // If no atm pressure for dive then clear text box ui->atmPressVal->clear(); // If no atm pressure for dive then clear text box
} else { } else {
ui->atmPressVal->setEnabled(true); ui->atmPressVal->setEnabled(true);
QString pressStr; ui->atmPressVal->setText(QString::number(current_dive->surface_pressure.mbar)); // else display atm pressure
pressStr.sprintf("%d",current_dive->surface_pressure.mbar);
ui->atmPressVal->setText(pressStr); // else display atm pressure
} }
} }
@ -329,7 +327,7 @@ void TabDiveInformation::divesChanged(const QVector<dive *> &dives, DiveField fi
if (field.water_temp) if (field.water_temp)
ui->watertemp->setText(get_temperature_string(current_dive->watertemp, true)); ui->watertemp->setText(get_temperature_string(current_dive->watertemp, true));
if (field.atm_press) if (field.atm_press)
ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",current_dive->surface_pressure.mbar)); ui->atmPressVal->setText(QString::number(current_dive->surface_pressure.mbar));
if (field.salinity) if (field.salinity)
checkDcSalinityOverWritten(); checkDcSalinityOverWritten();
if (current_dive->user_salinity) if (current_dive->user_salinity)
@ -423,7 +421,7 @@ void TabDiveInformation::updateTextBox(int event) // Either the text box has bee
else else
altitudeVal = altitudeVal * 1000; // metric: convert altitude from meters to mm altitudeVal = altitudeVal * 1000; // metric: convert altitude from meters to mm
atmpress.mbar = altitude_to_pressure((int32_t) altitudeVal); // convert altitude (mm) to pressure (mbar) atmpress.mbar = altitude_to_pressure((int32_t) altitudeVal); // convert altitude (mm) to pressure (mbar)
ui->atmPressVal->setText(ui->atmPressVal->text().sprintf("%d",atmpress.mbar)); ui->atmPressVal->setText(QString::number(atmpress.mbar));
ui->atmPressType->setCurrentIndex(0); // reset combobox to mbar ui->atmPressType->setCurrentIndex(0); // reset combobox to mbar
} else { // i.e. event == COMBO_CHANGED, that is, "m" or "ft" was selected from combobox } else { // i.e. event == COMBO_CHANGED, that is, "m" or "ft" was selected from combobox
// Show estimated altitude // Show estimated altitude