19#include "moc_qgstiledscenesourceselect.cpp"
40 setWindowTitle( tr(
"Add Scene Layer" ) );
42 mRadioSourceService->setChecked(
true );
43 mStackedWidget->setCurrentIndex( 1 );
45 connect( mRadioSourceFile, &QRadioButton::toggled,
this, [
this]
47 mStackedWidget->setCurrentIndex( 0 );
49 emit enableButtons( !mFileWidget->filePath().isEmpty() );
51 connect( mRadioSourceService, &QRadioButton::toggled,
this, [
this]
53 mStackedWidget->setCurrentIndex( 1 );
55 emit enableButtons( !cmbConnections->currentText().isEmpty() );
58 btnNew->setPopupMode( QToolButton::InstantPopup );
59 QMenu *newMenu =
new QMenu( btnNew );
61 QAction *actionNew =
new QAction( tr(
"New Cesium 3D Tiles Connection…" ),
this );
62 connect( actionNew, &QAction::triggered,
this, [
this ]() { newConnection(
"cesiumtiles" ); } );
63 newMenu->addAction( actionNew );
65 actionNew =
new QAction( tr(
"New Quantized Mesh Connection…" ),
this );
66 connect( actionNew, &QAction::triggered,
this, [
this ]() { newConnection(
"quantizedmesh" ); } );
67 newMenu->addAction( actionNew );
69 btnNew->setMenu( newMenu );
71 connect( btnEdit, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnEdit_clicked );
72 connect( btnDelete, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnDelete_clicked );
73 connect( btnSave, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnSave_clicked );
74 connect( btnLoad, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnLoad_clicked );
75 connect( cmbConnections, &QComboBox::currentTextChanged,
this, &QgsTiledSceneSourceSelect::cmbConnections_currentTextChanged );
76 setupButtons( buttonBox );
77 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsTiledSceneSourceSelect::showHelp );
79 populateConnectionList();
81 mFileWidget->setDialogTitle( tr(
"Open Scene Dataset" ) );
84 mFileWidget->setOptions( QFileDialog::HideNameFilterDetails );
87 emit enableButtons( !path.isEmpty() );
91void QgsTiledSceneSourceSelect::btnEdit_clicked()
95 const QString provider = connection.
provider;
97 QgsTiledSceneConnectionDialog nc(
this );
98 nc.setConnection( cmbConnections->currentText(), uri );
105 populateConnectionList();
106 emit connectionsChanged();
111void QgsTiledSceneSourceSelect::btnDelete_clicked()
113 const QString msg = tr(
"Are you sure you want to remove the %1 connection and all associated settings?" )
114 .arg( cmbConnections->currentText() );
115 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
120 populateConnectionList();
121 emit connectionsChanged();
124void QgsTiledSceneSourceSelect::btnSave_clicked()
130void QgsTiledSceneSourceSelect::btnLoad_clicked()
132 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Connections" ), QDir::homePath(),
133 tr(
"XML files (*.xml *.XML)" ) );
134 if ( fileName.isEmpty() )
141 populateConnectionList();
144void QgsTiledSceneSourceSelect::addButtonClicked()
146 if ( mRadioSourceService->isChecked() )
152 else if ( mRadioSourceFile->isChecked() )
154 const QString filePath = mFileWidget->filePath();
161 providerKey = details.metadata()->key();
166 parts.insert( QStringLiteral(
"path" ), filePath );
173void QgsTiledSceneSourceSelect::newConnection( QString provider )
175 QgsTiledSceneConnectionDialog nc(
this );
182 populateConnectionList();
184 setConnectionListPosition();
185 emit connectionsChanged();
190void QgsTiledSceneSourceSelect::populateConnectionList()
192 cmbConnections->blockSignals(
true );
193 cmbConnections->clear();
195 cmbConnections->blockSignals(
false );
197 btnEdit->setDisabled( cmbConnections->count() == 0 );
198 btnDelete->setDisabled( cmbConnections->count() == 0 );
199 btnSave->setDisabled( cmbConnections->count() == 0 );
200 cmbConnections->setDisabled( cmbConnections->count() == 0 );
202 setConnectionListPosition();
205void QgsTiledSceneSourceSelect::setConnectionListPosition()
209 cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
211 if ( cmbConnections->currentIndex() < 0 )
213 if ( toSelect.isNull() )
214 cmbConnections->setCurrentIndex( 0 );
216 cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
219 emit enableButtons( !cmbConnections->currentText().isEmpty() );
222void QgsTiledSceneSourceSelect::cmbConnections_currentTextChanged(
const QString &text )
225 emit enableButtons( !text.isEmpty() );
228void QgsTiledSceneSourceSelect::showHelp()
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
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.
@ TiledScene
Tiled scene connection.
Contains information pertaining to a candidate provider.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
WidgetMode
Different ways a source select dialog can be used.
QList< QgsProviderRegistry::ProviderCandidateDetails > preferredProvidersForUri(const QString &uri) const
Returns the details for the preferred provider(s) for opening the specified uri.
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
static QString suggestLayerNameFromFilePath(const QString &path)
Suggests a suitable layer name given only a file path.
Represents connections to tiled scene data sources.
virtual void remove(const QString &name) const override
Deletes the connection from the settings.
static QString selectedConnection()
Returns the name of the last used connection.
static Data decodedUri(const QString &uri)
Returns a connection uri decoded to a data structure.
static Data connection(const QString &name)
Returns connection details for the stored connection with the specified name.
static void addConnection(const QString &name, const Data &connection)
Stores a new connection, under the specified connection name.
static void setSelectedConnection(const QString &name)
Stores the name of the last used connection.
static QStringList connectionList()
Returns a list of the stored connection names.
static QString encodedUri(const Data &data)
Returns connection data encoded as a string.
Represents decoded data of a tiled scene connection.
QString provider
Provider key.