32 #include <QNetworkRequest>
33 #include <QNetworkReply>
36 : mConnName( connName )
43 const QString key =
"qgis/connections-" + mService.toLower() +
'/' + mConnName;
44 const QString credentialsKey =
"qgis/" + mService +
'/' + mConnName;
46 mConnectionInfo = settings.
value( key +
"/url" ).toString();
47 mUri.
setParam( QStringLiteral(
"url" ), settings.
value( key +
"/url" ).toString() );
50 const QString username = settings.
value( credentialsKey +
"/username" ).toString();
51 const QString password = settings.
value( credentialsKey +
"/password" ).toString();
52 if ( !username.isEmpty() )
59 const QString authcfg = settings.
value( credentialsKey +
"/authcfg" ).toString();
60 if ( !authcfg.isEmpty() )
64 mConnectionInfo.append(
",authcfg=" + authcfg );
66 const QString referer = settings.
value( key +
"/referer" ).toString();
67 if ( !referer.isEmpty() )
70 mConnectionInfo.append(
",referer=" + referer );
73 if ( mService.compare( QLatin1String(
"WMS" ), Qt::CaseInsensitive ) == 0
74 || mService.compare( QLatin1String(
"WCS" ), Qt::CaseInsensitive ) == 0 )
78 else if ( mService.compare( QLatin1String(
"WFS" ), Qt::CaseInsensitive ) == 0 )
93 return mConnectionInfo;
108 addCommonConnectionSettings(
uri, settingsKey );
111 const QString referer = settings.
value( settingsKey +
"/referer" ).toString();
112 if ( !referer.isEmpty() )
114 uri.
setParam( QStringLiteral(
"referer" ), referer );
116 if ( settings.
value( settingsKey + QStringLiteral(
"/ignoreGetMapURI" ),
false ).toBool() )
118 uri.
setParam( QStringLiteral(
"IgnoreGetMapUrl" ), QStringLiteral(
"1" ) );
120 if ( settings.
value( settingsKey + QStringLiteral(
"/ignoreGetFeatureInfoURI" ),
false ).toBool() )
122 uri.
setParam( QStringLiteral(
"IgnoreGetFeatureInfoUrl" ), QStringLiteral(
"1" ) );
124 if ( settings.
value( settingsKey + QStringLiteral(
"/smoothPixmapTransform" ),
false ).toBool() )
126 uri.
setParam( QStringLiteral(
"SmoothPixmapTransform" ), QStringLiteral(
"1" ) );
128 if ( settings.
value( settingsKey + QStringLiteral(
"/ignoreReportedLayerExtents" ),
false ).toBool() )
130 uri.
setParam( QStringLiteral(
"IgnoreReportedLayerExtents" ), QStringLiteral(
"1" ) );
132 const QString dpiMode = settings.
value( settingsKey + QStringLiteral(
"/dpiMode" ), QStringLiteral(
"all" ) ).toString();
133 if ( !dpiMode.isEmpty() )
135 uri.
setParam( QStringLiteral(
"dpiMode" ), dpiMode );
143 addCommonConnectionSettings(
uri, settingsKey );
146 const QString version = settings.
value( settingsKey +
"/version" ).toString();
147 if ( !version.isEmpty() )
149 uri.
setParam( QStringLiteral(
"version" ), version );
152 const QString maxnumfeatures = settings.
value( settingsKey + QStringLiteral(
"/maxnumfeatures" ) ).toString();
153 if ( !maxnumfeatures.isEmpty() )
155 uri.
setParam( QStringLiteral(
"maxNumFeatures" ), maxnumfeatures );
171 return settings.
value(
"qgis/connections-" +
service.toLower() +
"/selected" ).toString();
177 settings.
setValue(
"qgis/connections-" +
service.toLower() +
"/selected", name );
180 void QgsOwsConnection::addCommonConnectionSettings(
QgsDataSourceUri &uri,
const QString &key )
184 if ( settings.
value( key + QStringLiteral(
"/ignoreAxisOrientation" ),
false ).toBool() )
186 uri.
setParam( QStringLiteral(
"IgnoreAxisOrientation" ), QStringLiteral(
"1" ) );
188 if ( settings.
value( key + QStringLiteral(
"/invertAxisOrientation" ),
false ).toBool() )
190 uri.
setParam( QStringLiteral(
"InvertAxisOrientation" ), QStringLiteral(
"1" ) );
197 settings.
remove(
"qgis/connections-" +
service.toLower() +
'/' + name );
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.
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 setPassword(const QString &password)
Sets the password for the URI.
static 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 void setSelectedConnection(const QString &service, const QString &name)
Marks the specified connection for the specified service as selected.
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 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 QString selectedConnection(const QString &service)
Retrieves the selected connection for the specified service.
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.
This class is a composition of two QSettings instances:
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
#define QgsDebugMsgLevel(str, level)