summaryrefslogtreecommitdiffstats
path: root/qt-mobile/qmlmanager.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-05 22:54:47 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-05 22:54:47 -0800
commita4ec5206017b668842d2b9b317300b94dcb43057 (patch)
tree1adb3927c00ad39336b21da2f300cdbcae6b877f /qt-mobile/qmlmanager.cpp
parentad7fb80d0ac874e55ce91e5845f85aa12906941f (diff)
downloadsubsurface-a4ec5206017b668842d2b9b317300b94dcb43057.tar.gz
QML UI: enable editing of weight
But only if there is only one weight system defined in the dive. Otherwise display a read only text that explains that this cannot be edited. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r--qt-mobile/qmlmanager.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index f71e15100..bc0c99f4a 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -329,7 +329,7 @@ void QMLManager::refreshDiveList()
// update the dive and return the notes field, stripped of the HTML junk
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 weight, QString notes)
{
#define DROP_EMPTY_PLACEHOLDER(_s) if ((_s) == QLatin1Literal("--")) (_s).clear()
@@ -341,6 +341,7 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
DROP_EMPTY_PLACEHOLDER(suit);
DROP_EMPTY_PLACEHOLDER(buddy);
DROP_EMPTY_PLACEHOLDER(diveMaster);
+ DROP_EMPTY_PLACEHOLDER(weight);
DROP_EMPTY_PLACEHOLDER(notes);
#undef DROP_EMPTY_PLACEHOLDER
@@ -470,6 +471,18 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
prefs.units.temperature = units::FAHRENHEIT;
d->watertemp.mkelvin = parseTemperatureToMkelvin(watertemp);
}
+ // not sure what we'd do if there was more than one weight system
+ // defined - for now just ignore that case
+ if (weightsystem_none((void *)&d->weightsystem[1])) {
+ if (get_weight_string(d->weightsystem[0].weight, true) != weight) {
+ diveChanged = true;
+ if (weight.contains(tr("kg")))
+ prefs.units.weight = units::KG;
+ else if (weight.contains(tr("lbs")))
+ prefs.units.weight = units::LBS;
+ d->weightsystem[0].weight.grams = parseWeightToGrams(weight);
+ }
+ }
if (!same_string(d->suit, qPrintable(suit))) {
diveChanged = true;
free(d->suit);