diff --git a/src/gui/tiledscene/qgstiledscenedataitemguiprovider.cpp b/src/gui/tiledscene/qgstiledscenedataitemguiprovider.cpp index 3817cc87e865..040119cf54e6 100644 --- a/src/gui/tiledscene/qgstiledscenedataitemguiprovider.cpp +++ b/src/gui/tiledscene/qgstiledscenedataitemguiprovider.cpp @@ -14,6 +14,7 @@ ***************************************************************************/ #include "qgstiledscenedataitemguiprovider.h" +#include "qgsquantizedmeshdataprovider.h" #include "qgstiledscenedataitems.h" #include "qgstiledsceneconnection.h" #include "qgstiledsceneconnectiondialog.h" @@ -52,9 +53,13 @@ void QgsTiledSceneDataItemGuiProvider::populateContextMenu( QgsDataItem *item, Q if ( QgsTiledSceneRootItem *rootItem = qobject_cast< QgsTiledSceneRootItem * >( item ) ) { QAction *actionNewCesium = new QAction( tr( "New Cesium 3D Tiles Connection…" ), menu ); - connect( actionNewCesium, &QAction::triggered, this, [rootItem] { newCesium3dTilesConnection( rootItem ); } ); + connect( actionNewCesium, &QAction::triggered, this, [rootItem] { newConnection( rootItem, "cesiumtiles" ); } ); menu->addAction( actionNewCesium ); + QAction *actionNewQM = new QAction( tr( "New Quantized Mesh Connection…" ), menu ); + connect( actionNewQM, &QAction::triggered, this, [rootItem] { newConnection( rootItem, "quantizedmesh" ); } ); + menu->addAction( actionNewQM ); + menu->addSeparator(); QAction *actionSave = new QAction( tr( "Save Connections…" ), menu ); @@ -100,14 +105,14 @@ void QgsTiledSceneDataItemGuiProvider::duplicateConnection( QgsDataItem *item ) item->parent()->refreshConnections(); } -void QgsTiledSceneDataItemGuiProvider::newCesium3dTilesConnection( QgsDataItem *item ) +void QgsTiledSceneDataItemGuiProvider::newConnection( QgsDataItem *item, QString provider ) { QgsTiledSceneConnectionDialog dlg; if ( !dlg.exec() ) return; QgsTiledSceneProviderConnection::Data conn = QgsTiledSceneProviderConnection::decodedUri( dlg.connectionUri() ); - conn.provider = QStringLiteral( "cesiumtiles" ); + conn.provider = provider; QgsTiledSceneProviderConnection::addConnection( dlg.connectionName(), conn ); diff --git a/src/gui/tiledscene/qgstiledscenedataitemguiprovider.h b/src/gui/tiledscene/qgstiledscenedataitemguiprovider.h index 789ed40c16fb..817c6bda2735 100644 --- a/src/gui/tiledscene/qgstiledscenedataitemguiprovider.h +++ b/src/gui/tiledscene/qgstiledscenedataitemguiprovider.h @@ -35,7 +35,7 @@ class QgsTiledSceneDataItemGuiProvider : public QObject, public QgsDataItemGuiPr private: static void editConnection( QgsDataItem *item ); static void duplicateConnection( QgsDataItem *item ); - static void newCesium3dTilesConnection( QgsDataItem *item ); + static void newConnection( QgsDataItem *item, QString provider ); static void saveConnections(); static void loadConnections( QgsDataItem *item ); diff --git a/src/gui/tiledscene/qgstiledscenesourceselect.cpp b/src/gui/tiledscene/qgstiledscenesourceselect.cpp index 3d36f9efa6ea..4c5b1ad0a7f6 100644 --- a/src/gui/tiledscene/qgstiledscenesourceselect.cpp +++ b/src/gui/tiledscene/qgstiledscenesourceselect.cpp @@ -58,7 +58,11 @@ QgsTiledSceneSourceSelect::QgsTiledSceneSourceSelect( QWidget *parent, Qt::Windo QMenu *newMenu = new QMenu( btnNew ); QAction *actionNew = new QAction( tr( "New Cesium 3D Tiles Connection…" ), this ); - connect( actionNew, &QAction::triggered, this, &QgsTiledSceneSourceSelect::btnNewCesium3DTiles_clicked ); + connect( actionNew, &QAction::triggered, this, [ this ]() { newConnection( "cesiumtiles" ); } ); + newMenu->addAction( actionNew ); + + actionNew = new QAction( tr( "New Quantized Mesh Connection…" ), this ); + connect( actionNew, &QAction::triggered, this, [ this ]() { newConnection( "quantizedmesh" ); } ); newMenu->addAction( actionNew ); btnNew->setMenu( newMenu ); @@ -83,22 +87,6 @@ QgsTiledSceneSourceSelect::QgsTiledSceneSourceSelect( QWidget *parent, Qt::Windo } ); } -void QgsTiledSceneSourceSelect::btnNewCesium3DTiles_clicked() -{ - QgsTiledSceneConnectionDialog nc( this ); - if ( nc.exec() ) - { - QgsTiledSceneProviderConnection::Data connectionData = QgsTiledSceneProviderConnection::decodedUri( nc.connectionUri() ); - connectionData.provider = QStringLiteral( "cesiumtiles" ); - - QgsTiledSceneProviderConnection::addConnection( nc.connectionName(), connectionData ); - populateConnectionList(); - QgsTiledSceneProviderConnection::setSelectedConnection( nc.connectionName() ); - setConnectionListPosition(); - emit connectionsChanged(); - } -} - void QgsTiledSceneSourceSelect::btnEdit_clicked() { const QgsTiledSceneProviderConnection::Data connection = QgsTiledSceneProviderConnection::connection( cmbConnections->currentText() ); @@ -181,6 +169,23 @@ void QgsTiledSceneSourceSelect::addButtonClicked() } } +void QgsTiledSceneSourceSelect::newConnection( QString provider ) +{ + QgsTiledSceneConnectionDialog nc( this ); + if ( nc.exec() ) + { + QgsTiledSceneProviderConnection::Data connectionData = QgsTiledSceneProviderConnection::decodedUri( nc.connectionUri() ); + connectionData.provider = provider; + + QgsTiledSceneProviderConnection::addConnection( nc.connectionName(), connectionData ); + populateConnectionList(); + QgsTiledSceneProviderConnection::setSelectedConnection( nc.connectionName() ); + setConnectionListPosition(); + emit connectionsChanged(); + } +} + + void QgsTiledSceneSourceSelect::populateConnectionList() { cmbConnections->blockSignals( true ); diff --git a/src/gui/tiledscene/qgstiledscenesourceselect.h b/src/gui/tiledscene/qgstiledscenesourceselect.h index 5889df494be1..2786387f0269 100644 --- a/src/gui/tiledscene/qgstiledscenesourceselect.h +++ b/src/gui/tiledscene/qgstiledscenesourceselect.h @@ -46,8 +46,6 @@ class QgsTiledSceneSourceSelect : public QgsAbstractDataSourceWidget, private Ui private slots: - //! Opens the create connection dialog to build a new connection - void btnNewCesium3DTiles_clicked(); //! Opens a dialog to edit an existing connection void btnEdit_clicked(); //! Deletes the selected connection @@ -62,6 +60,8 @@ class QgsTiledSceneSourceSelect : public QgsAbstractDataSourceWidget, private Ui void showHelp(); private: + //! Opens the create connection dialog to build a new connection + void newConnection( QString provider ); void populateConnectionList(); void setConnectionListPosition(); };