summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/gettextfromc.cpp25
-rw-r--r--core/gettextfromc.h6
-rw-r--r--desktop-widgets/modeldelegates.cpp2
-rw-r--r--qt-models/cylindermodel.cpp2
-rw-r--r--qt-models/divelocationmodel.cpp2
5 files changed, 8 insertions, 29 deletions
diff --git a/core/gettextfromc.cpp b/core/gettextfromc.cpp
index e668fec2e..fdb1e6d37 100644
--- a/core/gettextfromc.cpp
+++ b/core/gettextfromc.cpp
@@ -1,28 +1,13 @@
// SPDX-License-Identifier: GPL-2.0
-#include <QCoreApplication>
-#include <QString>
#include "gettextfromc.h"
+#include <QHash>
-const char *gettextFromC::trGettext(const char *text)
+static QHash<QByteArray, QByteArray> translationCache;
+
+extern "C" const char *trGettext(const char *text)
{
QByteArray &result = translationCache[QByteArray(text)];
if (result.isEmpty())
- result = translationCache[QByteArray(text)] = trUtf8(text).toUtf8();
+ result = gettextFromC::tr(text).toUtf8();
return result.constData();
}
-
-void gettextFromC::reset(void)
-{
- translationCache.clear();
-}
-
-gettextFromC *gettextFromC::instance()
-{
- static gettextFromC self;
- return &self;
-}
-
-extern "C" const char *trGettext(const char *text)
-{
- return gettextFromC::instance()->trGettext(text);
-}
diff --git a/core/gettextfromc.h b/core/gettextfromc.h
index 5f22d8647..647ea52a8 100644
--- a/core/gettextfromc.h
+++ b/core/gettextfromc.h
@@ -2,18 +2,12 @@
#ifndef GETTEXTFROMC_H
#define GETTEXTFROMC_H
-#include <QHash>
#include <QCoreApplication>
extern "C" const char *trGettext(const char *text);
class gettextFromC {
Q_DECLARE_TR_FUNCTIONS(gettextFromC)
-public:
- static gettextFromC *instance();
- const char *trGettext(const char *text);
- void reset(void);
- QHash<QByteArray, QByteArray> translationCache;
};
#endif // GETTEXTFROMC_H
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp
index 8258c7d39..3af4b4f7a 100644
--- a/desktop-widgets/modeldelegates.cpp
+++ b/desktop-widgets/modeldelegates.cpp
@@ -301,7 +301,7 @@ QWidget *TankUseDelegate::createEditor(QWidget * parent, const QStyleOptionViewI
{
QComboBox *comboBox = new QComboBox(parent);
for (int i = 0; i < NUM_GAS_USE; i++)
- comboBox->addItem(gettextFromC::instance()->trGettext(cylinderuse_text[i]));
+ comboBox->addItem(gettextFromC::tr(cylinderuse_text[i]));
return comboBox;
}
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index 19302421e..9a093112c 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -222,7 +222,7 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
ret = get_depth_string(gas_mnd(&cyl->gasmix, prefs.bestmixend, &displayed_dive, M_OR_FT(1,1)), true);
break;
case USE:
- ret = gettextFromC::instance()->trGettext(cylinderuse_text[cyl->cylinder_use]);
+ ret = gettextFromC::tr(cylinderuse_text[cyl->cylinder_use]);
break;
}
break;
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index c706744a3..2e62997f9 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -176,7 +176,7 @@ GeoReferencingOptionsModel::GeoReferencingOptionsModel(QObject *parent) : QStrin
QStringList list;
int i;
for (i = 0; i < TC_NR_CATEGORIES; i++)
- list << gettextFromC::instance()->trGettext(taxonomy_category_names[i]);
+ list << gettextFromC::tr(taxonomy_category_names[i]);
setStringList(list);
}