mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Remove duplicate code
This commit is contained in:
parent
42869bb92c
commit
51922fc74c
@ -45,8 +45,6 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
|
||||
QString key = "qgis/connections-" + mService.toLower() + '/' + mConnName;
|
||||
QString credentialsKey = "qgis/" + mService + '/' + mConnName;
|
||||
|
||||
QStringList connStringParts;
|
||||
|
||||
mConnectionInfo = settings.value( key + "/url" ).toString();
|
||||
mUri.setParam( QStringLiteral( "url" ), settings.value( key + "/url" ).toString() );
|
||||
|
||||
@ -67,10 +65,19 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
|
||||
}
|
||||
mConnectionInfo.append( ",authcfg=" + authcfg );
|
||||
|
||||
QString referer = settings.value( key + "/referer" ).toString();
|
||||
if ( !referer.isEmpty() )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "referer" ), referer );
|
||||
}
|
||||
|
||||
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
|
||||
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
|
||||
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
|
||||
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();
|
||||
bool smoothPixmapTransform = settings.value( key + "/smoothPixmapTransform", false ).toBool();
|
||||
QString dpiMode = settings.value( key + "/dpiMode", "all" ).toString();
|
||||
|
||||
if ( ignoreGetMap )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), QStringLiteral( "1" ) );
|
||||
@ -87,6 +94,14 @@ QgsOwsConnection::QgsOwsConnection( const QString &service, const QString &connN
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "InvertAxisOrientation" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
if ( smoothPixmapTransform )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
if ( !dpiMode.isEmpty() )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "dpiMode" ), dpiMode );
|
||||
}
|
||||
|
||||
QgsDebugMsg( QString( "encoded uri: '%1'." ).arg( QString( mUri.encodedUri() ) ) );
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ SET (WMS_SRCS
|
||||
SET (WMS_MOC_HDRS
|
||||
qgswmscapabilities.h
|
||||
qgswmsprovider.h
|
||||
qgswmsconnection.h
|
||||
qgswmsdataitems.h
|
||||
)
|
||||
|
||||
|
@ -26,80 +26,11 @@
|
||||
#include "qgswmsconnection.h"
|
||||
#include "qgsnetworkaccessmanager.h"
|
||||
#include "qgssettings.h"
|
||||
#include "qgsowsconnection.h"
|
||||
|
||||
QgsWMSConnection::QgsWMSConnection( const QString &connName )
|
||||
: mConnName( connName )
|
||||
: QgsOwsConnection( QStringLiteral( "WMS" ), connName )
|
||||
{
|
||||
QgsDebugMsg( "theConnName = " + connName );
|
||||
|
||||
QgsSettings settings;
|
||||
|
||||
QString key = "qgis/connections-wms/" + mConnName;
|
||||
QString credentialsKey = "qgis/WMS/" + mConnName;
|
||||
|
||||
QStringList connStringParts;
|
||||
|
||||
mUri.setParam( QStringLiteral( "url" ), settings.value( key + "/url" ).toString() );
|
||||
|
||||
// Check for credentials and prepend to the connection info
|
||||
QString username = settings.value( credentialsKey + "/username" ).toString();
|
||||
QString password = settings.value( credentialsKey + "/password" ).toString();
|
||||
if ( !username.isEmpty() )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "username" ), username );
|
||||
mUri.setParam( QStringLiteral( "password" ), password );
|
||||
}
|
||||
|
||||
QString authcfg = settings.value( credentialsKey + "/authcfg" ).toString();
|
||||
if ( !authcfg.isEmpty() )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "authcfg" ), authcfg );
|
||||
}
|
||||
|
||||
QString referer = settings.value( key + "/referer" ).toString();
|
||||
if ( !referer.isEmpty() )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "referer" ), referer );
|
||||
}
|
||||
|
||||
bool ignoreGetMap = settings.value( key + "/ignoreGetMapURI", false ).toBool();
|
||||
bool ignoreGetFeatureInfo = settings.value( key + "/ignoreGetFeatureInfoURI", false ).toBool();
|
||||
bool ignoreAxisOrientation = settings.value( key + "/ignoreAxisOrientation", false ).toBool();
|
||||
bool invertAxisOrientation = settings.value( key + "/invertAxisOrientation", false ).toBool();
|
||||
bool smoothPixmapTransform = settings.value( key + "/smoothPixmapTransform", false ).toBool();
|
||||
QString dpiMode = settings.value( key + "/dpiMode", "all" ).toString();
|
||||
|
||||
if ( ignoreGetMap )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "IgnoreGetMapUrl" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
|
||||
if ( ignoreGetFeatureInfo )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "IgnoreGetFeatureInfoUrl" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
|
||||
if ( ignoreAxisOrientation )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "IgnoreAxisOrientation" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
|
||||
if ( invertAxisOrientation )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "InvertAxisOrientation" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
|
||||
if ( smoothPixmapTransform )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "SmoothPixmapTransform" ), QStringLiteral( "1" ) );
|
||||
}
|
||||
|
||||
if ( !dpiMode.isEmpty() )
|
||||
{
|
||||
mUri.setParam( QStringLiteral( "dpiMode" ), dpiMode );
|
||||
}
|
||||
|
||||
QgsDebugMsg( QString( "encodedUri: '%1'." ).arg( QString( mUri.encodedUri() ) ) );
|
||||
}
|
||||
|
||||
QgsWMSConnection::~QgsWMSConnection()
|
||||
@ -107,11 +38,6 @@ QgsWMSConnection::~QgsWMSConnection()
|
||||
|
||||
}
|
||||
|
||||
QgsDataSourceUri QgsWMSConnection::uri()
|
||||
{
|
||||
return mUri;
|
||||
}
|
||||
|
||||
QStringList QgsWMSConnection::connectionList()
|
||||
{
|
||||
QgsSettings settings;
|
||||
|
@ -18,16 +18,14 @@
|
||||
#ifndef QGSWMSCONNECTION_H
|
||||
#define QGSWMSCONNECTION_H
|
||||
|
||||
#include "qgsdatasourceuri.h"
|
||||
|
||||
#include "qgsowsconnection.h"
|
||||
#include <QStringList>
|
||||
|
||||
/*!
|
||||
* \brief Connections management
|
||||
*/
|
||||
class QgsWMSConnection : public QObject
|
||||
class QgsWMSConnection : public QgsOwsConnection
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
@ -42,10 +40,6 @@ class QgsWMSConnection : public QObject
|
||||
static QString selectedConnection();
|
||||
static void setSelectedConnection( const QString &name );
|
||||
|
||||
public:
|
||||
QString mConnName;
|
||||
QgsDataSourceUri uri();
|
||||
QgsDataSourceUri mUri;
|
||||
};
|
||||
|
||||
#endif // QGSWMSCONNECTION_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user