26#include "moc_qgsowsconnection.cpp"
34#include <QNetworkRequest>
35#include <QNetworkReply>
81 : mConnName( connName )
87 mConnectionInfo = url;
93 if ( !username.isEmpty() )
101 if ( !authcfg.isEmpty() )
105 mConnectionInfo.append(
",authcfg=" + authcfg );
110 if ( !referer.isEmpty() )
112 mConnectionInfo.append(
",referer=" + referer );
115 if ( mService.compare( QLatin1String(
"WMS" ), Qt::CaseInsensitive ) == 0
116 || mService.compare( QLatin1String(
"WCS" ), Qt::CaseInsensitive ) == 0 )
120 else if ( mService.compare( QLatin1String(
"WFS" ), Qt::CaseInsensitive ) == 0 )
135 return mConnectionInfo;
151 addCommonConnectionSettings(
uri, settingsKey );
157 if ( settings.value( settingsKey + QStringLiteral(
"/ignoreGetMapURI" ),
false ).toBool() )
159 uri.
setParam( QStringLiteral(
"IgnoreGetMapUrl" ), QStringLiteral(
"1" ) );
161 if ( settings.value( settingsKey + QStringLiteral(
"/ignoreGetFeatureInfoURI" ),
false ).toBool() )
163 uri.
setParam( QStringLiteral(
"IgnoreGetFeatureInfoUrl" ), QStringLiteral(
"1" ) );
165 if ( settings.value( settingsKey + QStringLiteral(
"/smoothPixmapTransform" ),
false ).toBool() )
167 uri.
setParam( QStringLiteral(
"SmoothPixmapTransform" ), QStringLiteral(
"1" ) );
169 if ( settings.value( settingsKey + QStringLiteral(
"/ignoreReportedLayerExtents" ),
false ).toBool() )
171 uri.
setParam( QStringLiteral(
"IgnoreReportedLayerExtents" ), QStringLiteral(
"1" ) );
173 const QString dpiMode = settings.value( settingsKey + QStringLiteral(
"/dpiMode" ), QStringLiteral(
"all" ) ).toString();
174 if ( !dpiMode.isEmpty() )
176 uri.
setParam( QStringLiteral(
"dpiMode" ), dpiMode );
178 const QString tilePixelRatio = settings.value( settingsKey + QStringLiteral(
"/tilePixelRatio" ),
"0" ).toString();
179 if ( tilePixelRatio != QLatin1String(
"0" ) )
181 uri.
setParam( QStringLiteral(
"tilePixelRatio" ), tilePixelRatio );
189 addCommonConnectionSettings(
uri,
service, connName );
195 uri.
setParam( QStringLiteral(
"IgnoreGetMapUrl" ), QStringLiteral(
"1" ) );
199 uri.
setParam( QStringLiteral(
"IgnoreGetFeatureInfoUrl" ), QStringLiteral(
"1" ) );
203 uri.
setParam( QStringLiteral(
"SmoothPixmapTransform" ), QStringLiteral(
"1" ) );
207 uri.
setParam( QStringLiteral(
"IgnoreReportedLayerExtents" ), QStringLiteral(
"1" ) );
228 addCommonConnectionSettings(
uri, settingsKey );
232 const QString version = settings.
value( settingsKey +
"/version" ).toString();
233 if ( !version.isEmpty() )
235 uri.
setParam( QStringLiteral(
"version" ), version );
238 const QString maxnumfeatures = settings.value( settingsKey + QStringLiteral(
"/maxnumfeatures" ) ).toString();
239 if ( !maxnumfeatures.isEmpty() )
241 uri.
setParam( QStringLiteral(
"maxNumFeatures" ), maxnumfeatures );
249 addCommonConnectionSettings(
uri,
service, connName );
252 if ( !version.isEmpty() )
254 uri.
setParam( QStringLiteral(
"version" ), version );
258 if ( !maxnumFeatures.isEmpty() )
260 uri.
setParam( QStringLiteral(
"maxNumFeatures" ), maxnumFeatures );
281void QgsOwsConnection::addCommonConnectionSettings(
QgsDataSourceUri &uri,
const QString &key )
285 if ( settings.
value( key + QStringLiteral(
"/ignoreAxisOrientation" ),
false ).toBool() )
287 uri.
setParam( QStringLiteral(
"IgnoreAxisOrientation" ), QStringLiteral(
"1" ) );
289 if ( settings.
value( key + QStringLiteral(
"/invertAxisOrientation" ),
false ).toBool() )
291 uri.
setParam( QStringLiteral(
"InvertAxisOrientation" ), QStringLiteral(
"1" ) );
295void QgsOwsConnection::addCommonConnectionSettings(
QgsDataSourceUri &uri,
const QString &service,
const QString &connectionName )
300 uri.
setParam( QStringLiteral(
"IgnoreAxisOrientation" ), QStringLiteral(
"1" ) );
304 uri.
setParam( QStringLiteral(
"InvertAxisOrientation" ), QStringLiteral(
"1" ) );
@ SaveEnumFlagAsInt
The enum/flag will be saved as an integer value instead of text.
@ Undefined
Undefined (not scale)
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryVariantMap * settingsHeaders
static const QgsSettingsEntryString * settingsContentEndpoint
static const QgsSettingsEntryString * settingsUrlPrefix
static const QgsSettingsEntryString * settingsAuthcfg
static const QgsSettingsEntryString * settingsCommunityEndpoint
Class for storing the component parts of a RDBMS data source URI (e.g.
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
void setAuthConfigId(const QString &authcfg)
Sets the authentication configuration ID for the URI.
QgsHttpHeaders httpHeaders() const
Returns http headers.
void setUsername(const QString &username)
Sets the username for the URI.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
void setHttpHeaders(const QgsHttpHeaders &headers)
Sets headers to headers.
void setPassword(const QString &password)
Sets the password for the URI.
static const QgsSettingsEntryInteger * settingsFeatureCount
static const QgsSettingsEntryBool * settingsPreferCoordinatesForWfsT11
static Q_DECL_DEPRECATED QgsDataSourceUri & addWmsWcsConnectionSettings(QgsDataSourceUri &uri, const QString &settingsKey)
Adds uri parameters relating to the settings for a WMS or WCS connection to a QgsDataSourceUri uri.
static QStringList connectionList(const QString &service)
Returns the list of connections for the specified service.
static const QgsSettingsEntryString * settingsPagingEnabled
static const QgsSettingsEntryString * settingsMaxNumFeatures
static QgsSettingsTreeNamedListNode * sTreeOwsConnections
static const QgsSettingsEntryBool * settingsIgnoreGetFeatureInfoURI
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryBool * settingsReportedLayerExtents
static void setSelectedConnection(const QString &service, const QString &name)
Marks the specified connection for the specified service as selected.
static const QgsSettingsEntryEnumFlag< Qgis::DpiMode > * settingsDpiMode
static const QgsSettingsEntryBool * settingsIgnoreAxisOrientation
static const QgsSettingsEntryBool * settingsInvertAxisOrientation
static const QgsSettingsEntryString * settingsVersion
QString connectionInfo() const
Returns connection info string.
static void deleteConnection(const QString &service, const QString &name)
Deletes the connection for the specified service with the specified name.
static const QgsSettingsEntryString * settingsPagesize
static const QgsSettingsEntryString * settingsAuthCfg
static const QgsSettingsEntryEnumFlag< Qgis::TilePixelRatio > * settingsTilePixelRatio
static const QgsSettingsEntryVariantMap * settingsHeaders
static Q_DECL_DEPRECATED QgsDataSourceUri & addWfsConnectionSettings(QgsDataSourceUri &uri, const QString &settingsKey)
Adds uri parameters relating to the settings for a WFS connection to a QgsDataSourceUri uri.
QString connectionName() const
Returns the connection name.
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryBool * settingsSmoothPixmapTransform
static const QgsSettingsEntryString * settingsUrl
static QString selectedConnection(const QString &service)
Retrieves the selected connection for the specified service.
static const QgsSettingsEntryBool * settingsIgnoreGetMapURI
QgsOwsConnection(const QString &service, const QString &connName)
Constructor.
QgsDataSourceUri uri() const
Returns the connection uri.
QString service() const
Returns a string representing the service type, e.g.
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool exists(const QString &dynamicKeyPart=QString()) const
Returns true if the settings is contained in the underlying QSettings.
A boolean settings entry.
A template class for enum and flag settings entry.
An integer settings entry.
A string list settings entry.
void deleteItem(const QString &item, const QStringList &parentsNamedItems=QStringList())
Deletes a named item from the named list node.
QString selectedItem(const QStringList &parentsNamedItems=QStringList())
Returns the selected named item from the named list node.
void setSelectedItem(const QString &item, const QStringList &parentsNamedItems=QStringList())
Sets the selected named item from the named list node.
QStringList items(const QStringList &parentsNamedItems=QStringList()) const
Returns the list of items.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryDouble * settingsTilePixelRatio
static const QgsSettingsEntryString * settingsInterpretation
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryString * settingsAuthcfg
static const QgsSettingsEntryInteger * settingsZmin
static const QgsSettingsEntryBool * settingsHidden
static const QgsSettingsEntryInteger * settingsZmax
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryVariantMap * settingsHeaders
#define Q_NOWARN_DEPRECATED_POP
#define Q_NOWARN_DEPRECATED_PUSH
#define QgsDebugMsgLevel(str, level)