The arrached patch makes the username for geonames.org requests
configurable.
Regards,
Michael
From 2991cdb27f604b7370061bf6cb41dcfbd8c91740 Mon Sep 17 00:00:00 2001
From: Michael Klein <[email protected]>
Date: Mon, 12 Mar 2012 22:50:29 +0100
Subject: [PATCH] make username for geonames.org configurable
---
src/CDlgConfig.cpp | 9 +++++----
src/CResources.cpp | 10 ++++++++++
src/CResources.h | 5 +++++
src/CTrack.cpp | 2 +-
src/IDlgConfig.ui | 25 ++++++++++++++++++++++++-
5 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/src/CDlgConfig.cpp b/src/CDlgConfig.cpp
index 7bc13be..699a0df 100644
--- a/src/CDlgConfig.cpp
+++ b/src/CDlgConfig.cpp
@@ -71,6 +71,7 @@ void CDlgConfig::exec()
checkProxy->setChecked(resources.m_useHttpProxy);
lineProxyURL->setText(resources.m_httpProxy);
lineProxyPort->setText(QString("%1").arg(resources.m_httpProxyPort));
+ lineGeonamesOrgUsername->setText(resources.m_geonamesOrgUsername);
labelFont->setFont(resources.m_mapfont);
if(resources.unit->type == "metric")
@@ -103,7 +104,6 @@ void CDlgConfig::exec()
labelPathGeoDB->setText(resources.m_pathGeoDB.absolutePath());
#endif
-
comboDevice->addItem(tr(""),"");
comboDevice->addItem(tr("QLandkarte M"), "QLandkarteM");
comboDevice->addItem(tr("Garmin"), "Garmin");
@@ -160,9 +160,10 @@ void CDlgConfig::accept()
{
CResources& resources = CResources::self();
- resources.m_useHttpProxy = checkProxy->isChecked();
- resources.m_httpProxy = lineProxyURL->text();
- resources.m_httpProxyPort = lineProxyPort->text().toUInt();
+ resources.m_useHttpProxy = checkProxy->isChecked();
+ resources.m_httpProxy = lineProxyURL->text();
+ resources.m_httpProxyPort = lineProxyPort->text().toUInt();
+ resources.m_geonamesOrgUsername = lineGeonamesOrgUsername->text();
if(resources.m_useHttpProxy)
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy,resources.m_httpProxy,resources.m_httpProxyPort));
diff --git a/src/CResources.cpp b/src/CResources.cpp
index 10c8bc3..6996aa1 100644
--- a/src/CResources.cpp
+++ b/src/CResources.cpp
@@ -53,6 +53,7 @@ CResources::CResources(QObject * parent)
, pathMaps("./")
, m_useHttpProxy(false)
, m_httpProxyPort(8080)
+, m_geonamesOrgUsername("demo")
, time_offset(0)
, m_device(0)
, m_devIPPort(4242)
@@ -109,6 +110,8 @@ CResources::CResources(QObject * parent)
else
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::NoProxy));
+ m_geonamesOrgUsername =
cfg.value("geonames.org/username",m_geonamesOrgUsername).toString();
+
m_devKey = cfg.value("device/key",m_devKey).toString();
m_devIPAddress = cfg.value("device/ipAddr",m_devIPAddress).toString();
m_devIPPort = cfg.value("device/ipPort",m_devIPPort).toUInt();
@@ -222,6 +225,7 @@ CResources::~CResources()
cfg.setValue("network/proxy/url",m_httpProxy);
cfg.setValue("network/proxy/port",m_httpProxyPort);
+ cfg.setValue("geonames.org/username",m_geonamesOrgUsername);
cfg.setValue("device/key",m_devKey);
cfg.setValue("device/ipAddr",m_devIPAddress);
@@ -281,6 +285,12 @@ bool CResources::getHttpProxy(QString& url, quint16& port)
}
+const QString & CResources::geonamesOrgUsername() const
+{
+ return m_geonamesOrgUsername;
+}
+
+
IDevice * CResources::device()
{
// purge device if the key does not match
diff --git a/src/CResources.h b/src/CResources.h
index 65dd115..6ba27aa 100644
--- a/src/CResources.h
+++ b/src/CResources.h
@@ -46,6 +46,8 @@ class CResources : public QObject
*/
bool getHttpProxy(QString& url, quint16& port);
+ const QString & geonamesOrgUsername() const;
+
/// get pointer to current device handler
IDevice * device();
QString charset();
@@ -103,6 +105,9 @@ class CResources : public QObject
/// the proxy port
quint16 m_httpProxyPort;
+ /// geonames.org username
+ QString m_geonamesOrgUsername;
+
/// font used by the map
QFont m_mapfont;
diff --git a/src/CTrack.cpp b/src/CTrack.cpp
index a822e25..31093b0 100644
--- a/src/CTrack.cpp
+++ b/src/CTrack.cpp
@@ -607,7 +607,7 @@ void CTrack::replaceElevationByRemote()
url.setPath("/srtm3");
url.addQueryItem("lats",lats.join(","));
url.addQueryItem("lngs",lngs.join(","));
- url.addQueryItem("username","demo");
+ url.addQueryItem("username",CResources::self().geonamesOrgUsername());
id = geonames->get(url.toEncoded( ));
id2idx[id] = idx;
diff --git a/src/IDlgConfig.ui b/src/IDlgConfig.ui
index 75dc160..e3a79c0 100644
--- a/src/IDlgConfig.ui
+++ b/src/IDlgConfig.ui
@@ -17,7 +17,7 @@
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
- <number>3</number>
+ <number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
@@ -420,6 +420,29 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="groupBoxGeonamesOrg">
+ <property name="title">
+ <string>geonames.org</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_6">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="lineGeonamesOrgUsername"/>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="groupBoxGeoDB">
<property name="enabled">
<bool>true</bool>
--
1.7.9
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Qlandkartegt-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users