From bf8261c0014253634eaddf7c0a9cf79d3a8b4123 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Mon, 14 Dec 2020 22:42:07 +0100 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-models/divetripmodel.cpp | 9 +++++---- qt-models/mobilelistmodel.h | 10 ---------- 2 files changed, 5 insertions(+), 14 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 6b700a92e..52ad937f5 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -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; diff --git a/qt-models/mobilelistmodel.h b/qt-models/mobilelistmodel.h index e18481efc..5c03a02a7 100644 --- a/qt-models/mobilelistmodel.h +++ b/qt-models/mobilelistmodel.h @@ -186,14 +186,4 @@ private: MobileSwipeModel sm; }; -// Helper functions - these are actually defined in DiveObjectHelper.cpp. Why declare them here? -QString formatSac(const dive *d); -QString formatNotes(const dive *d); -QString format_gps_decimal(const dive *d); -QStringList formatGetCylinder(const dive *d); -QStringList getStartPressure(const dive *d); -QStringList getEndPressure(const dive *d); -QStringList getFirstGas(const dive *d); -QStringList getFullCylinderList(); - #endif -- cgit v1.2.3-70-g09d2