QML UI: clear out empty strings from the UI

Right now the UI shows "--" as place filler for empty data. That may or
may not change - but while it's there, we should not store that string in
the corresponding string fields of the dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-01-28 14:00:52 -08:00
parent 30a4fb2274
commit 106bb07cff

View file

@ -330,6 +330,20 @@ void QMLManager::refreshDiveList()
QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth, QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes) QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
{ {
#define DROP_EMPTY_PLACEHOLDER(_s) if ((_s) == QLatin1Literal("--")) (_s).clear()
DROP_EMPTY_PLACEHOLDER(location);
DROP_EMPTY_PLACEHOLDER(duration);
DROP_EMPTY_PLACEHOLDER(depth);
DROP_EMPTY_PLACEHOLDER(airtemp);
DROP_EMPTY_PLACEHOLDER(watertemp);
DROP_EMPTY_PLACEHOLDER(suit);
DROP_EMPTY_PLACEHOLDER(buddy);
DROP_EMPTY_PLACEHOLDER(diveMaster);
DROP_EMPTY_PLACEHOLDER(notes);
#undef DROP_EMPTY_PLACEHOLDER
struct dive *d = get_dive_by_uniq_id(diveId.toInt()); struct dive *d = get_dive_by_uniq_id(diveId.toInt());
// notes comes back as rich text - let's convert this into plain text // notes comes back as rich text - let's convert this into plain text
QTextDocument doc; QTextDocument doc;
@ -439,8 +453,6 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
if (same_string(d->dc.model, "manually added dive")) if (same_string(d->dc.model, "manually added dive"))
d->dc.maxdepth.mm = d->maxdepth.mm; d->dc.maxdepth.mm = d->maxdepth.mm;
} }
if (airtemp == "--")
airtemp = "";
if (get_temperature_string(d->airtemp, true) != airtemp) { if (get_temperature_string(d->airtemp, true) != airtemp) {
diveChanged = true; diveChanged = true;
if (airtemp.contains(tr("C"))) if (airtemp.contains(tr("C")))
@ -449,8 +461,6 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
prefs.units.temperature = units::FAHRENHEIT; prefs.units.temperature = units::FAHRENHEIT;
d->airtemp.mkelvin = parseTemperatureToMkelvin(airtemp); d->airtemp.mkelvin = parseTemperatureToMkelvin(airtemp);
} }
if (watertemp == "--")
watertemp = "";
if (get_temperature_string(d->watertemp, true) != watertemp) { if (get_temperature_string(d->watertemp, true) != watertemp) {
diveChanged = true; diveChanged = true;
if (watertemp.contains(tr("C"))) if (watertemp.contains(tr("C")))