Showing with 83 additions and 3 deletions.
  1. +61 −1 src/providers/wfs/qgswfsdataitems.cpp
  2. +9 −0 src/providers/wfs/qgswfsdataitems.h
  3. +12 −1 src/providers/wfs/qgswfssourceselect.cpp
  4. +1 −1 src/providers/wfs/qgswfssourceselect.h
62 changes: 61 additions & 1 deletion 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,9 +136,20 @@ 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 );
QgsWFSSourceSelect *select = new QgsWFSSourceSelect( 0, 0, true );
connect( select, SIGNAL( connectionsChanged() ), this, SLOT( connectionsChanged() ) );
return select;
}
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
13 changes: 12 additions & 1 deletion src/providers/wfs/qgswfssourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,25 @@
#include <QFileDialog>


QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl )
QgsWFSSourceSelect::QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl, bool embeddedMode )
: QDialog( parent, fl )
, mConn( NULL )
{
setupUi( this );

btnAdd = buttonBox->button( QDialogButtonBox::Ok );
btnAdd->setEnabled( false );

if ( embeddedMode )
{
buttonBox->button( QDialogButtonBox::Ok )->hide();
buttonBox->button( QDialogButtonBox::Cancel )->hide();
}

// keep the "use current view extent" checkbox hidden until
// the functionality is reintroduced [MD]
mBboxCheckBox->hide();

connect( buttonBox, SIGNAL( accepted() ), this, SLOT( addLayer() ) );
connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) );
connect( btnNew, SIGNAL( clicked() ), this, SLOT( addEntryToServerList() ) );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfssourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class QgsWFSSourceSelect: public QDialog, private Ui::QgsWFSSourceSelectBase

public:

QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl );
QgsWFSSourceSelect( QWidget* parent, Qt::WFlags fl, bool embeddedMode = false );
~QgsWFSSourceSelect();

signals:
Expand Down