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