aboutsummaryrefslogtreecommitdiffstats
path: root/qt-mobile
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-28 14:00:52 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-28 14:07:27 -0800
commit106bb07cff60057145b6eca38928951bd42dd9a7 (patch)
treef70e457b633c2aab266462fe048c09737245c700 /qt-mobile
parent30a4fb22748bda18c94027c4746f639cbab3ea71 (diff)
downloadsubsurface-106bb07cff60057145b6eca38928951bd42dd9a7.tar.gz
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>
Diffstat (limited to 'qt-mobile')
-rw-r--r--qt-mobile/qmlmanager.cpp18
1 files changed, 14 insertions, 4 deletions
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")))