diff options
author | Joakim Bygdell <j.bygdell@gmail.com> | 2016-01-25 18:44:52 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-25 11:14:33 -0800 |
commit | e0725966b1740f35c986466210bb384f1ece1b7f (patch) | |
tree | 086255f349accc94d1ed55fe5ed20350d096eb41 /qt-mobile | |
parent | 19588ce1399381129f86b4cc54e0c6522852e666 (diff) | |
download | subsurface-e072596.tar.gz |
QML UI: Add helper function to get weights
Helper function that retrieved the total weight for a dive to be displayed
on the DiveDetials page.
Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile')
-rw-r--r-- | qt-mobile/qml/DiveDetailsView.qml | 2 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 20 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.h | 1 |
3 files changed, 22 insertions, 1 deletions
diff --git a/qt-mobile/qml/DiveDetailsView.qml b/qt-mobile/qml/DiveDetailsView.qml index 6c333596c..df1d255a2 100644 --- a/qt-mobile/qml/DiveDetailsView.qml +++ b/qt-mobile/qml/DiveDetailsView.qml @@ -13,6 +13,7 @@ Item { id: detailsView property int labelWidth: MobileComponents.Units.gridUnit * 10 property string cylinder: manager.getCylinder(dive.id) + property string weight: manager.getWeights(dive.id) width: parent.width height: mainLayout.implicitHeight + MobileComponents.Units.iconSizes.large Rectangle { @@ -171,7 +172,6 @@ Item { MobileComponents.Label { id: txtWeight text: weight - Layout.fillWidth: true wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere Layout.alignment: Qt.AlignRight } diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index d2b5c4702..a4cfd5fd4 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -718,3 +718,23 @@ QString QMLManager::getCylinder(QString diveId) cylinder = d->cylinder[0].type.description; return cylinder; } + +QString QMLManager::getWeights(QString diveId) +{ + int dive_id = diveId.toInt(); + struct dive *d = get_dive_by_uniq_id(dive_id); + int weight = 0; + QString weights; + if (d){ + for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) + weight += d->weightsystem[i].weight.grams; + + if (informational_prefs.unit_system == IMPERIAL){ + weights = QString::number(grams_to_lbs(weight)) + " lbs"; + } + else { + weights = QString::number(weight/1000) + " kg"; + } + } + return weights; +} diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h index 57b67c24a..bcaf9c726 100644 --- a/qt-mobile/qmlmanager.h +++ b/qt-mobile/qmlmanager.h @@ -85,6 +85,7 @@ public slots: QString getDate(QString diveId); QString getCurrentPosition(); QString getCylinder(QString diveId); + QString getWeights(QString diveId); void deleteGpsFix(quint64 when); void refreshDiveList(); |