Skip to content

Commit

Permalink
Standardise browser item behavior for AFS provider
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jul 25, 2018
1 parent 3425046 commit 6d5ba5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/providers/arcgisrest/qgsafsdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "qgsafssourceselect.h"
#endif

#include <QMessageBox>
#include <QCoreApplication>
#include <QSettings>
#include <QUrl>
Expand Down Expand Up @@ -131,11 +132,19 @@ QList<QAction *> QgsAfsConnectionItem::actions( QWidget *parent )
{
QList<QAction *> lst;

QAction *actionEdit = new QAction( tr( "Edit…" ), parent );
QAction *actionRefresh = new QAction( tr( "Refresh" ), parent );
connect( actionRefresh, &QAction::triggered, this, &QgsAfsConnectionItem::refreshConnection );
lst.append( actionRefresh );

QAction *separator = new QAction( parent );
separator->setSeparator( true );
lst.append( separator );

QAction *actionEdit = new QAction( tr( "Edit Connection…" ), parent );
connect( actionEdit, &QAction::triggered, this, &QgsAfsConnectionItem::editConnection );
lst.append( actionEdit );

QAction *actionDelete = new QAction( tr( "Delete" ), parent );
QAction *actionDelete = new QAction( tr( "Delete Connection" ), parent );
connect( actionDelete, &QAction::triggered, this, &QgsAfsConnectionItem::deleteConnection );
lst.append( actionDelete );

Expand All @@ -155,6 +164,11 @@ void QgsAfsConnectionItem::editConnection()

void QgsAfsConnectionItem::deleteConnection()
{
if ( QMessageBox::question( nullptr, QObject::tr( "Delete Connection" ),
QObject::tr( "Are you sure you want to delete the connection to %1?" ).arg( mName ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;

QgsOwsConnection::deleteConnection( QStringLiteral( "arcgisfeatureserver" ), mName );
mParent->refresh();
}
Expand Down
1 change: 1 addition & 0 deletions src/providers/arcgisrest/qgsafsdataitems.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class QgsAfsConnectionItem : public QgsDataCollectionItem
#ifdef HAVE_GUI
void editConnection();
void deleteConnection();
void refreshConnection();
#endif

private:
Expand Down

0 comments on commit 6d5ba5a

Please sign in to comment.