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 );
94 mComboHttpMethod->setCurrentIndex( mComboHttpMethod->findData( QVariant::fromValue(
Qgis::HttpMethod::Get ) ) );
96 cmbFeaturePaging->clear();
97 cmbFeaturePaging->addItem( tr(
"Default (trust server capabilities)" ) );
98 cmbFeaturePaging->addItem( tr(
"Enabled" ) );
99 cmbFeaturePaging->addItem( tr(
"Disabled" ) );
100 connect( cmbFeaturePaging,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsNewHttpConnection::wfsFeaturePagingCurrentIndexChanged );
104 if ( !connectionName.isEmpty() )
109 txtName->setText( connectionName );
110 const QStringList detailParameters { mServiceName.toLower(), connectionName };
121 mWfsVersionDetectButton->setDisabled( txtUrl->text().isEmpty() );
125 mWmsOptionsGroupBox->setVisible(
false );
126 mGroupBox->layout()->removeWidget( mWmsOptionsGroupBox );
130 mWfsOptionsGroupBox->setVisible(
false );
131 mGroupBox->layout()->removeWidget( mWfsOptionsGroupBox );
135 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)" ) );
140 cbxIgnoreGetMapURI->setText( tr(
"Ignore GetCoverage URI reported in capabilities" ) );
141 cbxWmsIgnoreAxisOrientation->setText( tr(
"Ignore axis orientation" ) );
144 mWmsOptionsGroupBox->setTitle( tr(
"WCS Options" ) );
146 cbxIgnoreGetFeatureInfoURI->setVisible(
false );
147 mGroupBox->layout()->removeWidget( cbxIgnoreGetFeatureInfoURI );
149 sbFeatureCount->setVisible(
false );
150 mGroupBox->layout()->removeWidget( sbFeatureCount );
151 lblFeatureCount->setVisible(
false );
152 mGroupBox->layout()->removeWidget( lblFeatureCount );
154 cmbDpiMode->setVisible(
false );
155 mGroupBox->layout()->removeWidget( cmbDpiMode );
156 lblDpiMode->setVisible(
false );
157 mGroupBox->layout()->removeWidget( lblDpiMode );
158 cmbTilePixelRatio->setVisible(
false );
159 mGroupBox->layout()->removeWidget( cmbTilePixelRatio );
160 lblTilePixelRatio->setVisible(
false );
161 mGroupBox->layout()->removeWidget( lblTilePixelRatio );
167 mTestConnectionButton->hide();
168 mGroupBox->layout()->removeWidget( mTestConnectionButton );
173 mAuthGroupBox->hide();
174 mGroupBox->layout()->removeWidget( mAuthGroupBox );
177 const int w = width();
179 resize( w, height() );
181 connect( txtName, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::nameChanged );
182 connect( txtUrl, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::urlChanged );
184 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
185 connect( txtName, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::updateOkButtonState );
186 connect( txtUrl, &QLineEdit::textChanged,
this, &QgsNewHttpConnection::updateOkButtonState );
188 nameChanged( connectionName );
311 QStringList detailsParameters = { mServiceName.toLower(), mOriginalConnName };
325 cmbDpiMode->setCurrentIndex( cmbDpiMode->findData(
static_cast<int>( dpiMode ) ) );
327 cmbTilePixelRatio->setCurrentIndex( cmbTilePixelRatio->findData(
static_cast<int>( tilePixelRatio ) ) );
333 if ( version == QLatin1String(
"1.0.0" ) )
335 else if ( version == QLatin1String(
"1.1.0" ) )
337 else if ( version == QLatin1String(
"2.0.0" ) )
339 else if ( version == QLatin1String(
"OGC_API_FEATURES" ) )
341 cmbVersion->setCurrentIndex( versionIdx );
344 wfsVersionCurrentIndexChanged( versionIdx );
352 if ( pagingEnabled == QLatin1String(
"enabled" ) )
354 else if ( pagingEnabled == QLatin1String(
"disabled" ) )
365 QUrl
url( txtUrl->text().trimmed() );
366 QUrlQuery query(
url );
367 const QList<QPair<QString, QString>> items = query.queryItems( QUrl::FullyEncoded );
368 QHash<QString, QPair<QString, QString>> params;
369 for (
const QPair<QString, QString> &it : items )
371 params.insert( it.first.toUpper(), it );
374 if ( params[QStringLiteral(
"SERVICE" )].second.toUpper() ==
"WMS" || params[QStringLiteral(
"SERVICE" )].second.toUpper() ==
"WFS" || params[QStringLiteral(
"SERVICE" )].second.toUpper() ==
"WCS" )
376 query.removeQueryItem( params.value( QStringLiteral(
"SERVICE" ) ).first );
377 query.removeQueryItem( params.value( QStringLiteral(
"REQUEST" ) ).first );
378 query.removeQueryItem( params.value( QStringLiteral(
"FORMAT" ) ).first );
381 url.setQuery( query );
383 if (
url.path( QUrl::FullyEncoded ).isEmpty() )
392 const QString newConnectionName = txtName->text();
400 if ( !mOriginalConnName.isNull() && mOriginalConnName != newConnectionName )
406 QStringList detailsParameters = { mServiceName.toLower(), newConnectionName };
440 QString version = QStringLiteral(
"auto" );
441 switch ( cmbVersion->currentIndex() )
444 version = QStringLiteral(
"auto" );
447 version = QStringLiteral(
"1.0.0" );
450 version = QStringLiteral(
"1.1.0" );
453 version = QStringLiteral(
"2.0.0" );
456 version = QStringLiteral(
"OGC_API_FEATURES" );
464 QString pagingEnabled = QStringLiteral(
"default" );
465 switch ( cmbFeaturePaging->currentIndex() )
468 pagingEnabled = QStringLiteral(
"default" );
471 pagingEnabled = QStringLiteral(
"enabled" );
474 pagingEnabled = QStringLiteral(
"disabled" );
480 QStringList credentialsParameters = { mServiceName.toLower(), newConnectionName };
485 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.