20 #include <QMessageBox>
21 #include <QPushButton>
25 QgsArcgisVectorTileConnectionDialog::QgsArcgisVectorTileConnectionDialog( QWidget *parent )
32 connect( mCheckBoxZMin, &QCheckBox::toggled, mSpinZMin, &QSpinBox::setEnabled );
33 connect( mCheckBoxZMax, &QCheckBox::toggled, mSpinZMax, &QSpinBox::setEnabled );
34 mSpinZMax->setClearValue( 14 );
36 buttonBox->button( QDialogButtonBox::Ok )->setDisabled(
true );
37 connect( mEditName, &QLineEdit::textChanged,
this, &QgsArcgisVectorTileConnectionDialog::updateOkButtonState );
38 connect( mEditUrl, &QLineEdit::textChanged,
this, &QgsArcgisVectorTileConnectionDialog::updateOkButtonState );
41 void QgsArcgisVectorTileConnectionDialog::setConnection(
const QString &name,
const QString &uri )
43 mEditName->setText( name );
45 QgsVectorTileProviderConnection::Data conn = QgsVectorTileProviderConnection::decodedUri( uri );
46 mEditUrl->setText( conn.url );
48 mCheckBoxZMin->setChecked( conn.zMin != -1 );
49 mSpinZMin->setValue( conn.zMin != -1 ? conn.zMin : 0 );
50 mCheckBoxZMax->setChecked( conn.zMax != -1 );
51 mSpinZMax->setValue( conn.zMax != -1 ? conn.zMax : 14 );
53 mAuthSettings->setUsername( conn.username );
54 mAuthSettings->setPassword( conn.password );
55 mEditReferer->setText( conn.referer );
56 mAuthSettings->setConfigId( conn.authCfg );
58 mEditStyleUrl->setText( conn.styleUrl );
61 QString QgsArcgisVectorTileConnectionDialog::connectionUri()
const
63 QgsVectorTileProviderConnection::Data conn;
64 conn.url = mEditUrl->text();
65 if ( conn.url.endsWith(
'/' ) )
66 conn.url = conn.url.left( conn.url.length() - 1 );
68 conn.serviceType = QgsVectorTileProviderConnection::ArcgisVectorTileService;
70 if ( mCheckBoxZMin->isChecked() )
71 conn.zMin = mSpinZMin->value();
72 if ( mCheckBoxZMax->isChecked() )
73 conn.zMax = mSpinZMax->value();
75 conn.username = mAuthSettings->username();
76 conn.password = mAuthSettings->password();
77 conn.referer = mEditReferer->text();
78 conn.authCfg = mAuthSettings->configId( );
80 conn.styleUrl = mEditStyleUrl->text();
82 return QgsVectorTileProviderConnection::encodedUri( conn );
85 QString QgsArcgisVectorTileConnectionDialog::connectionName()
const
87 return mEditName->text();
90 void QgsArcgisVectorTileConnectionDialog::accept()
92 if ( mCheckBoxZMin->isChecked() && mCheckBoxZMax->isChecked() && mSpinZMax->value() < mSpinZMin->value() )
94 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() ) );
100 void QgsArcgisVectorTileConnectionDialog::updateOkButtonState()
102 bool enabled = !mEditName->text().isEmpty() && !mEditUrl->text().isEmpty();
103 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...