Skip to content

Commit 51922fc

Browse files
committedSep 12, 2017
Remove duplicate code
1 parent 42869bb commit 51922fc

File tree

4 files changed

+21
-87
lines changed

4 files changed

+21
-87
lines changed
 

‎src/core/qgsowsconnection.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
4545
QString key = "qgis/connections-" + mService.toLower() + '/' + mConnName;
4646
QString credentialsKey = "qgis/" + mService + '/' + mConnName;
4747

48-
QStringList connStringParts;
49-
5048
mConnectionInfo = settings.value( key + "/url" ).toString();
5149
mUri.setParam( QStringLiteral( "url" ), settings.value( key + "/url" ).toString() );
5250

@@ -67,10 +65,19 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
6765
}
6866
mConnectionInfo.append( ",authcfg=" + authcfg );
6967

68+
QString referer = settings.value( key + "/referer" ).toString();
69+
if ( !referer.isEmpty() )
70+
{
71+
mUri.setParam( QStringLiteral( "referer" ), referer );
72+
}
73+
7074
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
7175
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
7276
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
7377
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();
78+
bool smoothPixmapTransform = settings.value( key + "/smoothPixmapTransform", false ).toBool();
79+
QString dpiMode = settings.value( key + "/dpiMode", "all" ).toString();
80+
7481
if ( ignoreGetMap )
7582
{
7683
mUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), QStringLiteral( "1" ) );
@@ -87,6 +94,14 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
8794
{
8895
mUri.setParam( QStringLiteral( "InvertAxisOrientation" ), QStringLiteral( "1" ) );
8996
}
97+
if ( smoothPixmapTransform )
98+
{
99+
mUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), QStringLiteral( "1" ) );
100+
}
101+
if ( !dpiMode.isEmpty() )
102+
{
103+
mUri.setParam( QStringLiteral( "dpiMode" ), dpiMode );
104+
}
90105

91106
QgsDebugMsg( QString( "encoded uri: '%1'." ).arg( QString( mUri.encodedUri() ) ) );
92107
}

‎src/providers/wms/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ SET (WMS_SRCS
1212
SET (WMS_MOC_HDRS
1313
qgswmscapabilities.h
1414
qgswmsprovider.h
15-
qgswmsconnection.h
1615
qgswmsdataitems.h
1716
)
1817

‎src/providers/wms/qgswmsconnection.cpp

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -26,92 +26,18 @@
2626
#include "qgswmsconnection.h"
2727
#include "qgsnetworkaccessmanager.h"
2828
#include "qgssettings.h"
29+
#include "qgsowsconnection.h"
2930

3031
QgsWMSConnection::QgsWMSConnection( const QString &connName )
31-
: mConnName( connName )
32+
: QgsOwsConnection( QStringLiteral( "WMS" ), connName )
3233
{
33-
QgsDebugMsg( "theConnName = " + connName );
34-
35-
QgsSettings settings;
36-
37-
QString key = "qgis/connections-wms/" + mConnName;
38-
QString credentialsKey = "qgis/WMS/" + mConnName;
39-
40-
QStringList connStringParts;
41-
42-
mUri.setParam( QStringLiteral( "url" ), settings.value( key + "/url" ).toString() );
43-
44-
// Check for credentials and prepend to the connection info
45-
QString username = settings.value( credentialsKey + "/username" ).toString();
46-
QString password = settings.value( credentialsKey + "/password" ).toString();
47-
if ( !username.isEmpty() )
48-
{
49-
mUri.setParam( QStringLiteral( "username" ), username );
50-
mUri.setParam( QStringLiteral( "password" ), password );
51-
}
52-
53-
QString authcfg = settings.value( credentialsKey + "/authcfg" ).toString();
54-
if ( !authcfg.isEmpty() )
55-
{
56-
mUri.setParam( QStringLiteral( "authcfg" ), authcfg );
57-
}
58-
59-
QString referer = settings.value( key + "/referer" ).toString();
60-
if ( !referer.isEmpty() )
61-
{
62-
mUri.setParam( QStringLiteral( "referer" ), referer );
63-
}
64-
65-
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
66-
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
67-
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
68-
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();
69-
bool smoothPixmapTransform = settings.value( key + "/smoothPixmapTransform", false ).toBool();
70-
QString dpiMode = settings.value( key + "/dpiMode", "all" ).toString();
71-
72-
if ( ignoreGetMap )
73-
{
74-
mUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), QStringLiteral( "1" ) );
75-
}
76-
77-
if ( ignoreGetFeatureInfo )
78-
{
79-
mUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), QStringLiteral( "1" ) );
80-
}
81-
82-
if ( ignoreAxisOrientation )
83-
{
84-
mUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), QStringLiteral( "1" ) );
85-
}
86-
87-
if ( invertAxisOrientation )
88-
{
89-
mUri.setParam( QStringLiteral( "InvertAxisOrientation" ), QStringLiteral( "1" ) );
90-
}
91-
92-
if ( smoothPixmapTransform )
93-
{
94-
mUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), QStringLiteral( "1" ) );
95-
}
96-
97-
if ( !dpiMode.isEmpty() )
98-
{
99-
mUri.setParam( QStringLiteral( "dpiMode" ), dpiMode );
100-
}
101-
102-
QgsDebugMsg( QString( "encodedUri: '%1'." ).arg( QString( mUri.encodedUri() ) ) );
10334
}
10435

10536
QgsWMSConnection::~QgsWMSConnection()
10637
{
10738

10839
}
10940

110-
QgsDataSourceUri QgsWMSConnection::uri()
111-
{
112-
return mUri;
113-
}
114-
11541
QStringList QgsWMSConnection::connectionList()
11642
{
11743
QgsSettings settings;

‎src/providers/wms/qgswmsconnection.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,14 @@
1818
#ifndef QGSWMSCONNECTION_H
1919
#define QGSWMSCONNECTION_H
2020

21-
#include "qgsdatasourceuri.h"
22-
21+
#include "qgsowsconnection.h"
2322
#include <QStringList>
2423

2524
/*!
2625
* \brief Connections management
2726
*/
28-
class QgsWMSConnection : public QObject
27+
class QgsWMSConnection : public QgsOwsConnection
2928
{
30-
Q_OBJECT
3129

3230
public:
3331
//! Constructor
@@ -42,10 +40,6 @@ class QgsWMSConnection : public QObject
4240
static QString selectedConnection();
4341
static void setSelectedConnection( const QString &name );
4442

45-
public:
46-
QString mConnName;
47-
QgsDataSourceUri uri();
48-
QgsDataSourceUri mUri;
4943
};
5044

5145
#endif // QGSWMSCONNECTION_H

0 commit comments

Comments
 (0)
Please sign in to comment.