core: create string-format.cpp source file

The mobile version of the list used string formatting functions
defined in DiveObjectHelper and declared in mobilelistmodels.h.
Very confusing. Move them to a separate source file where - in
the long run - all the string-formatting functions, which
are scattered all over the place, can be collected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Berthold Stoeger 2020-12-14 22:42:07 +01:00 committed by Dirk Hohndel
parent dc37ba7758
commit bf8261c001
7 changed files with 178 additions and 156 deletions

View file

@ -3,6 +3,7 @@
#include "core/divefilter.h"
#ifdef SUBSURFACE_MOBILE
#include "qt-models/mobilelistmodel.h"
#include "core/string-format.h"
#endif
#include "core/gettextfromc.h"
#include "core/metrics.h"
@ -225,11 +226,11 @@ QVariant DiveTripModelBase::diveData(const struct dive *d, int column, int role)
case MobileListModel::DiveSiteRole: return QVariant::fromValue(d->dive_site);
case MobileListModel::CylinderRole: return formatGetCylinder(d).join(", ");
case MobileListModel::GetCylinderRole: return formatGetCylinder(d);
case MobileListModel::CylinderListRole: return getFullCylinderList();
case MobileListModel::CylinderListRole: return formatFullCylinderList();
case MobileListModel::SingleWeightRole: return d->weightsystems.nr <= 1;
case MobileListModel::StartPressureRole: return getStartPressure(d);
case MobileListModel::EndPressureRole: return getEndPressure(d);
case MobileListModel::FirstGasRole: return getFirstGas(d);
case MobileListModel::StartPressureRole: return formatStartPressure(d);
case MobileListModel::EndPressureRole: return formatEndPressure(d);
case MobileListModel::FirstGasRole: return formatFirstGas(d);
case MobileListModel::SelectedRole: return d->selected;
case MobileListModel::DiveInTripRole: return d->divetrip != NULL;
case MobileListModel::IsInvalidRole: return d->invalid;