From 84acdc4fa195e13c1e0cbffae95b8d99f3156040 Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Tue, 28 Jan 2025 11:32:35 +0000 Subject: [PATCH] delete old tiled scene connection when renaming (fix #57570) --- .../tiledscene/qgstiledsceneconnectiondialog.cpp | 13 +++++++++++++ src/gui/tiledscene/qgstiledsceneconnectiondialog.h | 3 +++ 2 files changed, 16 insertions(+) diff --git a/src/gui/tiledscene/qgstiledsceneconnectiondialog.cpp b/src/gui/tiledscene/qgstiledsceneconnectiondialog.cpp index 6eb9750758c6..4b54c5bfc8fb 100644 --- a/src/gui/tiledscene/qgstiledsceneconnectiondialog.cpp +++ b/src/gui/tiledscene/qgstiledsceneconnectiondialog.cpp @@ -17,6 +17,8 @@ #include "moc_qgstiledsceneconnectiondialog.cpp" #include "qgstiledsceneconnection.h" #include "qgsgui.h" +#include "qgssettings.h" + #include #include @@ -37,6 +39,7 @@ QgsTiledSceneConnectionDialog::QgsTiledSceneConnectionDialog( QWidget *parent ) void QgsTiledSceneConnectionDialog::setConnection( const QString &name, const QString &uri ) { mEditName->setText( name ); + mOriginalConnectionName = name; const QgsTiledSceneProviderConnection::Data conn = QgsTiledSceneProviderConnection::decodedUri( uri ); mEditUrl->setText( conn.url ); @@ -73,6 +76,16 @@ void QgsTiledSceneConnectionDialog::updateOkButtonState() void QgsTiledSceneConnectionDialog::accept() { + const QString newConnectionName = mEditName->text(); + + // on rename delete original entry first + if ( !mOriginalConnectionName.isNull() && mOriginalConnectionName != newConnectionName ) + { + QgsSettings settings; + QgsTiledSceneProviderConnection( QString() ).remove( mOriginalConnectionName ); + settings.sync(); + } + QDialog::accept(); } diff --git a/src/gui/tiledscene/qgstiledsceneconnectiondialog.h b/src/gui/tiledscene/qgstiledsceneconnectiondialog.h index 8c22b91c422d..038a08c2c1b9 100644 --- a/src/gui/tiledscene/qgstiledsceneconnectiondialog.h +++ b/src/gui/tiledscene/qgstiledsceneconnectiondialog.h @@ -39,6 +39,9 @@ class QgsTiledSceneConnectionDialog : public QDialog, public Ui::QgsTiledSceneCo private slots: void updateOkButtonState(); + + private: + QString mOriginalConnectionName; //store initial name to delete entry in case of rename }; ///@endcond