17#include "moc_qgsarcgisvectortileconnectiondialog.cpp"
27QgsArcgisVectorTileConnectionDialog::QgsArcgisVectorTileConnectionDialog( QWidget *parent )
34 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
35 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
36 mSpinZMax->setClearValue( 14 );
38 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
39 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, [ = ]
41 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/opening_data.html#using-vector-tiles-services" ) );
43 connect( mEditName, &QLineEdit::textChanged,
this, &QgsArcgisVectorTileConnectionDialog::updateOkButtonState );
44 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsArcgisVectorTileConnectionDialog::updateOkButtonState );
47void QgsArcgisVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
49 mEditName->setText( name );
51 const QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
52 mEditUrl->setText( conn.url );
54 mCheckBoxZMin->setChecked( conn.zMin != -1 );
55 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
56 mCheckBoxZMax->setChecked( conn.zMax != -1 );
57 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
59 mAuthSettings->setUsername( conn.username );
60 mAuthSettings->setPassword( conn.password );
62 mAuthSettings->setConfigId( conn.authCfg );
64 mEditStyleUrl->setText( conn.styleUrl );
67QString QgsArcgisVectorTileConnectionDialog::connectionUri()
const
69 QgsVectorTileProviderConnection::Data conn;
70 conn.url = mEditUrl->text();
71 if ( conn.url.endsWith(
'/' ) )
72 conn.url = conn.url.left( conn.url.length() - 1 );
74 conn.serviceType = QgsVectorTileProviderConnection::ArcgisVectorTileService;
76 if ( mCheckBoxZMin->isChecked() )
77 conn.zMin = mSpinZMin->value();
78 if ( mCheckBoxZMax->isChecked() )
79 conn.zMax = mSpinZMax->value();
81 conn.username = mAuthSettings->username();
82 conn.password = mAuthSettings->password();
84 conn.authCfg = mAuthSettings->configId( );
86 conn.styleUrl = mEditStyleUrl->text();
88 return QgsVectorTileProviderConnection::encodedUri( conn );
91QString QgsArcgisVectorTileConnectionDialog::connectionName()
const
93 return mEditName->text();
96void QgsArcgisVectorTileConnectionDialog::accept()
98 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
100 QMessageBox::warning(
this, tr(
"Connection Properties" ), tr(
"The maximum zoom level (%1) cannot be lower than the minimum zoom level (%2)." ).arg( mSpinZMax->value() ).arg( mSpinZMin->value() ) );
106void QgsArcgisVectorTileConnectionDialog::updateOkButtonState()
108 const bool enabled = !mEditName->text().isEmpty() && !mEditUrl->text().isEmpty();
109 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( enabled );
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...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.