29 if ( QgsTiledSceneLayerItem *layerItem = qobject_cast< QgsTiledSceneLayerItem * >( item ) )
31 QAction *actionEdit =
new QAction( tr(
"Edit Connection…" ), menu );
32 connect( actionEdit, &QAction::triggered,
this, [layerItem] { editConnection( layerItem ); } );
33 menu->addAction( actionEdit );
35 QAction *actionDelete =
new QAction( tr(
"Remove Connection" ), menu );
36 connect( actionDelete, &QAction::triggered,
this, [layerItem] { deleteConnection( layerItem ); } );
37 menu->addAction( actionDelete );
40 if ( QgsTiledSceneRootItem *rootItem = qobject_cast< QgsTiledSceneRootItem * >( item ) )
42 QAction *actionNewCesium =
new QAction( tr(
"New Cesium 3D Tiles Connection…" ), menu );
43 connect( actionNewCesium, &QAction::triggered,
this, [rootItem] { newCesium3dTilesConnection( rootItem ); } );
44 menu->addAction( actionNewCesium );
48 QAction *actionSave =
new QAction( tr(
"Save Connections…" ), menu );
49 connect( actionSave, &QAction::triggered,
this, [] { saveConnections(); } );
50 menu->addAction( actionSave );
52 QAction *actionLoadXyzTilesServers =
new QAction( tr(
"Load Connections…" ), menu );
53 connect( actionLoadXyzTilesServers, &QAction::triggered,
this, [rootItem] { loadConnections( rootItem ); } );
54 menu->addAction( actionLoadXyzTilesServers );
58void QgsTiledSceneDataItemGuiProvider::editConnection(
QgsDataItem *item )
63 QgsTiledSceneConnectionDialog dlg;
65 dlg.setConnection( item->
name(), uri );
79void QgsTiledSceneDataItemGuiProvider::deleteConnection(
QgsDataItem *item )
81 if ( QMessageBox::question(
nullptr, tr(
"Remove Connection" ), tr(
"Are you sure you want to remove the connection “%1”?" ).arg( item->
name() ),
82 QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
90void QgsTiledSceneDataItemGuiProvider::newCesium3dTilesConnection(
QgsDataItem *item )
92 QgsTiledSceneConnectionDialog dlg;
97 conn.
provider = QStringLiteral(
"cesiumtiles" );
104void QgsTiledSceneDataItemGuiProvider::saveConnections()
110void QgsTiledSceneDataItemGuiProvider::loadConnections(
QgsDataItem *item )
112 const QString fileName = QFileDialog::getOpenFileName(
nullptr, tr(
"Load Connections" ), QDir::homePath(),
113 tr(
"XML files (*.xml *.XML)" ) );
114 if ( fileName.isEmpty() )
120 if ( dlg.exec() == QDialog::Accepted )
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
Base class for all items in the model.
QString name() const
Returns the name of the item (the displayed text for the item).
virtual void refreshConnections(const QString &providerKey=QString())
Causes a data item provider to refresh all registered connections.
QgsDataItem * parent() const
Gets item parent.
@ TiledScene
Tiled scene connection (since QGIS 3.34)
Represents connections to tiled scene data sources.
virtual void remove(const QString &name) const override
Deletes the connection from the settings.
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 QString encodedUri(const Data &data)
Returns connection data encoded as a string.
Represents decoded data of a tiled scene connection.
QString provider
Provider key.