aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/divesitehelpers.cpp22
-rw-r--r--core/divesitehelpers.h14
2 files changed, 7 insertions, 29 deletions
diff --git a/core/divesitehelpers.cpp b/core/divesitehelpers.cpp
index 3f752a320..b77bc8fec 100644
--- a/core/divesitehelpers.cpp
+++ b/core/divesitehelpers.cpp
@@ -20,17 +20,7 @@
#include <QEventLoop>
#include <QTimer>
-ReverseGeoLookupThread* ReverseGeoLookupThread::instance()
-{
- static ReverseGeoLookupThread* self = new ReverseGeoLookupThread();
- return self;
-}
-
-ReverseGeoLookupThread::ReverseGeoLookupThread(QObject *obj) : QThread(obj)
-{
-}
-
-void ReverseGeoLookupThread::run()
+void reverseGeoLookup()
{
QNetworkRequest request;
QNetworkAccessManager *rgl = new QNetworkAccessManager();
@@ -41,7 +31,7 @@ void ReverseGeoLookupThread::run()
request.setRawHeader("Accept", "text/json");
request.setRawHeader("User-Agent", getUserAgent().toUtf8());
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
struct dive_site *ds = &displayed_dive_site;
@@ -50,7 +40,7 @@ void ReverseGeoLookupThread::run()
QNetworkReply *reply = rgl->get(request);
timer.setSingleShot(true);
- connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
timer.start(5000); // 5 secs. timeout
loop.exec();
@@ -119,13 +109,13 @@ void ReverseGeoLookupThread::run()
}
} else {
report_error("timeout accessing geonames.org");
- disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
reply->abort();
}
// next check the oceans API to figure out the body of water
request.setUrl(geonamesOceanURL.arg(uiLanguage(NULL).section(QRegExp("[-_ ]"), 0, 0)).arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0));
reply = rgl->get(request);
- connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
timer.start(5000); // 5 secs. timeout
loop.exec();
if (timer.isActive()) {
@@ -165,7 +155,7 @@ void ReverseGeoLookupThread::run()
}
} else {
report_error("timeout accessing geonames.org");
- disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
reply->abort();
}
diff --git a/core/divesitehelpers.h b/core/divesitehelpers.h
index 9227aa5c2..eabb156f4 100644
--- a/core/divesitehelpers.h
+++ b/core/divesitehelpers.h
@@ -2,18 +2,6 @@
#ifndef DIVESITEHELPERS_H
#define DIVESITEHELPERS_H
-#include "units.h"
-#include <QThread>
-
-class ReverseGeoLookupThread : public QThread {
-Q_OBJECT
-public:
- static ReverseGeoLookupThread *instance();
- void lookup(struct dive_site *ds);
- void run() override;
-
-private:
- ReverseGeoLookupThread(QObject *parent = 0);
-};
+void reverseGeoLookup();
#endif // DIVESITEHELPERS_H