Skip to content

Commit

Permalink
WFS: add/edit/delete actions in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Oct 11, 2011
1 parent 69138fd commit 318a36b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/providers/wfs/qgswfsdataitems.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "qgswfsconnection.h"
#include "qgswfssourceselect.h"

#include "qgsnewhttpconnection.h"

#include <QSettings>
#include <QCoreApplication>

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



//////


Expand Down Expand Up @@ -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 );
Expand All @@ -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()
{
Expand Down
9 changes: 9 additions & 0 deletions src/providers/wfs/qgswfsdataitems.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit 318a36b

Please sign in to comment.