Skip to content
Permalink
Browse files
WFS: add/edit/delete actions in browser
  • Loading branch information
wonder-sk committed Oct 11, 2011
1 parent 69138fd commit 318a36b660b31584e79d03bf25a3f04107e057ae
Showing with 69 additions and 0 deletions.
  1. +60 −0 src/providers/wfs/qgswfsdataitems.cpp
  2. +9 −0 src/providers/wfs/qgswfsdataitems.h
@@ -4,6 +4,8 @@
#include "qgswfsconnection.h"
#include "qgswfssourceselect.h"

#include "qgsnewhttpconnection.h"

#include <QSettings>
#include <QCoreApplication>

@@ -69,6 +71,42 @@ void QgsWFSConnectionItem::gotCapabilities()
mGotCapabilities = true;
}

QList<QAction*> QgsWFSConnectionItem::actions()
{
QList<QAction*> lst;

QAction* actionEdit = new QAction( tr( "Edit..." ), this );
connect( actionEdit, SIGNAL( triggered() ), this, SLOT( editConnection() ) );
lst.append( actionEdit );

QAction* actionDelete = new QAction( tr( "Delete" ), this );
connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteConnection() ) );
lst.append( actionDelete );

return lst;
}

void QgsWFSConnectionItem::editConnection()
{
QgsNewHttpConnection nc( 0, "/Qgis/connections-wfs/", mName );
nc.setWindowTitle( tr( "Modify WFS connection" ) );

if ( nc.exec() )
{
// the parent should be updated
mParent->refresh();
}
}

void QgsWFSConnectionItem::deleteConnection()
{
QgsWFSConnection::deleteConnection( mName );
// the parent should be updated
mParent->refresh();
}



//////


@@ -98,6 +136,17 @@ QVector<QgsDataItem*> QgsWFSRootItem::createChildren()
return connections;
}

QList<QAction*> QgsWFSRootItem::actions()
{
QList<QAction*> lst;

QAction* actionNew = new QAction( tr( "New..." ), this );
connect( actionNew, SIGNAL( triggered() ), this, SLOT( newConnection() ) );
lst.append( actionNew );

return lst;
}

QWidget * QgsWFSRootItem::paramWidget()
{
QgsWFSSourceSelect *select = new QgsWFSSourceSelect( 0, 0 );
@@ -110,6 +159,17 @@ void QgsWFSRootItem::connectionsChanged()
refresh();
}

void QgsWFSRootItem::newConnection()
{
QgsNewHttpConnection nc( 0, "/Qgis/connections-wfs/" );
nc.setWindowTitle( tr( "Create a new WFS connection" ) );

if ( nc.exec() )
{
refresh();
}
}


QGISEXTERN int dataCapabilities()
{
@@ -12,10 +12,14 @@ class QgsWFSRootItem : public QgsDataCollectionItem

QVector<QgsDataItem*> createChildren();

virtual QList<QAction*> actions();

virtual QWidget * paramWidget();

public slots:
void connectionsChanged();

void newConnection();
};

class QgsWFSConnection;
@@ -30,9 +34,14 @@ class QgsWFSConnectionItem : public QgsDataCollectionItem
QVector<QgsDataItem*> createChildren();
//virtual bool equal( const QgsDataItem *other );

virtual QList<QAction*> actions();

private slots:
void gotCapabilities();

void editConnection();
void deleteConnection();

private:
QString mName;

0 comments on commit 318a36b

Please sign in to comment.