55#include " qgswmsconnection.h"
66#include " qgswmssourceselect.h"
77
8+ #include " qgsnewhttpconnection.h"
9+
810// ---------------------------------------------------------------------------
911QgsWMSConnectionItem::QgsWMSConnectionItem ( QgsDataItem* parent, QString name, QString path )
1012 : QgsDataCollectionItem( parent, name, path )
@@ -60,7 +62,43 @@ bool QgsWMSConnectionItem::equal( const QgsDataItem *other )
6062 const QgsWMSConnectionItem *o = dynamic_cast <const QgsWMSConnectionItem *>( other );
6163 return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
6264}
65+
66+ QList<QAction*> QgsWMSConnectionItem::actions ()
67+ {
68+ QList<QAction*> lst;
69+
70+ QAction* actionEdit = new QAction ( tr ( " Edit..." ), this );
71+ connect ( actionEdit, SIGNAL ( triggered () ), this , SLOT ( editConnection () ) );
72+ lst.append ( actionEdit );
73+
74+ QAction* actionDelete = new QAction ( tr ( " Delete" ), this );
75+ connect ( actionDelete, SIGNAL ( triggered () ), this , SLOT ( deleteConnection () ) );
76+ lst.append ( actionDelete );
77+
78+ return lst;
79+ }
80+
81+ void QgsWMSConnectionItem::editConnection ()
82+ {
83+ QgsNewHttpConnection nc ( 0 , " /Qgis/connections-wms/" , mName );
84+
85+ if ( nc.exec () )
86+ {
87+ // the parent should be updated
88+ mParent ->refresh ();
89+ }
90+ }
91+
92+ void QgsWMSConnectionItem::deleteConnection ()
93+ {
94+ QgsWMSConnection::deleteConnection ( mName );
95+ // the parent should be updated
96+ mParent ->refresh ();
97+ }
98+
99+
63100// ---------------------------------------------------------------------------
101+
64102QgsWMSLayerItem::QgsWMSLayerItem ( QgsDataItem* parent, QString name, QString path, QgsWmsCapabilitiesProperty capabilitiesProperty, QString connInfo, QgsWmsLayerProperty layerProperty )
65103 : QgsLayerItem( parent, name, path, QString(), QgsLayerItem::Raster, "wms" ),
66104 mCapabilitiesProperty( capabilitiesProperty ),
@@ -170,6 +208,18 @@ QVector<QgsDataItem*>QgsWMSRootItem::createChildren()
170208 return connections;
171209}
172210
211+ QList<QAction*> QgsWMSRootItem::actions ()
212+ {
213+ QList<QAction*> lst;
214+
215+ QAction* actionNew = new QAction ( tr ( " New..." ), this );
216+ connect ( actionNew, SIGNAL ( triggered () ), this , SLOT ( newConnection () ) );
217+ lst.append ( actionNew );
218+
219+ return lst;
220+ }
221+
222+
173223QWidget * QgsWMSRootItem::paramWidget ()
174224{
175225 QgsWMSSourceSelect *select = new QgsWMSSourceSelect ( 0 , 0 , true , true );
@@ -181,6 +231,17 @@ void QgsWMSRootItem::connectionsChanged()
181231 refresh ();
182232}
183233
234+ void QgsWMSRootItem::newConnection ()
235+ {
236+ QgsNewHttpConnection nc ( 0 );
237+
238+ if ( nc.exec () )
239+ {
240+ refresh ();
241+ }
242+ }
243+
244+
184245// ---------------------------------------------------------------------------
185246
186247QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem )
0 commit comments