28 #include "qgssettings.h"
32 #include <QNetworkRequest>
33 #include <QNetworkReply>
36 : mConnName( connName )
43 QString key =
"qgis/connections-" + mService.toLower() +
'/' + mConnName;
44 QString credentialsKey =
"qgis/" + mService +
'/' + mConnName;
46 mConnectionInfo = settings.value( key +
"/url" ).toString();
47 mUri.
setParam( QStringLiteral(
"url" ), settings.value( key +
"/url" ).toString() );
50 QString username = settings.value( credentialsKey +
"/username" ).toString();
51 QString password = settings.value( credentialsKey +
"/password" ).toString();
52 if ( !username.isEmpty() )
59 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 );
110 QgsSettings settings;
111 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 QString dpiMode = settings.value( settingsKey + QStringLiteral(
"/dpiMode" ), QStringLiteral(
"all" ) ).toString();
133 if ( !dpiMode.isEmpty() )
135 uri.
setParam( QStringLiteral(
"dpiMode" ), dpiMode );
143 addCommonConnectionSettings(
uri, settingsKey );
145 QgsSettings settings;
146 QString version = settings.value( settingsKey +
"/version" ).toString();
147 if ( !version.isEmpty() )
149 uri.
setParam( QStringLiteral(
"version" ), version );
152 QString maxnumfeatures = settings.value( settingsKey + QStringLiteral(
"/maxnumfeatures" ) ).toString();
153 if ( !maxnumfeatures.isEmpty() )
155 uri.
setParam( QStringLiteral(
"maxNumFeatures" ), maxnumfeatures );
163 QgsSettings settings;
164 settings.beginGroup(
"qgis/connections-" +
service.toLower() );
165 return settings.childGroups();
170 QgsSettings settings;
171 return settings.value(
"qgis/connections-" +
service.toLower() +
"/selected" ).toString();
176 QgsSettings settings;
177 settings.setValue(
"qgis/connections-" +
service.toLower() +
"/selected", name );
180 void QgsOwsConnection::addCommonConnectionSettings(
QgsDataSourceUri &uri,
const QString &key )
182 QgsSettings settings;
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" ) );
196 QgsSettings settings;
197 settings.remove(
"qgis/connections-" +
service.toLower() +
'/' + name );
198 settings.remove(
"qgis/" +
service +
'/' + 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.
#define QgsDebugMsgLevel(str, level)