mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Move helper function to DiveObjectsHelper
As per Tomaz recomendation the helper functions from19588ce
ande072596
are moved from qmlmanager to DiveObjectsHelper. [Dirk Hohndel: merged with the latest code] Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4abe73ff2a
commit
9342dedb26
5 changed files with 34 additions and 42 deletions
|
@ -243,3 +243,31 @@ int DiveObjectHelper::rating() const
|
|||
{
|
||||
return m_dive->rating;
|
||||
}
|
||||
|
||||
QString DiveObjectHelper::sumWeight() const
|
||||
{
|
||||
int sum = 0;
|
||||
QString sumWeight;
|
||||
for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++){
|
||||
sum += m_dive->weightsystem[i].weight.grams;
|
||||
}
|
||||
if (informational_prefs.unit_system == IMPERIAL){
|
||||
sumWeight = QString::number(grams_to_lbs(sum), 'f', 1) + " lbs";
|
||||
}
|
||||
else {
|
||||
sumWeight = QString::number(sum / 1000, 'f', 1) + " kg";
|
||||
}
|
||||
return sumWeight;
|
||||
}
|
||||
|
||||
QString DiveObjectHelper::getCylinder() const
|
||||
{
|
||||
QString getCylinder;
|
||||
if (m_dive->cylinder[1].type.description != NULL){
|
||||
getCylinder = QObject::tr("Multiple");
|
||||
}
|
||||
else {
|
||||
getCylinder = m_dive->cylinder[0].type.description;
|
||||
}
|
||||
return getCylinder;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue