39 mConnectionDetailsGroupBox->hide();
41 setWindowTitle( tr(
"Add Vector Tile Layer" ) );
42 mConnectionsGroupBox->setTitle( tr(
"Vector Tile Connections" ) );
46 btnNew->setPopupMode( QToolButton::InstantPopup );
47 QMenu *newMenu =
new QMenu( btnNew );
49 QAction *actionNew =
new QAction( tr(
"New Generic Connection…" ),
this );
50 connect( actionNew, &QAction::triggered,
this, &QgsVectorTileSourceSelect::btnNew_clicked );
51 newMenu->addAction( actionNew );
53 QAction *actionNewArcGISConnection =
new QAction( tr(
"New ArcGIS Vector Tile Service Connection…" ),
this );
54 connect( actionNewArcGISConnection, &QAction::triggered,
this, &QgsVectorTileSourceSelect::newArcgisVectorTileServerConnection );
55 newMenu->addAction( actionNewArcGISConnection );
57 btnNew->setMenu( newMenu );
59 connect( btnEdit, &QToolButton::clicked,
this, &QgsVectorTileSourceSelect::btnEdit_clicked );
60 connect( btnDelete, &QToolButton::clicked,
this, &QgsVectorTileSourceSelect::btnDelete_clicked );
61 connect( btnSave, &QToolButton::clicked,
this, &QgsVectorTileSourceSelect::btnSave_clicked );
62 connect( btnLoad, &QToolButton::clicked,
this, &QgsVectorTileSourceSelect::btnLoad_clicked );
63 connect( cmbConnections, &QComboBox::currentTextChanged,
this, &QgsVectorTileSourceSelect::cmbConnections_currentTextChanged );
64 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsVectorTileSourceSelect::showHelp );
65 setupButtons( buttonBox );
67 populateConnectionList();
70void QgsVectorTileSourceSelect::btnNew_clicked()
72 QgsVectorTileConnectionDialog nc(
this );
75 QgsVectorTileProviderConnection::addConnection( nc.connectionName(), QgsVectorTileProviderConnection::decodedUri( nc.connectionUri() ) );
76 populateConnectionList();
77 emit connectionsChanged();
81void QgsVectorTileSourceSelect::newArcgisVectorTileServerConnection()
83 QgsArcgisVectorTileConnectionDialog nc(
this );
86 QgsVectorTileProviderConnection::addConnection( nc.connectionName(), QgsVectorTileProviderConnection::decodedUri( nc.connectionUri() ) );
87 populateConnectionList();
88 emit connectionsChanged();
92void QgsVectorTileSourceSelect::btnEdit_clicked()
94 const QgsVectorTileProviderConnection::Data connection = QgsVectorTileProviderConnection::connection( cmbConnections->currentText() );
95 const QString uri = QgsVectorTileProviderConnection::encodedUri( connection );
97 switch ( connection.serviceType )
99 case QgsVectorTileProviderConnection::Generic:
101 QgsVectorTileConnectionDialog nc(
this );
102 nc.setConnection( cmbConnections->currentText(), uri );
105 QgsVectorTileProviderConnection::addConnection( nc.connectionName(), QgsVectorTileProviderConnection::decodedUri( nc.connectionUri() ) );
106 populateConnectionList();
107 emit connectionsChanged();
112 case QgsVectorTileProviderConnection::ArcgisVectorTileService:
114 QgsArcgisVectorTileConnectionDialog nc(
this );
116 nc.setConnection( cmbConnections->currentText(), uri );
119 QgsVectorTileProviderConnection::addConnection( nc.connectionName(), QgsVectorTileProviderConnection::decodedUri( nc.connectionUri() ) );
120 populateConnectionList();
121 emit connectionsChanged();
128void QgsVectorTileSourceSelect::btnDelete_clicked()
130 const QString msg = tr(
"Are you sure you want to remove the %1 connection and all associated settings?" )
131 .arg( cmbConnections->currentText() );
132 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
135 QgsVectorTileProviderConnection::deleteConnection( cmbConnections->currentText() );
137 populateConnectionList();
138 emit connectionsChanged();
141void QgsVectorTileSourceSelect::btnSave_clicked()
147void QgsVectorTileSourceSelect::btnLoad_clicked()
149 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Connections" ), QDir::homePath(),
150 tr(
"XML files (*.xml *.XML)" ) );
151 if ( fileName.isEmpty() )
158 populateConnectionList();
161void QgsVectorTileSourceSelect::addButtonClicked()
163 const QString uri = QgsVectorTileProviderConnection::encodedUri( QgsVectorTileProviderConnection::connection( cmbConnections->currentText() ) );
164 emit addVectorTileLayer( uri, cmbConnections->currentText() );
167void QgsVectorTileSourceSelect::populateConnectionList()
169 cmbConnections->blockSignals(
true );
170 cmbConnections->clear();
171 cmbConnections->addItems( QgsVectorTileProviderConnection::connectionList() );
172 cmbConnections->blockSignals(
false );
174 btnEdit->setDisabled( cmbConnections->count() == 0 );
175 btnDelete->setDisabled( cmbConnections->count() == 0 );
176 btnSave->setDisabled( cmbConnections->count() == 0 );
177 cmbConnections->setDisabled( cmbConnections->count() == 0 );
179 setConnectionListPosition();
182void QgsVectorTileSourceSelect::setConnectionListPosition()
184 const QString toSelect = QgsVectorTileProviderConnection::selectedConnection();
186 cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
188 if ( cmbConnections->currentIndex() < 0 )
190 if ( toSelect.isNull() )
191 cmbConnections->setCurrentIndex( 0 );
193 cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
196 emit enableButtons( !cmbConnections->currentText().isEmpty() );
199void QgsVectorTileSourceSelect::cmbConnections_currentTextChanged(
const QString &text )
201 QgsVectorTileProviderConnection::setSelectedConnection( text );
202 emit enableButtons( !text.isEmpty() );
205void QgsVectorTileSourceSelect::showHelp()
207 QgsHelp::openHelp( QStringLiteral(
"managing_data_source/opening_data.html#using-vector-tiles-services" ) );
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.
WidgetMode
Different ways a source select dialog can be used.