Skip to content

Commit

Permalink
delete old tiled scene connection when renaming (fix #57570)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy authored and github-actions[bot] committed Jan 28, 2025
1 parent 02d46a2 commit cb82958
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/gui/tiledscene/qgstiledsceneconnectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "moc_qgstiledsceneconnectiondialog.cpp"
#include "qgstiledsceneconnection.h"
#include "qgsgui.h"
#include "qgssettings.h"

#include <QMessageBox>
#include <QPushButton>

Expand All @@ -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 );
Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 3 additions & 0 deletions src/gui/tiledscene/qgstiledsceneconnectiondialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cb82958

Please # to comment.