32#include "moc_qgstiledscenesourceselect.cpp"
34using namespace Qt::StringLiterals;
45 setWindowTitle( tr(
"Add Scene Layer" ) );
47 mRadioSourceService->setChecked(
true );
48 mStackedWidget->setCurrentIndex( 1 );
50 connect( mRadioSourceFile, &QRadioButton::toggled,
this, [
this] {
51 mStackedWidget->setCurrentIndex( 0 );
53 emit enableButtons( !mFileWidget->filePath().isEmpty() );
55 connect( mRadioSourceService, &QRadioButton::toggled,
this, [
this] {
56 mStackedWidget->setCurrentIndex( 1 );
58 emit enableButtons( !cmbConnections->currentText().isEmpty() );
61 btnNew->setPopupMode( QToolButton::InstantPopup );
62 QMenu *newMenu =
new QMenu( btnNew );
64 QAction *actionNew =
new QAction( tr(
"New Cesium 3D Tiles Connection…" ),
this );
65 connect( actionNew, &QAction::triggered,
this, [
this]() { newConnection(
"cesiumtiles" ); } );
66 newMenu->addAction( actionNew );
68 actionNew =
new QAction( tr(
"New Quantized Mesh Connection…" ),
this );
69 connect( actionNew, &QAction::triggered,
this, [
this]() { newConnection(
"quantizedmesh" ); } );
70 newMenu->addAction( actionNew );
72 btnNew->setMenu( newMenu );
74 connect( btnEdit, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnEdit_clicked );
75 connect( btnDelete, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnDelete_clicked );
76 connect( btnSave, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnSave_clicked );
77 connect( btnLoad, &QToolButton::clicked,
this, &QgsTiledSceneSourceSelect::btnLoad_clicked );
78 connect( cmbConnections, &QComboBox::currentTextChanged,
this, &QgsTiledSceneSourceSelect::cmbConnections_currentTextChanged );
79 setupButtons( buttonBox );
80 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsTiledSceneSourceSelect::showHelp );
82 populateConnectionList();
84 mFileWidget->setDialogTitle( tr(
"Open Scene Dataset" ) );
87 mFileWidget->setOptions( QFileDialog::HideNameFilterDetails );
89 emit enableButtons( !path.isEmpty() );
93void QgsTiledSceneSourceSelect::btnEdit_clicked()
97 const QString provider = connection.
provider;
99 QgsTiledSceneConnectionDialog nc(
this );
100 nc.setConnection( cmbConnections->currentText(), uri );
107 populateConnectionList();
108 emit connectionsChanged();
112void QgsTiledSceneSourceSelect::btnDelete_clicked()
114 const QString msg = tr(
"Are you sure you want to remove the %1 connection and all associated settings?" )
115 .arg( cmbConnections->currentText() );
116 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Confirm Delete" ), msg, QMessageBox::Yes | QMessageBox::No ) )
121 populateConnectionList();
122 emit connectionsChanged();
125void QgsTiledSceneSourceSelect::btnSave_clicked()
131void QgsTiledSceneSourceSelect::btnLoad_clicked()
133 const QString fileName = QFileDialog::getOpenFileName(
this, tr(
"Load Connections" ), QDir::homePath(), 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( u
"path"_s, 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.
A dialog for importing or exporting stored connections.
@ 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.
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.