core: move total_weight() into struct dive

Feels natural in a C++ code base.

Change the function to return a weight_t. Sadly, use of the
units.h types is very inconsistent and many parts of the code
use int or double instead. So let's try to make this consistent.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-30 11:13:39 +02:00 committed by bstoeger
parent df1affc25b
commit d36fd79527
9 changed files with 22 additions and 34 deletions

View file

@ -183,7 +183,7 @@ static QString displaySac(const struct dive *d, bool units)
static QString displayWeight(const struct dive *d, bool units)
{
QString s = weight_string(total_weight(d));
QString s = get_weight_string(d->total_weight(), false);
if (!units)
return s;
else if (get_units()->weight == units::KG)
@ -1737,7 +1737,7 @@ bool DiveTripModelList::lessThan(const QModelIndex &i1, const QModelIndex &i2) c
case TEMPERATURE:
return lessThanHelper(d1->watertemp.mkelvin - d2->watertemp.mkelvin, row_diff);
case TOTALWEIGHT:
return lessThanHelper(total_weight(d1) - total_weight(d2), row_diff);
return lessThanHelper(d1->total_weight().grams - d2->total_weight().grams, row_diff);
case SUIT:
return lessThanHelper(strCmp(d1->suit, d2->suit), row_diff);
case CYLINDER: