QGIS API Documentation 3.43.0-Master (0cdc48caa8d)
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 mWmsOptionsGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
153
154 sbFeatureCount->setVisible( false );
155 mWmsOptionsGroupBox->layout()->removeWidget( sbFeatureCount );
156 lblFeatureCount->setVisible( false );
157 mWmsOptionsGroupBox->layout()->removeWidget( lblFeatureCount );
158
159 cmbDpiMode->setVisible( false );
160 mWmsOptionsGroupBox->layout()->removeWidget( cmbDpiMode );
161 lblDpiMode->setVisible( false );
162 mWmsOptionsGroupBox->layout()->removeWidget( lblDpiMode );
163 cmbTilePixelRatio->setVisible( false );
164 mWmsOptionsGroupBox->layout()->removeWidget( cmbTilePixelRatio );
165 lblTilePixelRatio->setVisible( false );
166 mWmsOptionsGroupBox->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
182 connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::nameChanged );
183 connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::urlChanged );
184
185 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
186 connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::updateOkButtonState );
187 connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::updateOkButtonState );
188
189 nameChanged( connectionName );
190}
191
192void QgsNewHttpConnection::wfsVersionCurrentIndexChanged( int index )
193{
194 // For now 2019-06-06, leave paging checkable for some WFS version 1.1 servers with support
195 const bool pagingOptionsEnabled = ( index == WFS_VERSION_MAX || index >= WFS_VERSION_1_1 );
196 cmbFeaturePaging->setEnabled( pagingOptionsEnabled );
197 lblPageSize->setEnabled( pagingOptionsEnabled );
198 txtPageSize->setEnabled( pagingOptionsEnabled );
199 cbxWfsIgnoreAxisOrientation->setEnabled( index != WFS_VERSION_1_0 && index != WFS_VERSION_API_FEATURES_1_0 );
200 cbxWfsInvertAxisOrientation->setEnabled( index != WFS_VERSION_API_FEATURES_1_0 );
201 wfsUseGml2EncodingForTransactions()->setEnabled( index == WFS_VERSION_1_1 );
202}
203
204void QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged( int index )
205{
206 const bool pagingNotDisabled = index != static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED );
207 lblPageSize->setEnabled( pagingNotDisabled );
208 txtPageSize->setEnabled( pagingNotDisabled );
209}
210
212{
213 return txtName->text();
214}
215
217{
218 return txtUrl->text();
219}
220
221void QgsNewHttpConnection::nameChanged( const QString &text )
222{
223 Q_UNUSED( text )
224 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
225}
226
227void QgsNewHttpConnection::urlChanged( const QString &text )
228{
229 Q_UNUSED( text )
230 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
231 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
232}
233
234void QgsNewHttpConnection::updateOkButtonState()
235{
236 const bool enabled = !txtName->text().isEmpty() && !txtUrl->text().isEmpty();
237 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
238}
239
241{
242 const QString newConnectionName = txtName->text();
243
244 bool urlExists = QgsOwsConnection::settingsUrl->exists( { mServiceName.toLower(), newConnectionName } );
245
246 // warn if entry was renamed to an existing connection
247 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 )
248 {
249 return false;
250 }
251
252 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 )
253 {
254 return false;
255 }
256
257 return true;
258}
259
261{
262 return mTestConnectionButton;
263}
264
269
271{
272 return mWfsVersionDetectButton;
273}
274
276{
277 return cmbVersion;
278}
279
281{
282 return cmbFeaturePaging;
283}
284
286{
287 return cbxWfsUseGml2EncodingForTransactions;
288}
289
291{
292 return txtPageSize;
293}
294
296{
297 return mComboHttpMethod->currentData().value< Qgis::HttpMethod >();
298}
299
300QString QgsNewHttpConnection::wfsSettingsKey( const QString &base, const QString &connectionName ) const
301{
302 return base + connectionName;
303}
304
305QString QgsNewHttpConnection::wmsSettingsKey( const QString &base, const QString &connectionName ) const
306{
307 return base + connectionName;
308}
309
311{
312 QStringList detailsParameters = { mServiceName.toLower(), mOriginalConnName };
313
314 cbxIgnoreGetMapURI->setChecked( QgsOwsConnection::settingsIgnoreGetMapURI->value( detailsParameters ) );
315 cbxWmsIgnoreReportedLayerExtents->setChecked( QgsOwsConnection::settingsReportedLayerExtents->value( detailsParameters ) );
316 cbxWfsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
317 cbxWfsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
318 cbxWfsUseGml2EncodingForTransactions->setChecked( QgsOwsConnection::settingsPreferCoordinatesForWfsT11->value( detailsParameters ) );
319
320 cbxWmsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
321 cbxWmsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
322 cbxIgnoreGetFeatureInfoURI->setChecked( QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->value( detailsParameters ) );
323 cbxSmoothPixmapTransform->setChecked( QgsOwsConnection::settingsSmoothPixmapTransform->value( detailsParameters ) );
324
325 Qgis::DpiMode dpiMode = QgsOwsConnection::settingsDpiMode->value( detailsParameters );
326 cmbDpiMode->setCurrentIndex( cmbDpiMode->findData( static_cast<int>( dpiMode ) ) );
327 Qgis::TilePixelRatio tilePixelRatio = QgsOwsConnection::settingsTilePixelRatio->value( detailsParameters );
328 cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData( static_cast<int>( tilePixelRatio ) ) );
329
330 sbFeatureCount->setValue( QgsOwsConnection::settingsFeatureCount->value( detailsParameters ) );
331
332 const QString version = QgsOwsConnection::settingsVersion->value( detailsParameters );
333 int versionIdx = WFS_VERSION_MAX; // AUTO
334 if ( version == QLatin1String( "1.0.0" ) )
335 versionIdx = WFS_VERSION_1_0;
336 else if ( version == QLatin1String( "1.1.0" ) )
337 versionIdx = WFS_VERSION_1_1;
338 else if ( version == QLatin1String( "2.0.0" ) )
339 versionIdx = WFS_VERSION_2_0;
340 else if ( version == QLatin1String( "OGC_API_FEATURES" ) )
341 versionIdx = WFS_VERSION_API_FEATURES_1_0;
342 cmbVersion->setCurrentIndex( versionIdx );
343
344 // Enable/disable these items per WFS versions
345 wfsVersionCurrentIndexChanged( versionIdx );
346
347 mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( { mServiceName.toLower(), mOriginalConnName } ) ) );
348
349 txtMaxNumFeatures->setText( QgsOwsConnection::settingsMaxNumFeatures->value( detailsParameters ) );
350
351 // Only default to paging enabled if WFS 2.0.0 or higher
352 const QString pagingEnabled = QgsOwsConnection::settingsPagingEnabled->value( detailsParameters );
353 if ( pagingEnabled == QLatin1String( "enabled" ) )
354 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::ENABLED ) );
355 else if ( pagingEnabled == QLatin1String( "disabled" ) )
356 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED ) );
357 else
358 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DEFAULT ) );
359
360 const QString wfsFeatureMode = QgsOwsConnection::settingsWfsFeatureMode->value( detailsParameters );
361 mComboWfsFeatureMode->setCurrentIndex( std::max( mComboWfsFeatureMode->findData( wfsFeatureMode ), 0 ) );
362
363 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue( QgsOwsConnection::settingsPreferredHttpMethod->value( detailsParameters ) ) ) );
364 txtPageSize->setText( QgsOwsConnection::settingsPagesize->value( detailsParameters ) );
365}
366
367void QgsNewHttpConnection::showEvent( QShowEvent *event )
368{
369 QDialog::showEvent( event );
370}
371
373{
374 QUrl url( txtUrl->text().trimmed() );
375 QUrlQuery query( url );
376 const QList<QPair<QString, QString>> items = query.queryItems( QUrl::FullyEncoded );
377 QHash<QString, QPair<QString, QString>> params;
378 for ( const QPair<QString, QString> &it : items )
379 {
380 params.insert( it.first.toUpper(), it );
381 }
382
383 if ( params[QStringLiteral( "SERVICE" )].second.toUpper() == "WMS" || params[QStringLiteral( "SERVICE" )].second.toUpper() == "WFS" || params[QStringLiteral( "SERVICE" )].second.toUpper() == "WCS" )
384 {
385 query.removeQueryItem( params.value( QStringLiteral( "SERVICE" ) ).first );
386 query.removeQueryItem( params.value( QStringLiteral( "REQUEST" ) ).first );
387 query.removeQueryItem( params.value( QStringLiteral( "FORMAT" ) ).first );
388 }
389
390 url.setQuery( query );
391
392 if ( url.path( QUrl::FullyEncoded ).isEmpty() )
393 {
394 url.setPath( fromEncodedComponent_helper( "/" ) );
395 }
396 return url;
397}
398
400{
401 const QString newConnectionName = txtName->text();
402
403 if ( !validate() )
404 return;
405
406 QgsSettings settings;
407
408 // on rename delete original entry first
409 if ( !mOriginalConnName.isNull() && mOriginalConnName != newConnectionName )
410 {
411 QgsOwsConnection::sTreeOwsConnections->deleteItem( mOriginalConnName, { mServiceName.toLower() } );
412 settings.sync();
413 }
414
415 QStringList detailsParameters = { mServiceName.toLower(), newConnectionName };
416
417 const QUrl url( urlTrimmed() );
418 QgsOwsConnection::settingsUrl->setValue( url.toString(), detailsParameters );
419
420 if ( mTypes & ConnectionWfs )
421 {
422 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWfsIgnoreAxisOrientation->isChecked(), detailsParameters );
423 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWfsInvertAxisOrientation->isChecked(), detailsParameters );
424 QgsOwsConnection::settingsPreferCoordinatesForWfsT11->setValue( cbxWfsUseGml2EncodingForTransactions->isChecked(), detailsParameters );
425 }
426 if ( mTypes & ConnectionWms || mTypes & ConnectionWcs )
427 {
428 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWmsIgnoreAxisOrientation->isChecked(), detailsParameters );
429 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWmsInvertAxisOrientation->isChecked(), detailsParameters );
430
431 QgsOwsConnection::settingsReportedLayerExtents->setValue( cbxWmsIgnoreReportedLayerExtents->isChecked(), detailsParameters );
432 QgsOwsConnection::settingsIgnoreGetMapURI->setValue( cbxIgnoreGetMapURI->isChecked(), detailsParameters );
433 QgsOwsConnection::settingsSmoothPixmapTransform->setValue( cbxSmoothPixmapTransform->isChecked(), detailsParameters );
434
435 Qgis::DpiMode dpiMode = cmbDpiMode->currentData().value<Qgis::DpiMode>();
436 QgsOwsConnection::settingsDpiMode->setValue( dpiMode, detailsParameters );
437 Qgis::TilePixelRatio tilePixelRatio = cmbTilePixelRatio->currentData().value<Qgis::TilePixelRatio>();
438 QgsOwsConnection::settingsTilePixelRatio->setValue( tilePixelRatio, detailsParameters );
439
440 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), detailsParameters );
441 }
442 if ( mTypes & ConnectionWms )
443 {
444 QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->setValue( cbxIgnoreGetFeatureInfoURI->isChecked(), detailsParameters );
445 QgsOwsConnection::settingsFeatureCount->setValue( sbFeatureCount->value(), detailsParameters );
446 }
447 if ( mTypes & ConnectionWfs )
448 {
449 QString version = QStringLiteral( "auto" );
450 switch ( cmbVersion->currentIndex() )
451 {
452 case WFS_VERSION_MAX:
453 version = QStringLiteral( "auto" );
454 break;
455 case WFS_VERSION_1_0:
456 version = QStringLiteral( "1.0.0" );
457 break;
458 case WFS_VERSION_1_1:
459 version = QStringLiteral( "1.1.0" );
460 break;
461 case WFS_VERSION_2_0:
462 version = QStringLiteral( "2.0.0" );
463 break;
465 version = QStringLiteral( "OGC_API_FEATURES" );
466 break;
467 }
468 QgsOwsConnection::settingsVersion->setValue( version, detailsParameters );
469 QgsOwsConnection::settingsMaxNumFeatures->setValue( txtMaxNumFeatures->text(), detailsParameters );
470 QgsOwsConnection::settingsPagesize->setValue( txtPageSize->text(), detailsParameters );
471 QgsOwsConnection::settingsPreferredHttpMethod->setValue( mComboHttpMethod->currentData().value< Qgis::HttpMethod >(), detailsParameters );
472
473 QString pagingEnabled = QStringLiteral( "default" );
474 switch ( cmbFeaturePaging->currentIndex() )
475 {
477 pagingEnabled = QStringLiteral( "default" );
478 break;
480 pagingEnabled = QStringLiteral( "enabled" );
481 break;
483 pagingEnabled = QStringLiteral( "disabled" );
484 break;
485 }
486 QgsOwsConnection::settingsPagingEnabled->setValue( pagingEnabled, detailsParameters );
487
488 const QString featureMode = mComboWfsFeatureMode->currentData().toString();
489 QgsOwsConnection::settingsWfsFeatureMode->setValue( featureMode, detailsParameters );
490 }
491
492 QStringList credentialsParameters = { mServiceName.toLower(), newConnectionName };
493 QgsOwsConnection::settingsUsername->setValue( mAuthSettings->username(), credentialsParameters );
494 QgsOwsConnection::settingsPassword->setValue( mAuthSettings->password(), credentialsParameters );
495 QgsOwsConnection::settingsAuthCfg->setValue( mAuthSettings->configId(), credentialsParameters );
496
497 if ( mHttpHeaders->isVisible() )
498 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), credentialsParameters );
499
500 QgsOwsConnection::sTreeOwsConnections->setSelectedItem( newConnectionName, { mServiceName.toLower() } );
501
502 QDialog::accept();
503}
504
505void QgsNewHttpConnection::showHelp()
506{
507 QgsHelp::openHelp( QStringLiteral( "working_with_ogc/index.html" ) );
508}
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.
void showEvent(QShowEvent *event) override
Adjust height of dialog to fit the content.
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)