aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-09-29 22:45:21 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-10-03 10:01:13 -0700
commitf4ee8934243d6c924d810b5b2ec5a6c1f3b492f8 (patch)
tree7064f6aac9a344cb5daf54424d8cdf3c8b3a96af /core
parent06c35026d650e2d35f4007012879b37672508e32 (diff)
downloadsubsurface-f4ee8934243d6c924d810b5b2ec5a6c1f3b492f8.tar.gz
cleanup: replace get_trip_date_string() by get_trip_string()
The get_trip_date_string() formatted, as the name implies, the date of a trip. It was passed a number of parameters and had only one caller, which would also add the location if it existed. Therefore, move all that logic into the helper function and name it get_trip_string(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/qthelper.cpp14
-rw-r--r--core/qthelper.h3
2 files changed, 13 insertions, 4 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index f8c06d755..25c5fd7ce 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1018,15 +1018,23 @@ extern "C" char *get_current_date()
return copy_qstring(current_date);
}
-QString get_trip_date_string(timestamp_t when, int nr, bool getday)
+QString get_trip_string(const dive_trip *trip)
{
+ if (!trip)
+ return QString();
+
+ int nr = trip->dives.nr;
+ timestamp_t when = trip_date(trip);
+ bool getday = trip_is_single_day(trip);
+
QDateTime localTime = timestampToDateTime(when);
+ QString prefix = !empty_string(trip->location) ? QString(trip->location) + ", " : QString();
QString suffix = " " + gettextFromC::tr("(%n dive(s))", "", nr);
if (getday)
- return loc.toString(localTime, prefs.date_format) + suffix;
+ return prefix + loc.toString(localTime, prefs.date_format) + suffix;
else
- return loc.toString(localTime, "MMM yyyy") + suffix;
+ return prefix + loc.toString(localTime, "MMM yyyy") + suffix;
}
static QMutex hashOfMutex;
diff --git a/core/qthelper.h b/core/qthelper.h
index b703a38b4..9ea51f312 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -8,6 +8,7 @@
#include "subsurface-time.h"
struct picture;
+struct dive_trip;
// 1) Types
@@ -79,7 +80,7 @@ QString get_dive_date_string(timestamp_t when);
QString get_first_dive_date_string();
QString get_last_dive_date_string();
QString get_short_dive_date_string(timestamp_t when);
-QString get_trip_date_string(timestamp_t when, int nr, bool getday);
+QString get_trip_string(const dive_trip *trip);
QString getUiLanguage();
void initUiLanguage();
QLocale getLocale();