Skip to content

Commit

Permalink
[geonode] fix data item context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
myarjunar committed Oct 18, 2019
1 parent e3e9d37 commit 3bd9fc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions src/core/geocms/geonode/qgsgeonodeconnection.cpp
Expand Up @@ -102,10 +102,7 @@ QStringList QgsGeoNodeConnectionUtils::connectionList()

void QgsGeoNodeConnectionUtils::deleteConnection( const QString &name )
{
QgsSettings settings;
// Add Section manually
settings.remove( QStringLiteral( "qgis/connections-geonode/" ) + name );
settings.remove( QStringLiteral( "qgis/geonode/" ) + name );
QgsOwsConnection::deleteConnection( QStringLiteral( "GEONODE" ), name );
}

QString QgsGeoNodeConnectionUtils::pathGeoNodeConnection()
Expand Down
8 changes: 7 additions & 1 deletion src/providers/geonode/qgsgeonodedataitemguiprovider.cpp
Expand Up @@ -17,6 +17,8 @@
#include "qgsgeonodedataitems.h"
#include "qgsgeonodenewconnection.h"

#include <QMessageBox>

void QgsGeoNodeDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *menu, const QList<QgsDataItem *> &, QgsDataItemGuiContext )
{
if ( QgsGeoNodeRootItem *rootItem = qobject_cast< QgsGeoNodeRootItem * >( item ) )
Expand All @@ -25,7 +27,7 @@ void QgsGeoNodeDataItemGuiProvider::populateContextMenu( QgsDataItem *item, QMen
connect( actionNew, &QAction::triggered, this, [rootItem] { newConnection( rootItem ); } );
menu->addAction( actionNew );
}
else if ( QgsGeoNodeRootItem *connItem = qobject_cast< QgsGeoNodeRootItem * >( item ) )
else if ( QgsGeoNodeConnectionItem *connItem = qobject_cast< QgsGeoNodeConnectionItem * >( item ) )
{
QAction *actionEdit = new QAction( tr( "Edit Connection…" ), menu );
connect( actionEdit, &QAction::triggered, this, [connItem] { editConnection( connItem ); } );
Expand Down Expand Up @@ -61,6 +63,10 @@ void QgsGeoNodeDataItemGuiProvider::editConnection( QgsDataItem *item )

void QgsGeoNodeDataItemGuiProvider::deleteConnection( QgsDataItem *item )
{
if ( QMessageBox::question( nullptr, tr( "Delete Connection" ), tr( "Are you sure you want to delete the connection “%1”?" ).arg( item->name() ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;

QgsGeoNodeConnectionUtils::deleteConnection( item->name() );
item->parent()->refresh();
}

0 comments on commit 3bd9fc6

Please sign in to comment.