QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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
21#include "qgsgui.h"
22#include "qgshelp.h"
23#include "qgsowsconnection.h"
24#include "qgssettings.h"
27
28#include <QMessageBox>
29#include <QPushButton>
30#include <QRegularExpression>
31#include <QRegularExpressionValidator>
32#include <QString>
33#include <QUrl>
34#include <QUrlQuery>
35
36#include "moc_qgsnewhttpconnection.cpp"
37
38using namespace Qt::StringLiterals;
39
40const QgsSettingsEntryBool *QgsNewHttpConnection::settingsIgnoreReportedLayerExtentsDefault = new QgsSettingsEntryBool( u"ignore-reported-layer-extents-default"_s, sTreeHttpConnectionDialog, false );
41
42QgsNewHttpConnection::QgsNewHttpConnection( QWidget *parent, ConnectionTypes types, const QString &serviceName, const QString &connectionName, QgsNewHttpConnection::Flags flags, Qt::WindowFlags fl )
43 : QDialog( parent, fl )
44 , mTypes( types )
45 , mServiceName( serviceName )
46 , mOriginalConnName( connectionName )
47{
48 setupUi( this );
49
50 // compatibility fix with former API (pre 3.26) when serviceName was a setting key instead
51 if ( mServiceName.startsWith( "qgis/"_L1 ) )
52 {
53 // It would be obviously much better to use mBaseKey also for credentials,
54 // but for some strange reason a different hardcoded key was used instead.
55 // WFS and WMS credentials were mixed with the same key WMS.
56 // Only WMS and WFS providers are using QgsNewHttpConnection at this moment
57 // using connection-wms and connection-wfs -> parse credential key from it.
58 mServiceName = mServiceName.split( '-' ).last().toUpper();
59 }
60
61 if ( !( flags & FlagShowHttpSettings ) )
62 mHttpHeaders->hide();
63
65
66 connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsNewHttpConnection::showHelp );
67
68 QString connectionType = mServiceName;
69 if ( mServiceName == "WMS"_L1 )
70 {
71 connectionType = u"WMS/WMTS"_s;
72 }
73
74 if ( connectionName.isEmpty() )
75 {
76 setWindowTitle( tr( "Create a New %1 Connection" ).arg( connectionType ) );
77 }
78 else
79 {
80 setWindowTitle( tr( "Edit %1 Connection \"%2\"" ).arg( connectionType, connectionName ) );
81 }
82
83 txtName->setValidator( new QRegularExpressionValidator( QRegularExpression( "[^\\/]+" ), txtName ) );
84
85 cmbDpiMode->clear();
86 cmbDpiMode->addItem( tr( "all" ), static_cast<int>( Qgis::DpiMode::All ) );
87 cmbDpiMode->addItem( tr( "off" ), static_cast<int>( Qgis::DpiMode::Off ) );
88 cmbDpiMode->addItem( tr( "QGIS" ), static_cast<int>( Qgis::DpiMode::QGIS ) );
89 cmbDpiMode->addItem( tr( "UMN" ), static_cast<int>( Qgis::DpiMode::UMN ) );
90 cmbDpiMode->addItem( tr( "GeoServer" ), static_cast<int>( Qgis::DpiMode::GeoServer ) );
91
92 cmbTilePixelRatio->clear();
93 cmbTilePixelRatio->addItem( tr( "Undefined (not scaled)" ), static_cast<int>( Qgis::TilePixelRatio::Undefined ) );
94 cmbTilePixelRatio->addItem( tr( "Standard (96 DPI)" ), static_cast<int>( Qgis::TilePixelRatio::StandardDpi ) );
95 cmbTilePixelRatio->addItem( tr( "High (192 DPI)" ), static_cast<int>( Qgis::TilePixelRatio::HighDpi ) );
96
97 cmbVersion->clear();
98 cmbVersion->addItem( tr( "Maximum" ) );
99 cmbVersion->addItem( tr( "1.0" ) );
100 cmbVersion->addItem( tr( "1.1" ) );
101 cmbVersion->addItem( tr( "2.0" ) );
102 cmbVersion->addItem( tr( "OGC API - Features" ) );
103 connect( cmbVersion, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewHttpConnection::wfsVersionCurrentIndexChanged );
104
105 mFeatureFormatComboBox->clear();
106 mFeatureFormatComboBox->addItem( tr( "Default" ), u"default"_s );
107 connect( mFeatureFormatComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewHttpConnection::featureFormatCurrentIndexChanged );
108
109 mComboWfsFeatureMode->clear();
110 mComboWfsFeatureMode->addItem( tr( "Default" ), u"default"_s );
111 mComboWfsFeatureMode->addItem( tr( "Simple Features" ), u"simpleFeatures"_s );
112 mComboWfsFeatureMode->addItem( tr( "Complex Features" ), u"complexFeatures"_s );
113
114 mComboHttpMethod->addItem( u"GET"_s, QVariant::fromValue( Qgis::HttpMethod::Get ) );
115 mComboHttpMethod->addItem( u"POST"_s, QVariant::fromValue( Qgis::HttpMethod::Post ) );
116 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue( Qgis::HttpMethod::Get ) ) );
117
118 cmbFeaturePaging->clear();
119 cmbFeaturePaging->addItem( tr( "Default (trust server capabilities)" ) );
120 cmbFeaturePaging->addItem( tr( "Enabled" ) );
121 cmbFeaturePaging->addItem( tr( "Disabled" ) );
122 connect( cmbFeaturePaging, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged );
123
124 cbxWmsIgnoreReportedLayerExtents->setChecked( settingsIgnoreReportedLayerExtentsDefault->value() );
125
126 if ( !connectionName.isEmpty() )
127 {
128 // populate the dialog with the information stored for the connection
129 // populate the fields with the stored setting parameters
130
131 txtName->setText( connectionName );
132 const QStringList detailParameters { mServiceName.toLower(), connectionName };
133 txtUrl->setText( QgsOwsConnection::settingsUrl->value( detailParameters ) );
134 mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( detailParameters ) ) );
135
137
138 // Authentication
139 mAuthSettings->setUsername( QgsOwsConnection::settingsUsername->value( detailParameters ) );
140 mAuthSettings->setPassword( QgsOwsConnection::settingsPassword->value( detailParameters ) );
141 mAuthSettings->setConfigId( QgsOwsConnection::settingsAuthCfg->value( detailParameters ) );
142 }
143
144 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
145
146 if ( !( mTypes & ConnectionWms ) && !( mTypes & ConnectionWcs ) )
147 {
148 mWmsOptionsGroupBox->setVisible( false );
149 mGroupBox->layout()->removeWidget( mWmsOptionsGroupBox );
150 }
151 if ( !( mTypes & ConnectionWfs ) )
152 {
153 mWfsOptionsGroupBox->setVisible( false );
154 mGroupBox->layout()->removeWidget( mWfsOptionsGroupBox );
155 }
156 else
157 {
158 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)" ) );
159 }
160
161 if ( mTypes & ConnectionWcs )
162 {
163 cbxIgnoreGetMapURI->setText( tr( "Ignore GetCoverage URI reported in capabilities" ) );
164 cbxWmsIgnoreAxisOrientation->setText( tr( "Ignore axis orientation" ) );
165 if ( !( mTypes & ConnectionWms ) )
166 {
167 mWmsOptionsGroupBox->setTitle( tr( "WCS Options" ) );
168
169 cbxIgnoreGetFeatureInfoURI->setVisible( false );
170 mWmsOptionsGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
171
172 sbFeatureCount->setVisible( false );
173 mWmsOptionsGroupBox->layout()->removeWidget( sbFeatureCount );
174 lblFeatureCount->setVisible( false );
175 mWmsOptionsGroupBox->layout()->removeWidget( lblFeatureCount );
176
177 cmbDpiMode->setVisible( false );
178 mWmsOptionsGroupBox->layout()->removeWidget( cmbDpiMode );
179 lblDpiMode->setVisible( false );
180 mWmsOptionsGroupBox->layout()->removeWidget( lblDpiMode );
181 cmbTilePixelRatio->setVisible( false );
182 mWmsOptionsGroupBox->layout()->removeWidget( cmbTilePixelRatio );
183 lblTilePixelRatio->setVisible( false );
184 mWmsOptionsGroupBox->layout()->removeWidget( lblTilePixelRatio );
185 }
186 }
187
188 if ( !( flags & FlagShowTestConnection ) )
189 {
190 mTestConnectionButton->hide();
191 mGroupBox->layout()->removeWidget( mTestConnectionButton );
192 }
193
194 if ( flags & FlagHideAuthenticationGroup )
195 {
196 mAuthGroupBox->hide();
197 mGroupBox->layout()->removeWidget( mAuthGroupBox );
198 }
199
200 mWmsFormatDetectButton->setDisabled( txtUrl->text().isEmpty() );
201
202 connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::nameChanged );
203 connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::urlChanged );
204
205 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( true );
206 connect( txtName, &QLineEdit::textChanged, this, &QgsNewHttpConnection::updateOkButtonState );
207 connect( txtUrl, &QLineEdit::textChanged, this, &QgsNewHttpConnection::updateOkButtonState );
208
209 nameChanged( connectionName );
210}
211
212void QgsNewHttpConnection::wfsVersionCurrentIndexChanged( int index )
213{
214 // For now 2019-06-06, leave paging checkable for some WFS version 1.1 servers with support
215 const bool pagingOptionsEnabled = ( index == WFS_VERSION_MAX || index >= WFS_VERSION_1_1 );
216 lblFeaturePaging->setEnabled( pagingOptionsEnabled );
217 cmbFeaturePaging->setEnabled( pagingOptionsEnabled );
218 lblPageSize->setEnabled( pagingOptionsEnabled );
219 txtPageSize->setEnabled( pagingOptionsEnabled );
220 cbxWfsIgnoreAxisOrientation->setEnabled( index != WFS_VERSION_1_0 && index != WFS_VERSION_API_FEATURES_1_0 );
221 cbxWfsInvertAxisOrientation->setEnabled( index != WFS_VERSION_API_FEATURES_1_0 );
222 wfsUseGml2EncodingForTransactions()->setEnabled( index == WFS_VERSION_1_1 );
223 cbxWfsForceInitialGetFeature->setEnabled( index != WFS_VERSION_API_FEATURES_1_0 );
224
225 featureFormatComboBox()->setEnabled( index == WFS_VERSION_MAX || index == WFS_VERSION_API_FEATURES_1_0 );
226 featureFormatDetectButton()->setEnabled( index == WFS_VERSION_MAX || index == WFS_VERSION_API_FEATURES_1_0 );
227 mComboWfsFeatureMode->setEnabled( index != WFS_VERSION_API_FEATURES_1_0 || featureFormatComboBox()->currentData().toString().indexOf( "gml"_L1 ) >= 0 );
228}
229
230void QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged( int index )
231{
232 const bool pagingNotDisabled = index != static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED );
233 lblPageSize->setEnabled( pagingNotDisabled );
234 txtPageSize->setEnabled( pagingNotDisabled );
235}
236
237void QgsNewHttpConnection::featureFormatCurrentIndexChanged( int index )
238{
239 Q_UNUSED( index );
240 mComboWfsFeatureMode->setEnabled( wfsVersionComboBox()->currentIndex() != WFS_VERSION_API_FEATURES_1_0 || featureFormatComboBox()->currentData().toString().indexOf( "gml"_L1 ) >= 0 );
241}
242
244{
245 return txtName->text();
246}
247
249{
250 return txtUrl->text();
251}
252
253void QgsNewHttpConnection::nameChanged( const QString &text )
254{
255 Q_UNUSED( text )
256 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
257}
258
259void QgsNewHttpConnection::urlChanged( const QString &text )
260{
261 Q_UNUSED( text )
262 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
263 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
264 mWmsFormatDetectButton->setDisabled( txtUrl->text().isEmpty() );
265}
266
267void QgsNewHttpConnection::updateOkButtonState()
268{
269 const bool enabled = !txtName->text().isEmpty() && !txtUrl->text().isEmpty();
270 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
271}
272
274{
275 const QString newConnectionName = txtName->text();
276
277 bool urlExists = QgsOwsConnection::settingsUrl->exists( { mServiceName.toLower(), newConnectionName } );
278
279 // warn if entry was renamed to an existing connection
280 if ( ( mOriginalConnName.isNull() || mOriginalConnName.compare( newConnectionName, Qt::CaseInsensitive ) != 0 )
281 && urlExists
282 && QMessageBox::question( this, tr( "Save Connection" ), tr( "Should the existing connection %1 be overwritten?" ).arg( txtName->text() ), QMessageBox::Ok | QMessageBox::Cancel )
283 == QMessageBox::Cancel )
284 {
285 return false;
286 }
287
288 if ( !mAuthSettings->password().isEmpty()
289 && QMessageBox::question(
290 this,
291 tr( "Saving Passwords" ),
292 tr(
293 "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 "
294 "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 "
295 "your credentials in an HTTP Basic Authentication method and store them in an encrypted database."
296 ),
297 QMessageBox::Ok | QMessageBox::Cancel
298 ) == QMessageBox::Cancel )
299 {
300 return false;
301 }
302
303 return true;
304}
305
307{
308 return mTestConnectionButton;
309}
310
312{
313 return mWmsFormatDetectButton;
314}
315
320
322{
323 return QgsAuthorizationSettings( mAuthSettings->username(), mAuthSettings->password(), mHttpHeaders->httpHeaders(), mAuthSettings->configId() );
324}
325
327{
328 return cbxWmsIgnoreAxisOrientation->isChecked();
329}
330
332{
333 return mWmsPreferredFormatCombo;
334}
335
337{
338 return cbxWmsInvertAxisOrientation->isChecked();
339}
340
341
343{
344 return mWfsVersionDetectButton;
345}
346
348{
349 return cmbVersion;
350}
351
353{
354 return mFeatureFormatDetectButton;
355}
356
358{
359 return mFeatureFormatComboBox;
360}
361
363{
364 return cmbFeaturePaging;
365}
366
368{
369 return cbxWfsUseGml2EncodingForTransactions;
370}
371
373{
374 return txtPageSize;
375}
376
378{
379 return mComboHttpMethod->currentData().value< Qgis::HttpMethod >();
380}
381
382QString QgsNewHttpConnection::wfsSettingsKey( const QString &base, const QString &connectionName ) const
383{
384 return base + connectionName;
385}
386
387QString QgsNewHttpConnection::wmsSettingsKey( const QString &base, const QString &connectionName ) const
388{
389 return base + connectionName;
390}
391
393{
394 QStringList detailsParameters = { mServiceName.toLower(), mOriginalConnName };
395
396 cbxIgnoreGetMapURI->setChecked( QgsOwsConnection::settingsIgnoreGetMapURI->value( detailsParameters ) );
397 cbxWmsIgnoreReportedLayerExtents->setChecked( QgsOwsConnection::settingsReportedLayerExtents->value( detailsParameters ) );
398 cbxWfsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
399 cbxWfsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
400 cbxWfsUseGml2EncodingForTransactions->setChecked( QgsOwsConnection::settingsPreferCoordinatesForWfsT11->value( detailsParameters ) );
401 cbxWfsForceInitialGetFeature->setChecked( QgsOwsConnection::settingsWfsForceInitialGetFeature->value( detailsParameters ) );
402
403 cbxWmsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
404 cbxWmsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
405 cbxIgnoreGetFeatureInfoURI->setChecked( QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->value( detailsParameters ) );
406 cbxSmoothPixmapTransform->setChecked( QgsOwsConnection::settingsSmoothPixmapTransform->value( detailsParameters ) );
407
408 Qgis::DpiMode dpiMode = QgsOwsConnection::settingsDpiMode->value( detailsParameters );
409 cmbDpiMode->setCurrentIndex( cmbDpiMode->findData( static_cast<int>( dpiMode ) ) );
410
411 Qgis::TilePixelRatio tilePixelRatio = QgsOwsConnection::settingsTilePixelRatio->value( detailsParameters );
412 cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData( static_cast<int>( tilePixelRatio ) ) );
413
414 sbFeatureCount->setValue( QgsOwsConnection::settingsFeatureCount->value( detailsParameters ) );
415
416 const QString version = QgsOwsConnection::settingsVersion->value( detailsParameters );
417 int versionIdx = WFS_VERSION_MAX; // AUTO
418 if ( version == "1.0.0"_L1 )
419 versionIdx = WFS_VERSION_1_0;
420 else if ( version == "1.1.0"_L1 )
421 versionIdx = WFS_VERSION_1_1;
422 else if ( version == "2.0.0"_L1 )
423 versionIdx = WFS_VERSION_2_0;
424 else if ( version == "OGC_API_FEATURES"_L1 )
425 versionIdx = WFS_VERSION_API_FEATURES_1_0;
426 cmbVersion->setCurrentIndex( versionIdx );
427
428 // Enable/disable these items per WFS versions
429 wfsVersionCurrentIndexChanged( versionIdx );
430
431 mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( { mServiceName.toLower(), mOriginalConnName } ) ) );
432
433 txtMaxNumFeatures->setText( QgsOwsConnection::settingsMaxNumFeatures->value( detailsParameters ) );
434
435 // Only default to paging enabled if WFS 2.0.0 or higher
436 const QString pagingEnabled = QgsOwsConnection::settingsPagingEnabled->value( detailsParameters );
437 if ( pagingEnabled == "enabled"_L1 )
438 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::ENABLED ) );
439 else if ( pagingEnabled == "disabled"_L1 )
440 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED ) );
441 else
442 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DEFAULT ) );
443
444 const QString wfsFeatureMode = QgsOwsConnection::settingsWfsFeatureMode->value( detailsParameters );
445 mComboWfsFeatureMode->setCurrentIndex( std::max( mComboWfsFeatureMode->findData( wfsFeatureMode ), 0 ) );
446
447 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue( QgsOwsConnection::settingsPreferredHttpMethod->value( detailsParameters ) ) ) );
448 txtPageSize->setText( QgsOwsConnection::settingsPagesize->value( detailsParameters ) );
449}
450
451void QgsNewHttpConnection::showEvent( QShowEvent *event )
452{
453 QDialog::showEvent( event );
454}
455
457{
458 return mOriginalConnName;
459}
460
462{
463 QUrl url( txtUrl->text().trimmed() );
464 QUrlQuery query( url );
465 const QList<QPair<QString, QString>> items = query.queryItems( QUrl::FullyEncoded );
466 QHash<QString, QPair<QString, QString>> params;
467 for ( const QPair<QString, QString> &it : items )
468 {
469 params.insert( it.first.toUpper(), it );
470 }
471
472 if ( params[u"SERVICE"_s].second.toUpper() == "WMS" || params[u"SERVICE"_s].second.toUpper() == "WFS" || params[u"SERVICE"_s].second.toUpper() == "WCS" )
473 {
474 query.removeQueryItem( params.value( u"SERVICE"_s ).first );
475 query.removeQueryItem( params.value( u"REQUEST"_s ).first );
476 query.removeQueryItem( params.value( u"FORMAT"_s ).first );
477 }
478
479 url.setQuery( query );
480
481 if ( url.path( QUrl::FullyEncoded ).isEmpty() )
482 {
483 url.setPath( fromEncodedComponent_helper( "/" ) );
484 }
485 return url;
486}
487
489{
490 const QString newConnectionName = txtName->text();
491
492 if ( !validate() )
493 return;
494
495 QgsSettings settings;
496
497 // on rename delete original entry first
498 if ( !mOriginalConnName.isNull() && mOriginalConnName != newConnectionName )
499 {
500 QgsOwsConnection::sTreeOwsConnections->deleteItem( mOriginalConnName, { mServiceName.toLower() } );
501 settings.sync();
502 }
503
504 QStringList detailsParameters = { mServiceName.toLower(), newConnectionName };
505
506 const QUrl url( urlTrimmed() );
507 QgsOwsConnection::settingsUrl->setValue( url.toString(), detailsParameters );
508
509 if ( mTypes & ConnectionWfs )
510 {
511 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWfsIgnoreAxisOrientation->isChecked(), detailsParameters );
512 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWfsInvertAxisOrientation->isChecked(), detailsParameters );
513 QgsOwsConnection::settingsPreferCoordinatesForWfsT11->setValue( cbxWfsUseGml2EncodingForTransactions->isChecked(), detailsParameters );
514 QgsOwsConnection::settingsWfsForceInitialGetFeature->setValue( cbxWfsForceInitialGetFeature->isChecked(), detailsParameters );
515
516 // Get all values from the combo
517 QStringList availableFormats;
518 for ( int i = 0; i < mFeatureFormatComboBox->count(); ++i )
519 {
520 availableFormats.append( mFeatureFormatComboBox->itemData( i ).toString() );
521 }
522 QString format = mFeatureFormatComboBox->currentData().toString();
523 QgsOwsConnection::settingsDefaultFeatureFormat->setValue( format, detailsParameters );
524 settings.setValue( u"/qgis/lastFeatureFormatEncoding"_s, format );
525 QgsOwsConnection::settingsAvailableFeatureFormats->setValue( availableFormats, detailsParameters );
526 }
527 if ( mTypes & ConnectionWms || mTypes & ConnectionWcs )
528 {
529 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWmsIgnoreAxisOrientation->isChecked(), detailsParameters );
530 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWmsInvertAxisOrientation->isChecked(), detailsParameters );
531
532 QgsOwsConnection::settingsReportedLayerExtents->setValue( cbxWmsIgnoreReportedLayerExtents->isChecked(), detailsParameters );
533 QgsOwsConnection::settingsIgnoreGetMapURI->setValue( cbxIgnoreGetMapURI->isChecked(), detailsParameters );
534 QgsOwsConnection::settingsSmoothPixmapTransform->setValue( cbxSmoothPixmapTransform->isChecked(), detailsParameters );
535
536 Qgis::DpiMode dpiMode = cmbDpiMode->currentData().value<Qgis::DpiMode>();
537 QgsOwsConnection::settingsDpiMode->setValue( dpiMode, detailsParameters );
538 // Get all values from the combo
539 QStringList availableFormats;
540 for ( int i = 0; i < mWmsPreferredFormatCombo->count(); ++i )
541 {
542 availableFormats.append( mWmsPreferredFormatCombo->itemData( i ).toString() );
543 }
544 QgsOwsConnection::settingsDefaultImageFormat->setValue( mWmsPreferredFormatCombo->currentData().toString(), detailsParameters );
545 QgsOwsConnection::settingsAvailableImageFormats->setValue( availableFormats, detailsParameters );
546 Qgis::TilePixelRatio tilePixelRatio = cmbTilePixelRatio->currentData().value<Qgis::TilePixelRatio>();
547 QgsOwsConnection::settingsTilePixelRatio->setValue( tilePixelRatio, detailsParameters );
548
549 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), detailsParameters );
550 }
551 if ( mTypes & ConnectionWms )
552 {
553 QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->setValue( cbxIgnoreGetFeatureInfoURI->isChecked(), detailsParameters );
554 QgsOwsConnection::settingsFeatureCount->setValue( sbFeatureCount->value(), detailsParameters );
555 }
556 if ( mTypes & ConnectionWfs )
557 {
558 QString version = u"auto"_s;
559 switch ( cmbVersion->currentIndex() )
560 {
561 case WFS_VERSION_MAX:
562 version = u"auto"_s;
563 break;
564 case WFS_VERSION_1_0:
565 version = u"1.0.0"_s;
566 break;
567 case WFS_VERSION_1_1:
568 version = u"1.1.0"_s;
569 break;
570 case WFS_VERSION_2_0:
571 version = u"2.0.0"_s;
572 break;
574 version = u"OGC_API_FEATURES"_s;
575 break;
576 }
577 QgsOwsConnection::settingsVersion->setValue( version, detailsParameters );
578 QgsOwsConnection::settingsMaxNumFeatures->setValue( txtMaxNumFeatures->text(), detailsParameters );
579 QgsOwsConnection::settingsPagesize->setValue( txtPageSize->text(), detailsParameters );
580 QgsOwsConnection::settingsPreferredHttpMethod->setValue( mComboHttpMethod->currentData().value< Qgis::HttpMethod >(), detailsParameters );
581
582 QString pagingEnabled = u"default"_s;
583 switch ( cmbFeaturePaging->currentIndex() )
584 {
586 pagingEnabled = u"default"_s;
587 break;
589 pagingEnabled = u"enabled"_s;
590 break;
592 pagingEnabled = u"disabled"_s;
593 break;
594 }
595 QgsOwsConnection::settingsPagingEnabled->setValue( pagingEnabled, detailsParameters );
596
597 const QString featureMode = mComboWfsFeatureMode->currentData().toString();
598 QgsOwsConnection::settingsWfsFeatureMode->setValue( featureMode, detailsParameters );
599 }
600
601 QStringList credentialsParameters = { mServiceName.toLower(), newConnectionName };
602 QgsOwsConnection::settingsUsername->setValue( mAuthSettings->username(), credentialsParameters );
603 QgsOwsConnection::settingsPassword->setValue( mAuthSettings->password(), credentialsParameters );
604 QgsOwsConnection::settingsAuthCfg->setValue( mAuthSettings->configId(), credentialsParameters );
605
606 if ( mHttpHeaders->isVisible() )
607 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), credentialsParameters );
608
609 QgsOwsConnection::sTreeOwsConnections->setSelectedItem( newConnectionName, { mServiceName.toLower() } );
610
611 QDialog::accept();
612}
613
614void QgsNewHttpConnection::showHelp()
615{
616 QgsHelp::openHelp( u"working_with_ogc/index.html"_s );
617}
TilePixelRatio
DpiMode enum.
Definition qgis.h:3486
@ Undefined
Undefined (not scale).
Definition qgis.h:3487
@ HighDpi
High (192 DPI).
Definition qgis.h:3489
@ StandardDpi
Standard (96 DPI).
Definition qgis.h:3488
DpiMode
DpiMode enum.
Definition qgis.h:3472
@ GeoServer
GeoServer.
Definition qgis.h:3477
@ QGIS
QGIS.
Definition qgis.h:3475
@ All
All.
Definition qgis.h:3473
@ Off
Off.
Definition qgis.h:3474
@ UMN
UMN.
Definition qgis.h:3476
HttpMethod
Different methods of HTTP requests.
Definition qgis.h:1063
@ Post
POST method.
Definition qgis.h:1065
@ Get
GET method.
Definition qgis.h:1064
Widget for entering authentication credentials both in the form username/password and by using QGIS A...
Utility class that contains authorization information.
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:224
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition qgshelp.cpp:41
Implements simple HTTP header management.
Qgis::HttpMethod preferredHttpMethod() const
Returns the selected preferred HTTP method.
QgsAuthorizationSettings authorizationSettings() const
Returns the authorization settings.
QPushButton * testConnectButton()
Returns the "test connection" button.
bool invertAxisOrientation() const
Returns the invert axis orientation checkbox status.
void showEvent(QShowEvent *event) override
Adjust height of dialog to fit the content.
QComboBox * featureFormatComboBox()
Returns the "Feature format" combobox.
QgsAuthSettingsWidget * authSettingsWidget()
Returns the current authentication settings widget.
QComboBox * wfsPagingComboBox()
Returns the "WFS paging" combobox.
QPushButton * featureFormatDetectButton()
Returns the "Feature format detect" button.
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.
QPushButton * wmsFormatDetectButton()
Returns the WMS Format Detect Button.
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.
QString originalConnectionName() const
Returns the original connection name (might be empty).
static const QgsSettingsEntryBool * settingsIgnoreReportedLayerExtentsDefault
QUrl urlTrimmed() const
Returns the url.
QLineEdit * wfsPageSizeLineEdit()
Returns the "WFS page size" edit.
bool ignoreAxisOrientation() const
Returns the ignore axis orientation checkbox status.
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
QComboBox * wmsPreferredFormatCombo() const
Returns the "WMS preferred format" combobox.
static const QgsSettingsEntryInteger * settingsFeatureCount
static const QgsSettingsEntryStringList * settingsAvailableImageFormats
static const QgsSettingsEntryBool * settingsPreferCoordinatesForWfsT11
static const QgsSettingsEntryEnumFlag< Qgis::HttpMethod > * settingsPreferredHttpMethod
static const QgsSettingsEntryString * settingsPagingEnabled
static const QgsSettingsEntryString * settingsDefaultImageFormat
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 * settingsWfsForceInitialGetFeature
static const QgsSettingsEntryBool * settingsIgnoreAxisOrientation
static const QgsSettingsEntryString * settingsDefaultFeatureFormat
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
static const QgsSettingsEntryStringList * settingsAvailableFeatureFormats
A boolean settings entry.
Stores settings for use within QGIS.
Definition qgssettings.h:68
void sync()
Writes any unsaved changes to permanent storage, and reloads any settings that have been changed in t...
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QString fromEncodedComponent_helper(const QByteArray &ba)