From 106bb07cff60057145b6eca38928951bd42dd9a7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 28 Jan 2016 14:00:52 -0800 Subject: 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 --- qt-mobile/qmlmanager.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'qt-mobile/qmlmanager.cpp') diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index cc0142d4f..f39c37ddf 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -330,6 +330,20 @@ void QMLManager::refreshDiveList() 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) { +#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()); // notes comes back as rich text - let's convert this into plain text QTextDocument doc; @@ -439,8 +453,6 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location if (same_string(d->dc.model, "manually added dive")) d->dc.maxdepth.mm = d->maxdepth.mm; } - if (airtemp == "--") - airtemp = ""; if (get_temperature_string(d->airtemp, true) != airtemp) { diveChanged = true; if (airtemp.contains(tr("C"))) @@ -449,8 +461,6 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location prefs.units.temperature = units::FAHRENHEIT; d->airtemp.mkelvin = parseTemperatureToMkelvin(airtemp); } - if (watertemp == "--") - watertemp = ""; if (get_temperature_string(d->watertemp, true) != watertemp) { diveChanged = true; if (watertemp.contains(tr("C"))) -- cgit v1.2.3-70-g09d2