mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
19588ce139
commit
e0725966b1
3 changed files with 22 additions and 1 deletions
|
@ -13,6 +13,7 @@ Item {
|
||||||
id: detailsView
|
id: detailsView
|
||||||
property int labelWidth: MobileComponents.Units.gridUnit * 10
|
property int labelWidth: MobileComponents.Units.gridUnit * 10
|
||||||
property string cylinder: manager.getCylinder(dive.id)
|
property string cylinder: manager.getCylinder(dive.id)
|
||||||
|
property string weight: manager.getWeights(dive.id)
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: mainLayout.implicitHeight + MobileComponents.Units.iconSizes.large
|
height: mainLayout.implicitHeight + MobileComponents.Units.iconSizes.large
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
@ -171,7 +172,6 @@ Item {
|
||||||
MobileComponents.Label {
|
MobileComponents.Label {
|
||||||
id: txtWeight
|
id: txtWeight
|
||||||
text: weight
|
text: weight
|
||||||
Layout.fillWidth: true
|
|
||||||
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
wrapMode: TextEdit.WrapAtWordBoundaryOrAnywhere
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
}
|
||||||
|
|
|
@ -718,3 +718,23 @@ QString QMLManager::getCylinder(QString diveId)
|
||||||
cylinder = d->cylinder[0].type.description;
|
cylinder = d->cylinder[0].type.description;
|
||||||
return cylinder;
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -85,6 +85,7 @@ public slots:
|
||||||
QString getDate(QString diveId);
|
QString getDate(QString diveId);
|
||||||
QString getCurrentPosition();
|
QString getCurrentPosition();
|
||||||
QString getCylinder(QString diveId);
|
QString getCylinder(QString diveId);
|
||||||
|
QString getWeights(QString diveId);
|
||||||
void deleteGpsFix(quint64 when);
|
void deleteGpsFix(quint64 when);
|
||||||
void refreshDiveList();
|
void refreshDiveList();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue