30 #include <QInputDialog> 31 #include <QMessageBox> 34 #include <QNetworkRequest> 35 #include <QNetworkReply> 38 : mConnName( connName )
45 QString key =
"qgis/connections-" + mService.toLower() +
'/' + mConnName;
46 QString credentialsKey =
"qgis/" + mService +
'/' + mConnName;
48 mConnectionInfo = settings.
value( key +
"/url" ).toString();
49 mUri.
setParam( QStringLiteral(
"url" ), settings.
value( key +
"/url" ).toString() );
52 QString username = settings.
value( credentialsKey +
"/username" ).toString();
53 QString password = settings.
value( credentialsKey +
"/password" ).toString();
54 if ( !username.isEmpty() )
61 QString authcfg = settings.
value( credentialsKey +
"/authcfg" ).toString();
62 if ( !authcfg.isEmpty() )
66 mConnectionInfo.append(
",authcfg=" + authcfg );
68 const QString referer = settings.
value( key +
"/referer" ).toString();
69 if ( !referer.isEmpty() )
72 mConnectionInfo.append(
",referer=" + referer );
75 if ( mService.compare( QLatin1String(
"WMS" ), Qt::CaseInsensitive ) == 0
76 || mService.compare( QLatin1String(
"WCS" ), Qt::CaseInsensitive ) == 0 )
80 else if ( mService.compare( QLatin1String(
"WFS" ), Qt::CaseInsensitive ) == 0 )
95 return mConnectionInfo;
110 addCommonConnectionSettings( uri, settingsKey );
113 QString referer = settings.
value( settingsKey +
"/referer" ).toString();
114 if ( !referer.isEmpty() )
116 uri.
setParam( QStringLiteral(
"referer" ), referer );
118 if ( settings.
value( settingsKey + QStringLiteral(
"/ignoreGetMapURI" ),
false ).toBool() )
120 uri.
setParam( QStringLiteral(
"IgnoreGetMapUrl" ), QStringLiteral(
"1" ) );
122 if ( settings.
value( settingsKey + QStringLiteral(
"/ignoreGetFeatureInfoURI" ),
false ).toBool() )
124 uri.
setParam( QStringLiteral(
"IgnoreGetFeatureInfoUrl" ), QStringLiteral(
"1" ) );
126 if ( settings.
value( settingsKey + QStringLiteral(
"/smoothPixmapTransform" ),
false ).toBool() )
128 uri.
setParam( QStringLiteral(
"SmoothPixmapTransform" ), QStringLiteral(
"1" ) );
130 QString dpiMode = settings.
value( settingsKey + QStringLiteral(
"/dpiMode" ), QStringLiteral(
"all" ) ).toString();
131 if ( !dpiMode.isEmpty() )
133 uri.
setParam( QStringLiteral(
"dpiMode" ), dpiMode );
141 addCommonConnectionSettings( uri, settingsKey );
144 QString version = settings.
value( settingsKey +
"/version" ).toString();
145 if ( !version.isEmpty() )
147 uri.
setParam( QStringLiteral(
"version" ), version );
150 QString maxnumfeatures = settings.
value( settingsKey + QStringLiteral(
"/maxnumfeatures" ) ).toString();
151 if ( !maxnumfeatures.isEmpty() )
153 uri.
setParam( QStringLiteral(
"maxNumFeatures" ), maxnumfeatures );
162 settings.
beginGroup(
"qgis/connections-" + service.toLower() );
169 return settings.
value(
"qgis/connections-" + service.toLower() +
"/selected" ).toString();
175 settings.
setValue(
"qgis/connections-" + service.toLower() +
"/selected", name );
178 void QgsOwsConnection::addCommonConnectionSettings(
QgsDataSourceUri &
uri,
const QString &key )
182 if ( settings.
value( key + QStringLiteral(
"/ignoreAxisOrientation" ),
false ).toBool() )
184 uri.
setParam( QStringLiteral(
"IgnoreAxisOrientation" ), QStringLiteral(
"1" ) );
186 if ( settings.
value( key + QStringLiteral(
"/invertAxisOrientation" ),
false ).toBool() )
188 uri.
setParam( QStringLiteral(
"InvertAxisOrientation" ), QStringLiteral(
"1" ) );
195 settings.
remove(
"qgis/connections-" + service.toLower() +
'/' + name );
196 settings.
remove(
"qgis/" + service +
'/' + name );
QStringList childGroups() const
Returns a list of all key top-level groups that contain keys that can be read using the QSettings obj...
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...
QString connectionName() const
Returns the connection name.
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.
void remove(const QString &key, QgsSettings::Section section=QgsSettings::NoSection)
Removes the setting key and any sub-settings of key in a section.
QgsOwsConnection(const QString &service, const QString &connName)
Constructor.
static QStringList connectionList(const QString &service)
Returns the list of connections for the specified service.
QString connectionInfo() const
Returns connection info string.
#define QgsDebugMsgLevel(str, level)
QString service() const
Returns a string representing the service type, e.g.
static void setSelectedConnection(const QString &service, const QString &name)
Marks the specified connection for the specified service as selected.
QgsDataSourceUri uri() const
Returns the connection uri.
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI.
void beginGroup(const QString &prefix, QgsSettings::Section section=QgsSettings::NoSection)
Appends prefix to the current group.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
static QgsDataSourceUri & addWfsConnectionSettings(QgsDataSourceUri &uri, const QString &settingsKey)
Adds uri parameters relating to the settings for a WFS connection to a QgsDataSourceUri uri...
QByteArray encodedUri() const
Returns the complete encoded URI as a byte array.
Class for storing the component parts of a RDBMS data source URI (e.g.
static QString selectedConnection(const QString &service)
Retrieves the selected connection for the specified service.
static void deleteConnection(const QString &service, const QString &name)
Deletes the connection for the specified service with the specified name.