38 : QDialog( parent, fl )
40 , mServiceName( serviceName )
41 , mOriginalConnName( connectionName )
46 if ( mServiceName.startsWith( QLatin1String(
"qgis/" ) ) )
53 mServiceName = mServiceName.split(
'-' ).last().toUpper();
61 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsNewHttpConnection::showHelp );
63 QString connectionType = mServiceName;
64 if ( mServiceName == QLatin1String(
"WMS" ) )
66 connectionType = QStringLiteral(
"WMS/WMTS" );
68 setWindowTitle( tr(
"Create a New %1 Connection" ).arg( connectionType ) );
70 txtName->setValidator(
new QRegularExpressionValidator( QRegularExpression(
"[^\\/]+" ), txtName ) );
79 cmbTilePixelRatio->clear();
85 cmbVersion->addItem( tr(
"Maximum" ) );
86 cmbVersion->addItem( tr(
"1.0" ) );
87 cmbVersion->addItem( tr(
"1.1" ) );
88 cmbVersion->addItem( tr(
"2.0" ) );
89 cmbVersion->addItem( tr(
"OGC API - Features" ) );
90 connect( cmbVersion,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsNewHttpConnection::wfsVersionCurrentIndexChanged );
92 cmbFeaturePaging->clear();
93 cmbFeaturePaging->addItem( tr(
"Default (trust server capabilities)" ) );
94 cmbFeaturePaging->addItem( tr(
"Enabled" ) );
95 cmbFeaturePaging->addItem( tr(
"Disabled" ) );
96 connect( cmbFeaturePaging,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged );
100 if ( !connectionName.isEmpty() )
105 txtName->setText( connectionName );
106 const QStringList detailParameters { mServiceName.toLower(), connectionName };
117 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
121 mWmsOptionsGroupBox->setVisible(
false );
122 mGroupBox->layout()->removeWidget( mWmsOptionsGroupBox );
126 mWfsOptionsGroupBox->setVisible(
false );
127 mGroupBox->layout()->removeWidget( mWfsOptionsGroupBox );
131 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)" ) );
136 cbxIgnoreGetMapURI->setText( tr(
"Ignore GetCoverage URI reported in capabilities" ) );
137 cbxWmsIgnoreAxisOrientation->setText( tr(
"Ignore axis orientation" ) );
140 mWmsOptionsGroupBox->setTitle( tr(
"WCS Options" ) );
142 cbxIgnoreGetFeatureInfoURI->setVisible(
false );
143 mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
145 sbFeatureCount->setVisible(
false );
146 mGroupBox->layout()->removeWidget( sbFeatureCount );
147 lblFeatureCount->setVisible(
false );
148 mGroupBox->layout()->removeWidget( lblFeatureCount );
150 cmbDpiMode->setVisible(
false );
151 mGroupBox->layout()->removeWidget( cmbDpiMode );
152 lblDpiMode->setVisible(
false );
153 mGroupBox->layout()->removeWidget( lblDpiMode );
154 cmbTilePixelRatio->setVisible(
false );
155 mGroupBox->layout()->removeWidget( cmbTilePixelRatio );
156 lblTilePixelRatio->setVisible(
false );
157 mGroupBox->layout()->removeWidget( lblTilePixelRatio );
163 mTestConnectionButton->hide();
164 mGroupBox->layout()->removeWidget( mTestConnectionButton );
169 mAuthGroupBox->hide();
170 mGroupBox->layout()->removeWidget( mAuthGroupBox );
173 const int w = width();
175 resize( w, height() );
177 connect( txtName, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::nameChanged );
178 connect( txtUrl, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::urlChanged );
180 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
181 connect( txtName, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::updateOkButtonState );
182 connect( txtUrl, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::updateOkButtonState );
184 nameChanged( connectionName );
302 QStringList detailsParameters = { mServiceName.toLower(), mOriginalConnName };
316 cmbDpiMode->setCurrentIndex( cmbDpiMode->findData(
static_cast<int>( dpiMode ) ) );
318 cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData(
static_cast<int>( tilePixelRatio ) ) );
324 if ( version == QLatin1String(
"1.0.0" ) )
326 else if ( version == QLatin1String(
"1.1.0" ) )
328 else if ( version == QLatin1String(
"2.0.0" ) )
330 else if ( version == QLatin1String(
"OGC_API_FEATURES" ) )
332 cmbVersion->setCurrentIndex( versionIdx );
335 wfsVersionCurrentIndexChanged( versionIdx );
343 if ( pagingEnabled == QLatin1String(
"enabled" ) )
345 else if ( pagingEnabled == QLatin1String(
"disabled" ) )
355 QUrl
url( txtUrl->text().trimmed() );
356 QUrlQuery query(
url );
357 const QList<QPair<QString, QString>> items = query.queryItems( QUrl::FullyEncoded );
358 QHash<QString, QPair<QString, QString>> params;
359 for (
const QPair<QString, QString> &it : items )
361 params.insert( it.first.toUpper(), it );
364 if ( params[QStringLiteral(
"SERVICE" )].second.toUpper() ==
"WMS" || params[QStringLiteral(
"SERVICE" )].second.toUpper() ==
"WFS" || params[QStringLiteral(
"SERVICE" )].second.toUpper() ==
"WCS" )
366 query.removeQueryItem( params.value( QStringLiteral(
"SERVICE" ) ).first );
367 query.removeQueryItem( params.value( QStringLiteral(
"REQUEST" ) ).first );
368 query.removeQueryItem( params.value( QStringLiteral(
"FORMAT" ) ).first );
371 url.setQuery( query );
373 if (
url.path( QUrl::FullyEncoded ).isEmpty() )
382 const QString newConnectionName = txtName->text();
390 if ( !mOriginalConnName.isNull() && mOriginalConnName != newConnectionName )
396 QStringList detailsParameters = { mServiceName.toLower(), newConnectionName };
430 QString version = QStringLiteral(
"auto" );
431 switch ( cmbVersion->currentIndex() )
434 version = QStringLiteral(
"auto" );
437 version = QStringLiteral(
"1.0.0" );
440 version = QStringLiteral(
"1.1.0" );
443 version = QStringLiteral(
"2.0.0" );
446 version = QStringLiteral(
"OGC_API_FEATURES" );
453 QString pagingEnabled = QStringLiteral(
"default" );
454 switch ( cmbFeaturePaging->currentIndex() )
457 pagingEnabled = QStringLiteral(
"default" );
460 pagingEnabled = QStringLiteral(
"enabled" );
463 pagingEnabled = QStringLiteral(
"disabled" );
469 QStringList credentialsParameters = { mServiceName.toLower(), newConnectionName };
474 if ( mHttpHeaders->isVisible() )
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
bool exists(const QString &dynamicKeyPart=QString()) const
Returns true if the settings is contained in the underlying QSettings.