28void QgsTiledSceneDataItemGuiProvider::populateContextMenu(
QgsDataItem *item, QMenu *menu,
const QList<QgsDataItem *> &selection,
QgsDataItemGuiContext context )
30 if ( QgsTiledSceneLayerItem *layerItem = qobject_cast< QgsTiledSceneLayerItem * >( item ) )
32 QAction *actionEdit =
new QAction( tr(
"Edit Connection…" ), menu );
33 connect( actionEdit, &QAction::triggered,
this, [layerItem] { editConnection( layerItem ); } );
34 menu->addAction( actionEdit );
36 const QList< QgsTiledSceneLayerItem * > sceneConnectionItems = QgsDataItem::filteredItems<QgsTiledSceneLayerItem>( selection );
37 QAction *actionDelete =
new QAction( sceneConnectionItems.size() > 1 ? tr(
"Remove Connections…" ) : tr(
"Remove Connection…" ), menu );
38 connect( actionDelete, &QAction::triggered,
this, [sceneConnectionItems, context]
45 menu->addAction( actionDelete );
48 if ( QgsTiledSceneRootItem *rootItem = qobject_cast< QgsTiledSceneRootItem * >( item ) )
50 QAction *actionNewCesium =
new QAction( tr(
"New Cesium 3D Tiles Connection…" ), menu );
51 connect( actionNewCesium, &QAction::triggered,
this, [rootItem] { newCesium3dTilesConnection( rootItem ); } );
52 menu->addAction( actionNewCesium );
56 QAction *actionSave =
new QAction( tr(
"Save Connections…" ), menu );
57 connect( actionSave, &QAction::triggered,
this, [] { saveConnections(); } );
58 menu->addAction( actionSave );
60 QAction *actionLoadXyzTilesServers =
new QAction( tr(
"Load Connections…" ), menu );
61 connect( actionLoadXyzTilesServers, &QAction::triggered,
this, [rootItem] { loadConnections( rootItem ); } );
62 menu->addAction( actionLoadXyzTilesServers );
66void QgsTiledSceneDataItemGuiProvider::editConnection(
QgsDataItem *item )
71 QgsTiledSceneConnectionDialog dlg;
73 dlg.setConnection( item->
name(), uri );
87void QgsTiledSceneDataItemGuiProvider::newCesium3dTilesConnection(
QgsDataItem *item )
89 QgsTiledSceneConnectionDialog dlg;
94 conn.
provider = QStringLiteral(
"cesiumtiles" );
101void QgsTiledSceneDataItemGuiProvider::saveConnections()
107void QgsTiledSceneDataItemGuiProvider::loadConnections(
QgsDataItem *item )
109 const QString fileName = QFileDialog::getOpenFileName(
nullptr, tr(
"Load Connections" ), QDir::homePath(),
110 tr(
"XML files (*.xml *.XML)" ) );
111 if ( fileName.isEmpty() )
117 if ( dlg.exec() == QDialog::Accepted )
Encapsulates the context in which a QgsDataItem is shown within the application GUI.
static void deleteConnections(const QList< T * > &items, const std::function< void(const QString &) > &deleteConnection, QgsDataItemGuiContext context)
Handles deletion of a list of connection items.
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.