summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-07-03 16:52:20 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-04 05:33:31 +0800
commit57c01f7a66ccd04fc2e83b67a840519db4661798 (patch)
tree4134dd2be823ea62ab3370cfb7ee567a6a53d4ec /core
parent2f951413303e10a80e540cacd0c6c282f8ce82cc (diff)
downloadsubsurface-57c01f7a66ccd04fc2e83b67a840519db4661798.tar.gz
Translations: unify gettextFromC::tr() and QObject::tr()
There were two catch-all classes for translations outside of class context. gettextFromC was used exclusively from C, but C++ used both, gettextFromC and QObject. Some of the string were even present in both. Therefore, unify to gettextFromC throughout the code base. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divelogexportlogic.cpp4
-rw-r--r--core/divesite-helper.cpp5
-rw-r--r--core/gpslocation.h2
-rw-r--r--core/qthelper.cpp40
-rw-r--r--core/qthelper.h3
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp4
6 files changed, 30 insertions, 28 deletions
diff --git a/core/divelogexportlogic.cpp b/core/divelogexportlogic.cpp
index 7617e6c23..82c8b452f 100644
--- a/core/divelogexportlogic.cpp
+++ b/core/divelogexportlogic.cpp
@@ -53,7 +53,7 @@ static void exportHTMLstatisticsTotal(QTextStream &out, stats_t *total_stats)
out << "\"YEAR\":\"Total\",";
out << "\"DIVES\":\"" << total_stats->selection_size << "\",";
out << "\"TOTAL_TIME\":\"" << get_dive_duration_string(total_stats->total_time.seconds,
- QObject::tr("h"), QObject::tr("min"), QObject::tr("sec"), " ") << "\",";
+ gettextFromC::tr("h"), gettextFromC::tr("min"), gettextFromC::tr("sec"), " ") << "\",";
out << "\"AVERAGE_TIME\":\"--\",";
out << "\"SHORTEST_TIME\":\"--\",";
out << "\"LONGEST_TIME\":\"--\",";
@@ -89,7 +89,7 @@ static void exportHTMLstatistics(const QString filename, struct htmlExportSettin
out << "\"YEAR\":\"" << stats_yearly[i].period << "\",";
out << "\"DIVES\":\"" << stats_yearly[i].selection_size << "\",";
out << "\"TOTAL_TIME\":\"" << get_dive_duration_string(stats_yearly[i].total_time.seconds,
- QObject::tr("h"), QObject::tr("min"), QObject::tr("sec"), " ") << "\",";
+ gettextFromC::tr("h"), gettextFromC::tr("min"), gettextFromC::tr("sec"), " ") << "\",";
out << "\"AVERAGE_TIME\":\"" << get_minutes(stats_yearly[i].total_time.seconds / stats_yearly[i].selection_size) << "\",";
out << "\"SHORTEST_TIME\":\"" << get_minutes(stats_yearly[i].shortest_time.seconds) << "\",";
out << "\"LONGEST_TIME\":\"" << get_minutes(stats_yearly[i].longest_time.seconds) << "\",";
diff --git a/core/divesite-helper.cpp b/core/divesite-helper.cpp
index 56030afd1..55ebb3aba 100644
--- a/core/divesite-helper.cpp
+++ b/core/divesite-helper.cpp
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "divesite.h"
#include "pref.h"
+#include "gettextfromc.h"
QString constructLocationTags(struct dive_site *ds, bool for_maintab)
{
@@ -17,7 +18,7 @@ QString constructLocationTags(struct dive_site *ds, bool for_maintab)
}
if (!prefs_set && !for_maintab) {
- locationTag = QString("<small><small>") + QObject::tr("No dive site layout categories set in preferences!") +
+ locationTag = QString("<small><small>") + gettextFromC::tr("No dive site layout categories set in preferences!") +
QString("</small></small>");
return locationTag;
}
@@ -25,7 +26,7 @@ QString constructLocationTags(struct dive_site *ds, bool for_maintab)
return locationTag;
if (for_maintab)
- locationTag = QString("<small><small>(") + QObject::tr("Tags") + QString(": ");
+ locationTag = QString("<small><small>(") + gettextFromC::tr("Tags") + QString(": ");
else
locationTag = QString("<small><small>");
QString connector;
diff --git a/core/gpslocation.h b/core/gpslocation.h
index fb4f4c802..b277091a3 100644
--- a/core/gpslocation.h
+++ b/core/gpslocation.h
@@ -11,7 +11,7 @@
#include <QNetworkReply>
#include <QMap>
-#define GPS_CURRENT_POS QObject::tr("Waiting to aquire GPS location")
+#define GPS_CURRENT_POS gettextFromC::tr("Waiting to aquire GPS location")
struct gpsTracker {
degrees_t latitude;
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index a6125526b..299f8771b 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -762,9 +762,9 @@ int parseLengthToMm(const QString &text)
if (numOnly.isEmpty())
return 0;
double number = numOnly.toDouble();
- if (text.contains(QObject::tr("m"), Qt::CaseInsensitive)) {
+ if (text.contains(gettextFromC::tr("m"), Qt::CaseInsensitive)) {
mm = lrint(number * 1000);
- } else if (text.contains(QObject::tr("ft"), Qt::CaseInsensitive)) {
+ } else if (text.contains(gettextFromC::tr("ft"), Qt::CaseInsensitive)) {
mm = feet_to_mm(number);
} else {
switch (prefs.units.length) {
@@ -790,9 +790,9 @@ int parseTemperatureToMkelvin(const QString &text)
if (numOnly.isEmpty())
return 0;
double number = numOnly.toDouble();
- if (text.contains(QObject::tr("C"), Qt::CaseInsensitive)) {
+ if (text.contains(gettextFromC::tr("C"), Qt::CaseInsensitive)) {
mkelvin = C_to_mkelvin(number);
- } else if (text.contains(QObject::tr("F"), Qt::CaseInsensitive)) {
+ } else if (text.contains(gettextFromC::tr("F"), Qt::CaseInsensitive)) {
mkelvin = F_to_mkelvin(number);
} else {
switch (prefs.units.temperature) {
@@ -817,9 +817,9 @@ int parseWeightToGrams(const QString &text)
if (numOnly.isEmpty())
return 0;
double number = numOnly.toDouble();
- if (text.contains(QObject::tr("kg"), Qt::CaseInsensitive)) {
+ if (text.contains(gettextFromC::tr("kg"), Qt::CaseInsensitive)) {
grams = lrint(number * 1000);
- } else if (text.contains(QObject::tr("lbs"), Qt::CaseInsensitive)) {
+ } else if (text.contains(gettextFromC::tr("lbs"), Qt::CaseInsensitive)) {
grams = lbs_to_grams(number);
} else {
switch (prefs.units.weight) {
@@ -844,9 +844,9 @@ int parsePressureToMbar(const QString &text)
if (numOnly.isEmpty())
return 0;
double number = numOnly.toDouble();
- if (text.contains(QObject::tr("bar"), Qt::CaseInsensitive)) {
+ if (text.contains(gettextFromC::tr("bar"), Qt::CaseInsensitive)) {
mbar = lrint(number * 1000);
- } else if (text.contains(QObject::tr("psi"), Qt::CaseInsensitive)) {
+ } else if (text.contains(gettextFromC::tr("psi"), Qt::CaseInsensitive)) {
mbar = psi_to_mbar(number);
} else {
switch (prefs.units.pressure) {
@@ -867,9 +867,9 @@ int parseGasMixO2(const QString &text)
{
QString gasString = text;
int o2, number;
- if (gasString.contains(QObject::tr("AIR"), Qt::CaseInsensitive)) {
+ if (gasString.contains(gettextFromC::tr("AIR"), Qt::CaseInsensitive)) {
o2 = O2_IN_AIR;
- } else if (gasString.contains(QObject::tr("EAN"), Qt::CaseInsensitive)) {
+ } else if (gasString.contains(gettextFromC::tr("EAN"), Qt::CaseInsensitive)) {
gasString.remove(QRegExp("[^0-9]"));
number = gasString.toInt();
o2 = number * 10;
@@ -1007,7 +1007,7 @@ QString get_trip_date_string(timestamp_t when, int nr, bool getday)
localTime.setTimeSpec(Qt::UTC);
QString ret ;
- QString suffix = " " + QObject::tr("(%n dive(s))", "", nr);
+ QString suffix = " " + gettextFromC::tr("(%n dive(s))", "", nr);
if (getday) {
ret = localTime.date().toString(prefs.date_format) + suffix;
} else {
@@ -1235,7 +1235,7 @@ extern "C" char *picturedir_string()
QString get_gas_string(struct gasmix gas)
{
uint o2 = (get_o2(&gas) + 5) / 10, he = (get_he(&gas) + 5) / 10;
- QString result = gasmix_is_air(&gas) ? QObject::tr("AIR") : he == 0 ? (o2 == 100 ? QObject::tr("OXYGEN") : QString("EAN%1").arg(o2, 2, 10, QChar('0'))) : QString("%1/%2").arg(o2).arg(he);
+ QString result = gasmix_is_air(&gas) ? gettextFromC::tr("AIR") : he == 0 ? (o2 == 100 ? gettextFromC::tr("OXYGEN") : QString("EAN%1").arg(o2, 2, 10, QChar('0'))) : QString("%1/%2").arg(o2).arg(he);
return result;
}
@@ -1258,8 +1258,8 @@ weight_t string_to_weight(const char *str)
const char *end;
double value = strtod_flags(str, &end, 0);
QString rest = QString(end).trimmed();
- QString local_kg = QObject::tr("kg");
- QString local_lbs = QObject::tr("lbs");
+ QString local_kg = gettextFromC::tr("kg");
+ QString local_lbs = gettextFromC::tr("lbs");
weight_t weight;
if (rest.startsWith("kg") || rest.startsWith(local_kg))
@@ -1282,8 +1282,8 @@ depth_t string_to_depth(const char *str)
const char *end;
double value = strtod_flags(str, &end, 0);
QString rest = QString(end).trimmed();
- QString local_ft = QObject::tr("ft");
- QString local_m = QObject::tr("m");
+ QString local_ft = gettextFromC::tr("ft");
+ QString local_m = gettextFromC::tr("m");
depth_t depth;
if (value < 0)
@@ -1307,8 +1307,8 @@ pressure_t string_to_pressure(const char *str)
const char *end;
double value = strtod_flags(str, &end, 0);
QString rest = QString(end).trimmed();
- QString local_psi = QObject::tr("psi");
- QString local_bar = QObject::tr("bar");
+ QString local_psi = gettextFromC::tr("psi");
+ QString local_bar = gettextFromC::tr("bar");
pressure_t pressure;
if (rest.startsWith("bar") || rest.startsWith(local_bar))
@@ -1330,8 +1330,8 @@ volume_t string_to_volume(const char *str, pressure_t workp)
const char *end;
double value = strtod_flags(str, &end, 0);
QString rest = QString(end).trimmed();
- QString local_l = QObject::tr("l");
- QString local_cuft = QObject::tr("cuft");
+ QString local_l = gettextFromC::tr("l");
+ QString local_cuft = gettextFromC::tr("cuft");
volume_t volume;
if (rest.startsWith("l") || rest.startsWith("ℓ") || rest.startsWith(local_l))
diff --git a/core/qthelper.h b/core/qthelper.h
index 2bd933e0f..64a57798d 100644
--- a/core/qthelper.h
+++ b/core/qthelper.h
@@ -18,6 +18,7 @@ enum inertgas {N2, HE};
#include <QString>
#include <QTranslator>
#include <QDir>
+#include "core/gettextfromc.h"
QString weight_string(int weight_in_grams);
QString distance_string(int distanceInMeters);
bool gpsHasChanged(struct dive *dive, struct dive *master, const QString &gps_text, bool *parsed_out = 0);
@@ -69,7 +70,7 @@ int parsePressureToMbar(const QString &text);
int parseGasMixO2(const QString &text);
int parseGasMixHE(const QString &text);
QString render_seconds_to_string(int seconds);
-QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = QObject::tr("sec"), QString separator = ":", bool isFreeDive = false);
+QString get_dive_duration_string(timestamp_t when, QString hoursText, QString minutesText, QString secondsText = gettextFromC::tr("sec"), QString separator = ":", bool isFreeDive = false);
QString get_dive_surfint_string(timestamp_t when, QString daysText, QString hoursText, QString minutesText, QString separator = " ", int maxdays = 4);
QString get_dive_date_string(timestamp_t when);
QString get_short_dive_date_string(timestamp_t when);
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index 46f274522..4c5a30912 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -27,7 +27,7 @@ static QString getFormattedCylinder(struct dive *dive, unsigned int idx)
const char *desc = cyl->type.description;
if (!desc && idx > 0)
return QString(EMPTY_DIVE_STRING);
- QString fmt = desc ? QString(desc) : QObject::tr("unknown");
+ QString fmt = desc ? QString(desc) : gettextFromC::tr("unknown");
fmt += ", " + get_volume_string(cyl->type.size, true);
fmt += ", " + get_pressure_string(cyl->type.workingpressure, true);
fmt += ", " + get_pressure_string(cyl->start, false) + " - " + get_pressure_string(cyl->end, true);
@@ -129,7 +129,7 @@ QVariant DiveObjectHelper::dive_site_uuid() const
QString DiveObjectHelper::duration() const
{
- return get_dive_duration_string(m_dive->duration.seconds, QObject::tr("h"), QObject::tr("min"));
+ return get_dive_duration_string(m_dive->duration.seconds, gettextFromC::tr("h"), gettextFromC::tr("min"));
}
bool DiveObjectHelper::noDive() const