summaryrefslogtreecommitdiffstats
path: root/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-02 16:15:17 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-12-02 16:17:35 -0800
commit917b47b79cb8accbedd2c49c569aaafb728914c5 (patch)
tree6ed7e80085626d24c85207876b12f9a4e2596c2b /qthelper.cpp
parenta529285e9eab823c9027af0b86ac21b2aef290e8 (diff)
downloadsubsurface-917b47b79cb8accbedd2c49c569aaafb728914c5.tar.gz
Parse localized GPS string
Let's ALWAYS support the somewhat "international standard" N/S/W/E characters, but ALSO support localized versions. Fixes #315 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r--qthelper.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/qthelper.cpp b/qthelper.cpp
index 00412b224..273bfd4b4 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -1,7 +1,9 @@
#include "qthelper.h"
+#include "qt-ui/mainwindow.h"
#include <QRegExp>
#include <QDebug>
+#define tr(_arg) mainWindow()->information()->tr(_arg)
DiveComputerList::DiveComputerList()
{
@@ -105,7 +107,9 @@ bool parseGpsText(const QString& gps_text, double *latitude, double *longitude)
*longitude = 0.0;
return true;
}
- QRegExp r("\\s*([SN])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)\\.(\\d+)[^EW]*([EW])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)\\.(\\d+)");
+ QString regExp = QString("\\s*([NS%1%2])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)\\.(\\d+)[^EW%3%4]*([EW%6%7])\\s*(\\d+)[" UTF8_DEGREE "\\s]+(\\d+)\\.(\\d+)")
+ .arg(tr("N")).arg(tr("S")).arg(tr("E")).arg(tr("W")).arg(tr("E")).arg(tr("W"));
+ QRegExp r(regExp);
if (r.indexIn(gps_text) != 8) {
// qDebug() << "Hemisphere" << r.cap(1) << "deg" << r.cap(2) << "min" << r.cap(3) << "decimal" << r.cap(4);
// qDebug() << "Hemisphere" << r.cap(5) << "deg" << r.cap(6) << "min" << r.cap(7) << "decimal" << r.cap(8);