39 setWindowTitle( tr(
"Add Scene Layer" ) );
41 mRadioSourceService->setChecked(
true );
42 mStackedWidget->setCurrentIndex( 1 );
44 connect( mRadioSourceFile, &QRadioButton::toggled,
this, [
this]
46 mStackedWidget->setCurrentIndex( 0 );
48 emit enableButtons( !mFileWidget->filePath().isEmpty() );
50 connect( mRadioSourceService, &QRadioButton::toggled,
this, [
this]
52 mStackedWidget->setCurrentIndex( 1 );
54 emit enableButtons( !cmbConnections->currentText().isEmpty() );
57 btnNew->setPopupMode( QToolButton::InstantPopup );
58 QMenu *newMenu =
new QMenu( btnNew );
60 QAction *actionNew =
new QAction( tr(
"New Cesium 3D Tiles Connection…" ),
this );
61 connect( actionNew, &QAction::triggered,
this, &QgsTiledSceneSourceSelect::btnNewCesium3DTiles_clicked );
62 newMenu->addAction( actionNew );
64 btnNew->setMenu( newMenu );
66 connect( btnEdit, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnEdit_clicked );
67 connect( btnDelete, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnDelete_clicked );
68 connect( btnSave, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnSave_clicked );
69 connect( btnLoad, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnLoad_clicked );
70 connect( cmbConnections, &QComboBox::currentTextChanged,
this, &QgsTiledSceneSourceSelect::cmbConnections_currentTextChanged );
71 setupButtons( buttonBox );
72 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsTiledSceneSourceSelect::showHelp );
74 populateConnectionList();
76 mFileWidget->setDialogTitle( tr(
"Open Scene Dataset" ) );
79 mFileWidget->setOptions( QFileDialog::HideNameFilterDetails );
82 emit enableButtons( !path.isEmpty() );
86void QgsTiledSceneSourceSelect::btnNewCesium3DTiles_clicked()
88 QgsTiledSceneConnectionDialog nc(
this );
92 connectionData.
provider = QStringLiteral(
"cesiumtiles" );
95 populateConnectionList();
96 emit connectionsChanged();
100void QgsTiledSceneSourceSelect::btnEdit_clicked()
104 const QString provider = connection.
provider;
106 QgsTiledSceneConnectionDialog nc(
this );
107 nc.setConnection( cmbConnections->currentText(), uri );
114 populateConnectionList();
115 emit connectionsChanged();
120void QgsTiledSceneSourceSelect::btnDelete_clicked()
122 const QString msg = tr(
"Are you sure you want to remove the %1 connection and all associated settings?" )
123 .arg( cmbConnections->currentText() );
124 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
129 populateConnectionList();
130 emit connectionsChanged();
133void QgsTiledSceneSourceSelect::btnSave_clicked()
139void QgsTiledSceneSourceSelect::btnLoad_clicked()
141 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Connections" ), QDir::homePath(),
142 tr(
"XML files (*.xml *.XML)" ) );
143 if ( fileName.isEmpty() )
150 populateConnectionList();
153void QgsTiledSceneSourceSelect::addButtonClicked()
155 if ( mRadioSourceService->isChecked() )
161 else if ( mRadioSourceFile->isChecked() )
163 const QString filePath = mFileWidget->filePath();
170 providerKey = details.metadata()->key();
175 parts.insert( QStringLiteral(
"path" ), filePath );
182void QgsTiledSceneSourceSelect::populateConnectionList()
184 cmbConnections->blockSignals(
true );
185 cmbConnections->clear();
187 cmbConnections->blockSignals(
false );
189 btnEdit->setDisabled( cmbConnections->count() == 0 );
190 btnDelete->setDisabled( cmbConnections->count() == 0 );
191 btnSave->setDisabled( cmbConnections->count() == 0 );
192 cmbConnections->setDisabled( cmbConnections->count() == 0 );
194 setConnectionListPosition();
197void QgsTiledSceneSourceSelect::setConnectionListPosition()
201 cmbConnections->setCurrentIndex( cmbConnections->findText( toSelect ) );
203 if ( cmbConnections->currentIndex() < 0 )
205 if ( toSelect.isNull() )
206 cmbConnections->setCurrentIndex( 0 );
208 cmbConnections->setCurrentIndex( cmbConnections->count() - 1 );
211 emit enableButtons( !cmbConnections->currentText().isEmpty() );
214void QgsTiledSceneSourceSelect::cmbConnections_currentTextChanged(
const QString &text )
217 emit enableButtons( !text.isEmpty() );
220void 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 (since QGIS 3.34)
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.