QGIS API Documentation 3.99.0-Master (d270888f95f)
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(
228 index != WFS_VERSION_API_FEATURES_1_0 || featureFormatComboBox()->currentData().toString().indexOf( "gml"_L1 ) >= 0
229 );
230}
231
232void QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged( int index )
233{
234 const bool pagingNotDisabled = index != static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED );
235 lblPageSize->setEnabled( pagingNotDisabled );
236 txtPageSize->setEnabled( pagingNotDisabled );
237}
238
239void QgsNewHttpConnection::featureFormatCurrentIndexChanged( int index )
240{
241 Q_UNUSED( index );
242 mComboWfsFeatureMode->setEnabled(
243 wfsVersionComboBox()->currentIndex() != WFS_VERSION_API_FEATURES_1_0 || featureFormatComboBox()->currentData().toString().indexOf( "gml"_L1 ) >= 0
244 );
245}
246
248{
249 return txtName->text();
250}
251
253{
254 return txtUrl->text();
255}
256
257void QgsNewHttpConnection::nameChanged( const QString &text )
258{
259 Q_UNUSED( text )
260 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
261}
262
263void QgsNewHttpConnection::urlChanged( const QString &text )
264{
265 Q_UNUSED( text )
266 buttonBox->button( QDialogButtonBox::Ok )->setDisabled( txtName->text().isEmpty() || txtUrl->text().isEmpty() );
267 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
268 mWmsFormatDetectButton->setDisabled( txtUrl->text().isEmpty() );
269}
270
271void QgsNewHttpConnection::updateOkButtonState()
272{
273 const bool enabled = !txtName->text().isEmpty() && !txtUrl->text().isEmpty();
274 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
275}
276
278{
279 const QString newConnectionName = txtName->text();
280
281 bool urlExists = QgsOwsConnection::settingsUrl->exists( { mServiceName.toLower(), newConnectionName } );
282
283 // warn if entry was renamed to an existing connection
284 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 )
285 {
286 return false;
287 }
288
289 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 )
290 {
291 return false;
292 }
293
294 return true;
295}
296
298{
299 return mTestConnectionButton;
300}
301
303{
304 return mWmsFormatDetectButton;
305}
306
311
313{
314 return QgsAuthorizationSettings( mAuthSettings->username(), mAuthSettings->password(), mHttpHeaders->httpHeaders(), mAuthSettings->configId() );
315}
316
318{
319 return cbxWmsIgnoreAxisOrientation->isChecked();
320}
321
323{
324 return mWmsPreferredFormatCombo;
325}
326
328{
329 return cbxWmsInvertAxisOrientation->isChecked();
330}
331
332
334{
335 return mWfsVersionDetectButton;
336}
337
339{
340 return cmbVersion;
341}
342
344{
345 return mFeatureFormatDetectButton;
346}
347
349{
350 return mFeatureFormatComboBox;
351}
352
354{
355 return cmbFeaturePaging;
356}
357
359{
360 return cbxWfsUseGml2EncodingForTransactions;
361}
362
364{
365 return txtPageSize;
366}
367
369{
370 return mComboHttpMethod->currentData().value< Qgis::HttpMethod >();
371}
372
373QString QgsNewHttpConnection::wfsSettingsKey( const QString &base, const QString &connectionName ) const
374{
375 return base + connectionName;
376}
377
378QString QgsNewHttpConnection::wmsSettingsKey( const QString &base, const QString &connectionName ) const
379{
380 return base + connectionName;
381}
382
384{
385 QStringList detailsParameters = { mServiceName.toLower(), mOriginalConnName };
386
387 cbxIgnoreGetMapURI->setChecked( QgsOwsConnection::settingsIgnoreGetMapURI->value( detailsParameters ) );
388 cbxWmsIgnoreReportedLayerExtents->setChecked( QgsOwsConnection::settingsReportedLayerExtents->value( detailsParameters ) );
389 cbxWfsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
390 cbxWfsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
391 cbxWfsUseGml2EncodingForTransactions->setChecked( QgsOwsConnection::settingsPreferCoordinatesForWfsT11->value( detailsParameters ) );
392 cbxWfsForceInitialGetFeature->setChecked( QgsOwsConnection::settingsWfsForceInitialGetFeature->value( detailsParameters ) );
393
394 cbxWmsIgnoreAxisOrientation->setChecked( QgsOwsConnection::settingsIgnoreAxisOrientation->value( detailsParameters ) );
395 cbxWmsInvertAxisOrientation->setChecked( QgsOwsConnection::settingsInvertAxisOrientation->value( detailsParameters ) );
396 cbxIgnoreGetFeatureInfoURI->setChecked( QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->value( detailsParameters ) );
397 cbxSmoothPixmapTransform->setChecked( QgsOwsConnection::settingsSmoothPixmapTransform->value( detailsParameters ) );
398
399 Qgis::DpiMode dpiMode = QgsOwsConnection::settingsDpiMode->value( detailsParameters );
400 cmbDpiMode->setCurrentIndex( cmbDpiMode->findData( static_cast<int>( dpiMode ) ) );
401
402 Qgis::TilePixelRatio tilePixelRatio = QgsOwsConnection::settingsTilePixelRatio->value( detailsParameters );
403 cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData( static_cast<int>( tilePixelRatio ) ) );
404
405 sbFeatureCount->setValue( QgsOwsConnection::settingsFeatureCount->value( detailsParameters ) );
406
407 const QString version = QgsOwsConnection::settingsVersion->value( detailsParameters );
408 int versionIdx = WFS_VERSION_MAX; // AUTO
409 if ( version == "1.0.0"_L1 )
410 versionIdx = WFS_VERSION_1_0;
411 else if ( version == "1.1.0"_L1 )
412 versionIdx = WFS_VERSION_1_1;
413 else if ( version == "2.0.0"_L1 )
414 versionIdx = WFS_VERSION_2_0;
415 else if ( version == "OGC_API_FEATURES"_L1 )
416 versionIdx = WFS_VERSION_API_FEATURES_1_0;
417 cmbVersion->setCurrentIndex( versionIdx );
418
419 // Enable/disable these items per WFS versions
420 wfsVersionCurrentIndexChanged( versionIdx );
421
422 mHttpHeaders->setHeaders( QgsHttpHeaders( QgsOwsConnection::settingsHeaders->value( { mServiceName.toLower(), mOriginalConnName } ) ) );
423
424 txtMaxNumFeatures->setText( QgsOwsConnection::settingsMaxNumFeatures->value( detailsParameters ) );
425
426 // Only default to paging enabled if WFS 2.0.0 or higher
427 const QString pagingEnabled = QgsOwsConnection::settingsPagingEnabled->value( detailsParameters );
428 if ( pagingEnabled == "enabled"_L1 )
429 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::ENABLED ) );
430 else if ( pagingEnabled == "disabled"_L1 )
431 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DISABLED ) );
432 else
433 cmbFeaturePaging->setCurrentIndex( static_cast<int>( QgsNewHttpConnection::WfsFeaturePagingIndex::DEFAULT ) );
434
435 const QString wfsFeatureMode = QgsOwsConnection::settingsWfsFeatureMode->value( detailsParameters );
436 mComboWfsFeatureMode->setCurrentIndex( std::max( mComboWfsFeatureMode->findData( wfsFeatureMode ), 0 ) );
437
438 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue( QgsOwsConnection::settingsPreferredHttpMethod->value( detailsParameters ) ) ) );
439 txtPageSize->setText( QgsOwsConnection::settingsPagesize->value( detailsParameters ) );
440}
441
442void QgsNewHttpConnection::showEvent( QShowEvent *event )
443{
444 QDialog::showEvent( event );
445}
446
448{
449 return mOriginalConnName;
450}
451
453{
454 QUrl url( txtUrl->text().trimmed() );
455 QUrlQuery query( url );
456 const QList<QPair<QString, QString>> items = query.queryItems( QUrl::FullyEncoded );
457 QHash<QString, QPair<QString, QString>> params;
458 for ( const QPair<QString, QString> &it : items )
459 {
460 params.insert( it.first.toUpper(), it );
461 }
462
463 if ( params[u"SERVICE"_s].second.toUpper() == "WMS" || params[u"SERVICE"_s].second.toUpper() == "WFS" || params[u"SERVICE"_s].second.toUpper() == "WCS" )
464 {
465 query.removeQueryItem( params.value( u"SERVICE"_s ).first );
466 query.removeQueryItem( params.value( u"REQUEST"_s ).first );
467 query.removeQueryItem( params.value( u"FORMAT"_s ).first );
468 }
469
470 url.setQuery( query );
471
472 if ( url.path( QUrl::FullyEncoded ).isEmpty() )
473 {
474 url.setPath( fromEncodedComponent_helper( "/" ) );
475 }
476 return url;
477}
478
480{
481 const QString newConnectionName = txtName->text();
482
483 if ( !validate() )
484 return;
485
486 QgsSettings settings;
487
488 // on rename delete original entry first
489 if ( !mOriginalConnName.isNull() && mOriginalConnName != newConnectionName )
490 {
491 QgsOwsConnection::sTreeOwsConnections->deleteItem( mOriginalConnName, { mServiceName.toLower() } );
492 settings.sync();
493 }
494
495 QStringList detailsParameters = { mServiceName.toLower(), newConnectionName };
496
497 const QUrl url( urlTrimmed() );
498 QgsOwsConnection::settingsUrl->setValue( url.toString(), detailsParameters );
499
500 if ( mTypes & ConnectionWfs )
501 {
502 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWfsIgnoreAxisOrientation->isChecked(), detailsParameters );
503 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWfsInvertAxisOrientation->isChecked(), detailsParameters );
504 QgsOwsConnection::settingsPreferCoordinatesForWfsT11->setValue( cbxWfsUseGml2EncodingForTransactions->isChecked(), detailsParameters );
505 QgsOwsConnection::settingsWfsForceInitialGetFeature->setValue( cbxWfsForceInitialGetFeature->isChecked(), detailsParameters );
506
507 // Get all values from the combo
508 QStringList availableFormats;
509 for ( int i = 0; i < mFeatureFormatComboBox->count(); ++i )
510 {
511 availableFormats.append( mFeatureFormatComboBox->itemData( i ).toString() );
512 }
513 QString format = mFeatureFormatComboBox->currentData().toString();
514 QgsOwsConnection::settingsDefaultFeatureFormat->setValue( format, detailsParameters );
515 settings.setValue( u"/qgis/lastFeatureFormatEncoding"_s, format );
516 QgsOwsConnection::settingsAvailableFeatureFormats->setValue( availableFormats, detailsParameters );
517 }
518 if ( mTypes & ConnectionWms || mTypes & ConnectionWcs )
519 {
520 QgsOwsConnection::settingsIgnoreAxisOrientation->setValue( cbxWmsIgnoreAxisOrientation->isChecked(), detailsParameters );
521 QgsOwsConnection::settingsInvertAxisOrientation->setValue( cbxWmsInvertAxisOrientation->isChecked(), detailsParameters );
522
523 QgsOwsConnection::settingsReportedLayerExtents->setValue( cbxWmsIgnoreReportedLayerExtents->isChecked(), detailsParameters );
524 QgsOwsConnection::settingsIgnoreGetMapURI->setValue( cbxIgnoreGetMapURI->isChecked(), detailsParameters );
525 QgsOwsConnection::settingsSmoothPixmapTransform->setValue( cbxSmoothPixmapTransform->isChecked(), detailsParameters );
526
527 Qgis::DpiMode dpiMode = cmbDpiMode->currentData().value<Qgis::DpiMode>();
528 QgsOwsConnection::settingsDpiMode->setValue( dpiMode, detailsParameters );
529 // Get all values from the combo
530 QStringList availableFormats;
531 for ( int i = 0; i < mWmsPreferredFormatCombo->count(); ++i )
532 {
533 availableFormats.append( mWmsPreferredFormatCombo->itemData( i ).toString() );
534 }
535 QgsOwsConnection::settingsDefaultImageFormat->setValue( mWmsPreferredFormatCombo->currentData().toString(), detailsParameters );
536 QgsOwsConnection::settingsAvailableImageFormats->setValue( availableFormats, detailsParameters );
537 Qgis::TilePixelRatio tilePixelRatio = cmbTilePixelRatio->currentData().value<Qgis::TilePixelRatio>();
538 QgsOwsConnection::settingsTilePixelRatio->setValue( tilePixelRatio, detailsParameters );
539
540 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), detailsParameters );
541 }
542 if ( mTypes & ConnectionWms )
543 {
544 QgsOwsConnection::settingsIgnoreGetFeatureInfoURI->setValue( cbxIgnoreGetFeatureInfoURI->isChecked(), detailsParameters );
545 QgsOwsConnection::settingsFeatureCount->setValue( sbFeatureCount->value(), detailsParameters );
546 }
547 if ( mTypes & ConnectionWfs )
548 {
549 QString version = u"auto"_s;
550 switch ( cmbVersion->currentIndex() )
551 {
552 case WFS_VERSION_MAX:
553 version = u"auto"_s;
554 break;
555 case WFS_VERSION_1_0:
556 version = u"1.0.0"_s;
557 break;
558 case WFS_VERSION_1_1:
559 version = u"1.1.0"_s;
560 break;
561 case WFS_VERSION_2_0:
562 version = u"2.0.0"_s;
563 break;
565 version = u"OGC_API_FEATURES"_s;
566 break;
567 }
568 QgsOwsConnection::settingsVersion->setValue( version, detailsParameters );
569 QgsOwsConnection::settingsMaxNumFeatures->setValue( txtMaxNumFeatures->text(), detailsParameters );
570 QgsOwsConnection::settingsPagesize->setValue( txtPageSize->text(), detailsParameters );
571 QgsOwsConnection::settingsPreferredHttpMethod->setValue( mComboHttpMethod->currentData().value< Qgis::HttpMethod >(), detailsParameters );
572
573 QString pagingEnabled = u"default"_s;
574 switch ( cmbFeaturePaging->currentIndex() )
575 {
577 pagingEnabled = u"default"_s;
578 break;
580 pagingEnabled = u"enabled"_s;
581 break;
583 pagingEnabled = u"disabled"_s;
584 break;
585 }
586 QgsOwsConnection::settingsPagingEnabled->setValue( pagingEnabled, detailsParameters );
587
588 const QString featureMode = mComboWfsFeatureMode->currentData().toString();
589 QgsOwsConnection::settingsWfsFeatureMode->setValue( featureMode, detailsParameters );
590 }
591
592 QStringList credentialsParameters = { mServiceName.toLower(), newConnectionName };
593 QgsOwsConnection::settingsUsername->setValue( mAuthSettings->username(), credentialsParameters );
594 QgsOwsConnection::settingsPassword->setValue( mAuthSettings->password(), credentialsParameters );
595 QgsOwsConnection::settingsAuthCfg->setValue( mAuthSettings->configId(), credentialsParameters );
596
597 if ( mHttpHeaders->isVisible() )
598 QgsOwsConnection::settingsHeaders->setValue( mHttpHeaders->httpHeaders().headers(), credentialsParameters );
599
600 QgsOwsConnection::sTreeOwsConnections->setSelectedItem( newConnectionName, { mServiceName.toLower() } );
601
602 QDialog::accept();
603}
604
605void QgsNewHttpConnection::showHelp()
606{
607 QgsHelp::openHelp( u"working_with_ogc/index.html"_s );
608}
TilePixelRatio
DpiMode enum.
Definition qgis.h:3431
@ Undefined
Undefined (not scale).
Definition qgis.h:3432
@ HighDpi
High (192 DPI).
Definition qgis.h:3434
@ StandardDpi
Standard (96 DPI).
Definition qgis.h:3433
DpiMode
DpiMode enum.
Definition qgis.h:3417
@ GeoServer
GeoServer.
Definition qgis.h:3422
@ QGIS
QGIS.
Definition qgis.h:3420
@ All
All.
Definition qgis.h:3418
@ Off
Off.
Definition qgis.h:3419
@ UMN
UMN.
Definition qgis.h:3421
HttpMethod
Different methods of HTTP requests.
Definition qgis.h:1056
@ Post
POST method.
Definition qgis.h:1058
@ Get
GET method.
Definition qgis.h:1057
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)