QGIS API Documentation 3.43.0-Master (5df50c54ce9)
qgsnewhttpconnection.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsnewhttpconnection.cpp - selector for a new HTTP server for WMS, etc.
3 -------------------
4 begin : 3 April 2005
5 copyright : (C) 2005 by Brendan Morley
6 email : morb at ozemail dot com dot au
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18#include "moc_qgsnewhttpconnection.cpp"
20#include "qgssettings.h"
21#include "qgshelp.h"
22#include "qgsgui.h"
24#include "qgsowsconnection.h"
27
28#include <QMessageBox>
29#include <QUrl>
30#include <QPushButton>
31#include <QRegularExpression>
32#include <QRegularExpressionValidator>
33#include <QUrlQuery>
34
35const QgsSettingsEntryBool *QgsNewHttpConnection::settingsIgnoreReportedLayerExtentsDefault = new QgsSettingsEntryBool( QStringLiteral( "ignore-reported-layer-extents-default" ), sTreeHttpConnectionDialog, false );
36
37QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes types, const QString &serviceName, const QString &connectionName, QgsNewHttpConnection::Flags flags, Qt::WindowFlags fl )
38 : QDialog( parent, fl )
39 , mTypes( types )
40 , mServiceName( serviceName )
41 , mOriginalConnName( connectionName )
42{
43 setupUi( this );
44
45 // compatibility fix with former API (pre 3.26) when serviceName was a setting key instead
46 if ( mServiceName.startsWith( QLatin1String( "qgis/" ) ) )
47 {
48 // It would be obviously much better to use mBaseKey also for credentials,
49 // but for some strange reason a different hardcoded key was used instead.
50 // WFS and WMS credentials were mixed with the same key WMS.
51 // Only WMS and WFS providers are using QgsNewHttpConnection at this moment
52 // using connection-wms and connection-wfs -> parse credential key from it.
53 mServiceName = mServiceName.split( '-' ).last().toUpper();
54 }
55
56 if ( !( flags & FlagShowHttpSettings ) )
57 mHttpHeaders->hide();
58
60
61 connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsNewHttpConnection::showHelp );
62
63 QString connectionType = mServiceName;
64 if ( mServiceName == QLatin1String( "WMS" ) )
65 {
66 connectionType = QStringLiteral( "WMS/WMTS" );
67 }
68 setWindowTitle( tr( "Create a New %1 Connection" ).arg( connectionType ) );
69
70 txtName->setValidator( new QRegularExpressionValidator( QRegularExpression( "[^\\/]+" ), txtName ) );
71
72 cmbDpiMode->clear();
73 cmbDpiMode->addItem( tr( "all" ), static_cast<int>( Qgis::DpiMode::All ) );
74 cmbDpiMode->addItem( tr( "off" ), static_cast<int>( Qgis::DpiMode::Off ) );
75 cmbDpiMode->addItem( tr( "QGIS" ), static_cast<int>( Qgis::DpiMode::QGIS ) );
76 cmbDpiMode->addItem( tr( "UMN" ), static_cast<int>( Qgis::DpiMode::UMN ) );
77 cmbDpiMode->addItem( tr( "GeoServer" ), static_cast<int>( Qgis::DpiMode::GeoServer ) );
78
79 cmbTilePixelRatio->clear();
80 cmbTilePixelRatio->addItem( tr( "Undefined (not scaled)" ), static_cast<int>( Qgis::TilePixelRatio::Undefined ) );
81 cmbTilePixelRatio->addItem( tr( "Standard (96 DPI)" ), static_cast<int>( Qgis::TilePixelRatio::StandardDpi ) );
82 cmbTilePixelRatio->addItem( tr( "High (192 DPI)" ), static_cast<int>( Qgis::TilePixelRatio::HighDpi ) );
83
84 cmbVersion->clear();
85 cmbVersion->addItem( tr( "Maximum" ) );
86 cmbVersion->addItem( tr( "1.0" ) );
87 cmbVersion->addItem( tr( "1.1" ) );
88 cmbVersion->addItem( tr( "2.0" ) );
89 cmbVersion->addItem( tr( "OGC API - Features" ) );
90 connect( cmbVersion, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewHttpConnection::wfsVersionCurrentIndexChanged );
91
92 mComboWfsFeatureMode->clear();
93 mComboWfsFeatureMode->addItem( tr( "Default" ), QStringLiteral( "default" ) );
94 mComboWfsFeatureMode->addItem( tr( "Simple Features" ), QStringLiteral( "simpleFeatures" ) );
95 mComboWfsFeatureMode->addItem( tr( "Complex Features" ), QStringLiteral( "complexFeatures" ) );
96
97 mComboHttpMethod->addItem( QStringLiteral( "GET" ), QVariant::fromValue( Qgis::HttpMethod::Get ) );
98 mComboHttpMethod->addItem( QStringLiteral( "POST" ), QVariant::fromValue( Qgis::HttpMethod::Post ) );
99 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue( Qgis::HttpMethod::Get ) ) );
100
101 cmbFeaturePaging->clear();
102 cmbFeaturePaging->addItem( tr( "Default (trust server capabilities)" ) );
103 cmbFeaturePaging->addItem( tr( "Enabled" ) );
104 cmbFeaturePaging->addItem( tr( "Disabled" ) );
105 connect( cmbFeaturePaging, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged );
106
107 cbxWmsIgnoreReportedLayerExtents->setChecked( settingsIgnoreReportedLayerExtentsDefault->value() );
108
109 if ( !connectionName.isEmpty() )
110 {
111 // populate the dialog with the information stored for the connection
112 // populate the fields with the stored setting parameters
113
114 txtName->setText( connectionName );
115 const QStringList detailParameters { mServiceName.toLower(), connectionName };
116 txtUrl->setText( QgsOwsConnection::settingsUrl->value( detailParameters ) );
117 mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( detailParameters ) ) );
118
120
121 // Authentication
122 mAuthSettings->setUsername( QgsOwsConnection::settingsUsername->value( detailParameters ) );
123 mAuthSettings->setPassword( QgsOwsConnection::settingsPassword->value( detailParameters ) );
124 mAuthSettings->setConfigId( QgsOwsConnection::settingsAuthCfg->value( detailParameters ) );
125 }
126 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
127
128 if ( !( mTypes & ConnectionWms ) && !( mTypes & ConnectionWcs ) )
129 {
130 mWmsOptionsGroupBox->setVisible( false );
131 mGroupBox->layout()->removeWidget( mWmsOptionsGroupBox );
132 }
133 if ( !( mTypes & ConnectionWfs ) )
134 {
135 mWfsOptionsGroupBox->setVisible( false );
136 mGroupBox->layout()->removeWidget( mWfsOptionsGroupBox );
137 }
138 else
139 {
140 txtUrl->setToolTip( tr( "HTTP address of the WFS service, or landing page of a OGC API service<br>(an ending slash might be needed for some OGC API servers)" ) );
141 }
142
143 if ( mTypes & ConnectionWcs )
144 {
145 cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
146 cbxWmsIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
147 if ( !( mTypes & ConnectionWms ) )
148 {
149 mWmsOptionsGroupBox->setTitle( tr( "WCS Options" ) );
150
151 cbxIgnoreGetFeatureInfoURI->setVisible( false );
152 mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
153
154 sbFeatureCount->setVisible( false );
155 mGroupBox->layout()->removeWidget( sbFeatureCount );
156 lblFeatureCount->setVisible( false );
157 mGroupBox->layout()->removeWidget( lblFeatureCount );
158
159 cmbDpiMode->setVisible( false );
160 mGroupBox->layout()->removeWidget( cmbDpiMode );
161 lblDpiMode->setVisible( false );
162 mGroupBox->layout()->removeWidget( lblDpiMode );
163 cmbTilePixelRatio->setVisible( false );
164 mGroupBox->layout()->removeWidget( cmbTilePixelRatio );
165 lblTilePixelRatio->setVisible( false );
166 mGroupBox->layout()->removeWidget( lblTilePixelRatio );
167 }
168 }
169
170 if ( !( flags & FlagShowTestConnection ) )
171 {
172 mTestConnectionButton->hide();
173 mGroupBox->layout()->removeWidget( mTestConnectionButton );
174 }
175
176 if ( flags & FlagHideAuthenticationGroup )
177 {
178 mAuthGroupBox->hide();
179 mGroupBox->layout()->removeWidget( mAuthGroupBox );
180 }
181 // Adjust height
182 const int w = width();
183 adjustSize();
184 resize( w, height() );
185
186 connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::nameChanged );
187 connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::urlChanged );
188
189 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
190 connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::updateOkButtonState );
191 connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::updateOkButtonState );
192
193 nameChanged( connectionName );
194}
195
196void QgsNewHttpConnection::wfsVersionCurrentIndexChanged( int index )
197{
198 // For now 2019-06-06, leave paging checkable for some WFS version 1.1 servers with support
199 const bool pagingOptionsEnabled = ( index == WFS_VERSION_MAX || index >= WFS_VERSION_1_1 );
200 cmbFeaturePaging->setEnabled( pagingOptionsEnabled );
201 lblPageSize->setEnabled( pagingOptionsEnabled );
202 txtPageSize->setEnabled( pagingOptionsEnabled );
203 cbxWfsIgnoreAxisOrientation->setEnabled( index != WFS_VERSION_1_0 && index != WFS_VERSION_API_FEATURES_1_0 );
204 cbxWfsInvertAxisOrientation->setEnabled( index != WFS_VERSION_API_FEATURES_1_0 );
205 wfsUseGml2EncodingForTransactions()->setEnabled( index == WFS_VERSION_1_1 );
206}
207
208void QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged( int index )
209{
210 const bool pagingNotDisabled = index != static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED );
211 lblPageSize->setEnabled( pagingNotDisabled );
212 txtPageSize->setEnabled( pagingNotDisabled );
213}
214
216{
217 return txtName->text();
218}
219
221{
222 return txtUrl->text();
223}
224
225void QgsNewHttpConnection::nameChanged( const QString &text )
226{
227 Q_UNUSED( text )
228 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
229}
230
231void QgsNewHttpConnection::urlChanged( const QString &text )
232{
233 Q_UNUSED( text )
234 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
235 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
236}
237
238void QgsNewHttpConnection::updateOkButtonState()
239{
240 const bool enabled = !txtName->text().isEmpty() && !txtUrl->text().isEmpty();
241 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
242}
243
245{
246 const QString newConnectionName = txtName->text();
247
248 bool urlExists = QgsOwsConnection::settingsUrl->exists( { mServiceName.toLower(), newConnectionName } );
249
250 // warn if entry was renamed to an existing connection
251 if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( newConnectionName, Qt::CaseInsensitive ) != 0 ) && urlExists && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
252 {
253 return false;
254 }
255
256 if ( !mAuthSettings->password().isEmpty() && QMessageBox::question( this, tr( "Saving Passwords" ), tr( "WARNING: You have entered a password. It will be stored in unsecured plain text in your project files and your home directory (Unix-like OS) or user profile (Windows). If you want to avoid this, press Cancel and either:\n\na) Don't provide a password in the connection settings — it will be requested interactively when needed;\nb) Use the Configuration tab to add your credentials in an HTTP Basic Authentication method and store them in an encrypted database." ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
257 {
258 return false;
259 }
260
261 return true;
262}
263
265{
266 return mTestConnectionButton;
267}
268
273
275{
276 return mWfsVersionDetectButton;
277}
278
280{
281 return cmbVersion;
282}
283
285{
286 return cmbFeaturePaging;
287}
288
290{
291 return cbxWfsUseGml2EncodingForTransactions;
292}
293
295{
296 return txtPageSize;
297}
298
300{
301 return mComboHttpMethod->currentData().value< Qgis::HttpMethod >();
302}
303
304QString QgsNewHttpConnection::wfsSettingsKey( const QString &base, const QString &connectionName ) const
305{
306 return base + connectionName;
307}
308
309QString QgsNewHttpConnection::wmsSettingsKey( const QString &base, const QString &connectionName ) const
310{
311 return base + connectionName;
312}
313
315{
316 QStringList detailsParameters = { mServiceName.toLower(), mOriginalConnName };
317
318 cbxIgnoreGetMapURI->setChecked( QgsOwsConnection::settingsIgnoreGetMapURI->value( detailsParameters ) );
319 cbxWmsIgnoreReportedLayerExtents->setChecked( QgsOwsConnection::settingsReportedLayerExtents->value( detailsParameters ) );
320 cbxWfsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
321 cbxWfsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
322 cbxWfsUseGml2EncodingForTransactions->setChecked( QgsOwsConnection::settingsPreferCoordinatesForWfsT11->value( detailsParameters ) );
323
324 cbxWmsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
325 cbxWmsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
326 cbxIgnoreGetFeatureInfoURI->setChecked( QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->value( detailsParameters ) );
327 cbxSmoothPixmapTransform->setChecked( QgsOwsConnection::settingsSmoothPixmapTransform->value( detailsParameters ) );
328
329 Qgis::DpiMode dpiMode = QgsOwsConnection::settingsDpiMode->value( detailsParameters );
330 cmbDpiMode->setCurrentIndex( cmbDpiMode->findData( static_cast<int>( dpiMode ) ) );
331 Qgis::TilePixelRatio tilePixelRatio = QgsOwsConnection::settingsTilePixelRatio->value( detailsParameters );
332 cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData( static_cast<int>( tilePixelRatio ) ) );
333
334 sbFeatureCount->setValue( QgsOwsConnection::settingsFeatureCount->value( detailsParameters ) );
335
336 const QString version = QgsOwsConnection::settingsVersion->value( detailsParameters );
337 int versionIdx = WFS_VERSION_MAX; // AUTO
338 if ( version == QLatin1String( "1.0.0" ) )
339 versionIdx = WFS_VERSION_1_0;
340 else if ( version == QLatin1String( "1.1.0" ) )
341 versionIdx = WFS_VERSION_1_1;
342 else if ( version == QLatin1String( "2.0.0" ) )
343 versionIdx = WFS_VERSION_2_0;
344 else if ( version == QLatin1String( "OGC_API_FEATURES" ) )
345 versionIdx = WFS_VERSION_API_FEATURES_1_0;
346 cmbVersion->setCurrentIndex( versionIdx );
347
348 // Enable/disable these items per WFS versions
349 wfsVersionCurrentIndexChanged( versionIdx );
350
351 mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( { mServiceName.toLower(), mOriginalConnName } ) ) );
352
353 txtMaxNumFeatures->setText( QgsOwsConnection::settingsMaxNumFeatures->value( detailsParameters ) );
354
355 // Only default to paging enabled if WFS 2.0.0 or higher
356 const QString pagingEnabled = QgsOwsConnection::settingsPagingEnabled->value( detailsParameters );
357 if ( pagingEnabled == QLatin1String( "enabled" ) )
358 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::ENABLED ) );
359 else if ( pagingEnabled == QLatin1String( "disabled" ) )
360 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED ) );
361 else
362 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DEFAULT ) );
363
364 const QString wfsFeatureMode = QgsOwsConnection::settingsWfsFeatureMode->value( detailsParameters );
365 mComboWfsFeatureMode->setCurrentIndex( std::max( mComboWfsFeatureMode->findData( wfsFeatureMode ), 0 ) );
366
367 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue( QgsOwsConnection::settingsPreferredHttpMethod->value( detailsParameters ) ) ) );
368 txtPageSize->setText( QgsOwsConnection::settingsPagesize->value( detailsParameters ) );
369}
370
372{
373 QUrl url( txtUrl->text().trimmed() );
374 QUrlQuery query( url );
375 const QList<QPair<QString, QString>> items = query.queryItems( QUrl::FullyEncoded );
376 QHash<QString, QPair<QString, QString>> params;
377 for ( const QPair<QString, QString> &it : items )
378 {
379 params.insert( it.first.toUpper(), it );
380 }
381
382 if ( params[QStringLiteral( "SERVICE" )].second.toUpper() == "WMS" || params[QStringLiteral( "SERVICE" )].second.toUpper() == "WFS" || params[QStringLiteral( "SERVICE" )].second.toUpper() == "WCS" )
383 {
384 query.removeQueryItem( params.value( QStringLiteral( "SERVICE" ) ).first );
385 query.removeQueryItem( params.value( QStringLiteral( "REQUEST" ) ).first );
386 query.removeQueryItem( params.value( QStringLiteral( "FORMAT" ) ).first );
387 }
388
389 url.setQuery( query );
390
391 if ( url.path( QUrl::FullyEncoded ).isEmpty() )
392 {
393 url.setPath( fromEncodedComponent_helper( "/" ) );
394 }
395 return url;
396}
397
399{
400 const QString newConnectionName = txtName->text();
401
402 if ( !validate() )
403 return;
404
405 QgsSettings settings;
406
407 // on rename delete original entry first
408 if ( !mOriginalConnName.isNull() && mOriginalConnName != newConnectionName )
409 {
410 QgsOwsConnection::sTreeOwsConnections->deleteItem( mOriginalConnName, { mServiceName.toLower() } );
411 settings.sync();
412 }
413
414 QStringList detailsParameters = { mServiceName.toLower(), newConnectionName };
415
416 const QUrl url( urlTrimmed() );
417 QgsOwsConnection::settingsUrl->setValue( url.toString(), detailsParameters );
418
419 if ( mTypes & ConnectionWfs )
420 {
421 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWfsIgnoreAxisOrientation->isChecked(), detailsParameters );
422 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWfsInvertAxisOrientation->isChecked(), detailsParameters );
423 QgsOwsConnection::settingsPreferCoordinatesForWfsT11->setValue( cbxWfsUseGml2EncodingForTransactions->isChecked(), detailsParameters );
424 }
425 if ( mTypes & ConnectionWms || mTypes & ConnectionWcs )
426 {
427 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWmsIgnoreAxisOrientation->isChecked(), detailsParameters );
428 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWmsInvertAxisOrientation->isChecked(), detailsParameters );
429
430 QgsOwsConnection::settingsReportedLayerExtents->setValue( cbxWmsIgnoreReportedLayerExtents->isChecked(), detailsParameters );
431 QgsOwsConnection::settingsIgnoreGetMapURI->setValue( cbxIgnoreGetMapURI->isChecked(), detailsParameters );
432 QgsOwsConnection::settingsSmoothPixmapTransform->setValue( cbxSmoothPixmapTransform->isChecked(), detailsParameters );
433
434 Qgis::DpiMode dpiMode = cmbDpiMode->currentData().value<Qgis::DpiMode>();
435 QgsOwsConnection::settingsDpiMode->setValue( dpiMode, detailsParameters );
436 Qgis::TilePixelRatio tilePixelRatio = cmbTilePixelRatio->currentData().value<Qgis::TilePixelRatio>();
437 QgsOwsConnection::settingsTilePixelRatio->setValue( tilePixelRatio, detailsParameters );
438
439 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), detailsParameters );
440 }
441 if ( mTypes & ConnectionWms )
442 {
443 QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->setValue( cbxIgnoreGetFeatureInfoURI->isChecked(), detailsParameters );
444 QgsOwsConnection::settingsFeatureCount->setValue( sbFeatureCount->value(), detailsParameters );
445 }
446 if ( mTypes & ConnectionWfs )
447 {
448 QString version = QStringLiteral( "auto" );
449 switch ( cmbVersion->currentIndex() )
450 {
451 case WFS_VERSION_MAX:
452 version = QStringLiteral( "auto" );
453 break;
454 case WFS_VERSION_1_0:
455 version = QStringLiteral( "1.0.0" );
456 break;
457 case WFS_VERSION_1_1:
458 version = QStringLiteral( "1.1.0" );
459 break;
460 case WFS_VERSION_2_0:
461 version = QStringLiteral( "2.0.0" );
462 break;
464 version = QStringLiteral( "OGC_API_FEATURES" );
465 break;
466 }
467 QgsOwsConnection::settingsVersion->setValue( version, detailsParameters );
468 QgsOwsConnection::settingsMaxNumFeatures->setValue( txtMaxNumFeatures->text(), detailsParameters );
469 QgsOwsConnection::settingsPagesize->setValue( txtPageSize->text(), detailsParameters );
470 QgsOwsConnection::settingsPreferredHttpMethod->setValue( mComboHttpMethod->currentData().value< Qgis::HttpMethod >(), detailsParameters );
471
472 QString pagingEnabled = QStringLiteral( "default" );
473 switch ( cmbFeaturePaging->currentIndex() )
474 {
476 pagingEnabled = QStringLiteral( "default" );
477 break;
479 pagingEnabled = QStringLiteral( "enabled" );
480 break;
482 pagingEnabled = QStringLiteral( "disabled" );
483 break;
484 }
485 QgsOwsConnection::settingsPagingEnabled->setValue( pagingEnabled, detailsParameters );
486
487 const QString featureMode = mComboWfsFeatureMode->currentData().toString();
488 QgsOwsConnection::settingsWfsFeatureMode->setValue( featureMode, detailsParameters );
489 }
490
491 QStringList credentialsParameters = { mServiceName.toLower(), newConnectionName };
492 QgsOwsConnection::settingsUsername->setValue( mAuthSettings->username(), credentialsParameters );
493 QgsOwsConnection::settingsPassword->setValue( mAuthSettings->password(), credentialsParameters );
494 QgsOwsConnection::settingsAuthCfg->setValue( mAuthSettings->configId(), credentialsParameters );
495
496 if ( mHttpHeaders->isVisible() )
497 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), credentialsParameters );
498
499 QgsOwsConnection::sTreeOwsConnections->setSelectedItem( newConnectionName, { mServiceName.toLower() } );
500
501 QDialog::accept();
502}
503
504void QgsNewHttpConnection::showHelp()
505{
506 QgsHelp::openHelp( QStringLiteral( "working_with_ogc/index.html" ) );
507}
TilePixelRatio
DpiMode enum.
Definition qgis.h:3240
@ Undefined
Undefined (not scale)
@ HighDpi
High (192 DPI)
@ StandardDpi
Standard (96 DPI)
DpiMode
DpiMode enum.
Definition qgis.h:3226
@ GeoServer
GeoServer.
HttpMethod
Different methods of HTTP requests.
Definition qgis.h:1001
@ Post
POST method.
@ Get
GET method.
Widget for entering authentication credentials both in the form username/password and by using QGIS A...
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition qgsgui.cpp:210
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition qgshelp.cpp:39
Implements simple HTTP header management.
Qgis::HttpMethod preferredHttpMethod() const
Returns the selected preferred HTTP method.
QPushButton * testConnectButton()
Returns the "test connection" button.
QgsAuthSettingsWidget * authSettingsWidget()
Returns the current authentication settings widget.
QComboBox * wfsPagingComboBox()
Returns the "WFS paging" combobox.
virtual bool validate()
Returns true if dialog settings are valid, or false if current settings are not valid and the dialog ...
QgsNewHttpConnection(QWidget *parent=nullptr, QgsNewHttpConnection::ConnectionTypes types=ConnectionWms, const QString &serviceName="WMS", const QString &connectionName=QString(), QgsNewHttpConnection::Flags flags=QgsNewHttpConnection::Flags(), Qt::WindowFlags fl=QgsGuiUtils::ModalDialogFlags)
Constructor for QgsNewHttpConnection.
QString name() const
Returns the current connection name.
@ FlagShowHttpSettings
Display the 'http' group.
@ FlagHideAuthenticationGroup
Hide the Authentication group.
@ FlagShowTestConnection
Display the 'test connection' button.
QCheckBox * wfsUseGml2EncodingForTransactions()
Returns the "Use GML2 encoding for transactions" checkbox.
QComboBox * wfsVersionComboBox()
Returns the "WFS version" combobox.
virtual QString wmsSettingsKey(const QString &base, const QString &connectionName) const
Returns the QSettings key for WMS related settings for the connection.
virtual QString wfsSettingsKey(const QString &base, const QString &connectionName) const
Returns the QSettings key for WFS related settings for the connection.
QString url() const
Returns the current connection url.
QPushButton * wfsVersionDetectButton()
Returns the "WFS version detect" button.
static const QgsSettingsEntryBool * settingsIgnoreReportedLayerExtentsDefault
QUrl urlTrimmed() const
Returns the url.
QLineEdit * wfsPageSizeLineEdit()
Returns the "WFS page size" edit.
void updateServiceSpecificSettings()
Triggers a resync of the GUI widgets for the service specific settings (i.e.
@ ConnectionWms
WMS connection.
@ ConnectionWfs
WFS connection.
@ ConnectionWcs
WCS connection.
QFlags< ConnectionType > ConnectionTypes
static const QgsSettingsEntryInteger * settingsFeatureCount
static const QgsSettingsEntryBool * settingsPreferCoordinatesForWfsT11
static const QgsSettingsEntryEnumFlag< Qgis::HttpMethod > * settingsPreferredHttpMethod
static const QgsSettingsEntryString * settingsPagingEnabled
static const QgsSettingsEntryString * settingsMaxNumFeatures
static QgsSettingsTreeNamedListNode * sTreeOwsConnections
static const QgsSettingsEntryBool * settingsIgnoreGetFeatureInfoURI
static const QgsSettingsEntryString * settingsPassword
static const QgsSettingsEntryBool * settingsReportedLayerExtents
static const QgsSettingsEntryString * settingsWfsFeatureMode
static const QgsSettingsEntryEnumFlag< Qgis::DpiMode > * settingsDpiMode
static const QgsSettingsEntryBool * settingsIgnoreAxisOrientation
static const QgsSettingsEntryBool * settingsInvertAxisOrientation
static const QgsSettingsEntryString * settingsVersion
static const QgsSettingsEntryString * settingsPagesize
static const QgsSettingsEntryString * settingsAuthCfg
static const QgsSettingsEntryEnumFlag< Qgis::TilePixelRatio > * settingsTilePixelRatio
static const QgsSettingsEntryVariantMap * settingsHeaders
static const QgsSettingsEntryString * settingsUsername
static const QgsSettingsEntryBool * settingsSmoothPixmapTransform
static const QgsSettingsEntryString * settingsUrl
static const QgsSettingsEntryBool * settingsIgnoreGetMapURI
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
bool exists(const QString &dynamicKeyPart=QString()) const
Returns true if the settings is contained in the underlying QSettings.
A boolean settings entry.
void deleteItem(const QString &item, const QStringList &parentsNamedItems=QStringList())
Deletes a 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.
Stores settings for use within QGIS.
Definition qgssettings.h:65
void sync()
Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in t...
QString fromEncodedComponent_helper(const QByteArray &ba)