Skip to content
Permalink
Browse files

WMS: add/edit/delete connection from data items

  • Loading branch information
wonder-sk committed Oct 14, 2011
1 parent e045d34 commit befb5f6506b70e7e272702dfa67cd33c70970916
Showing with 72 additions and 0 deletions.
  1. +61 −0 src/providers/wms/qgswmsdataitems.cpp
  2. +11 −0 src/providers/wms/qgswmsdataitems.h
@@ -5,6 +5,8 @@
#include "qgswmsconnection.h"
#include "qgswmssourceselect.h"

#include "qgsnewhttpconnection.h"

// ---------------------------------------------------------------------------
QgsWMSConnectionItem::QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path )
: QgsDataCollectionItem( parent, name, path )
@@ -60,7 +62,43 @@ bool QgsWMSConnectionItem::equal( const QgsDataItem *other )
const QgsWMSConnectionItem *o = dynamic_cast<const QgsWMSConnectionItem *>( other );
return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
}

QList<QAction*> QgsWMSConnectionItem::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 QgsWMSConnectionItem::editConnection()
{
QgsNewHttpConnection nc( 0, "/Qgis/connections-wms/", mName );

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

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


// ---------------------------------------------------------------------------

QgsWMSLayerItem::QgsWMSLayerItem( QgsDataItem* parent, QString name, QString path, QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperty )
: QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, "wms" ),
mCapabilitiesProperty( capabilitiesProperty ),
@@ -170,6 +208,18 @@ QVector<QgsDataItem*>QgsWMSRootItem::createChildren()
return connections;
}

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

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

return lst;
}


QWidget * QgsWMSRootItem::paramWidget()
{
QgsWMSSourceSelect *select = new QgsWMSSourceSelect( 0, 0, true, true );
@@ -181,6 +231,17 @@ void QgsWMSRootItem::connectionsChanged()
refresh();
}

void QgsWMSRootItem::newConnection()
{
QgsNewHttpConnection nc( 0 );

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


// ---------------------------------------------------------------------------

QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
@@ -5,16 +5,23 @@

class QgsWMSConnectionItem : public QgsDataCollectionItem
{
Q_OBJECT
public:
QgsWMSConnectionItem( QgsDataItem* parent, QString name, QString path );
~QgsWMSConnectionItem();

QVector<QgsDataItem*> createChildren();
virtual bool equal( const QgsDataItem *other );

virtual QList<QAction*> actions();

QgsWmsCapabilitiesProperty mCapabilitiesProperty;
QString mConnInfo;
QVector<QgsWmsLayerProperty> mLayerProperties;

public slots:
void editConnection();
void deleteConnection();
};

// WMS Layers may be nested, so that they may be both QgsDataCollectionItem and QgsLayerItem
@@ -43,10 +50,14 @@ class QgsWMSRootItem : public QgsDataCollectionItem

QVector<QgsDataItem*> createChildren();

virtual QList<QAction*> actions();

virtual QWidget * paramWidget();

public slots:
void connectionsChanged();

void newConnection();
};

#endif // QGSWMSDATAITEMS_H

0 comments on commit befb5f6

Please sign in to comment.
You can’t perform that action at this time.