@@ -4455,6 +4455,41 @@ bool QgsPGConnectionItem::equal( const QgsDataItem *other )
44554455 const QgsPGConnectionItem *o = dynamic_cast <const QgsPGConnectionItem *>( other );
44564456 return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
44574457}
4458+
4459+ QList<QAction*> QgsPGConnectionItem::actions ()
4460+ {
4461+ QList<QAction*> lst;
4462+
4463+ QAction* actionEdit = new QAction ( tr ( " Edit..." ), this );
4464+ connect ( actionEdit, SIGNAL ( triggered () ), this , SLOT ( editConnection () ) );
4465+ lst.append ( actionEdit );
4466+
4467+ QAction* actionDelete = new QAction ( tr ( " Delete" ), this );
4468+ connect ( actionDelete, SIGNAL ( triggered () ), this , SLOT ( deleteConnection () ) );
4469+ lst.append ( actionDelete );
4470+
4471+ return lst;
4472+ }
4473+
4474+ #include " qgspgnewconnection.h"
4475+ void QgsPGConnectionItem::editConnection ()
4476+ {
4477+ QgsPgNewConnection nc ( NULL , mName );
4478+ if ( nc.exec () )
4479+ {
4480+ // the parent should be updated
4481+ mParent ->refresh ();
4482+ }
4483+ }
4484+
4485+ void QgsPGConnectionItem::deleteConnection ()
4486+ {
4487+ QgsPgSourceSelect::deleteConnection ( mName );
4488+ // the parent should be updated
4489+ mParent ->refresh ();
4490+ }
4491+
4492+
44584493// ---------------------------------------------------------------------------
44594494QgsPGLayerItem::QgsPGLayerItem ( QgsDataItem* parent, QString name, QString path, QString connInfo, QgsLayerItem::LayerType layerType, QgsPostgresLayerProperty layerProperty )
44604495 : QgsLayerItem( parent, name, path, QString(), layerType, "postgres" ),
@@ -4543,6 +4578,17 @@ QVector<QgsDataItem*>QgsPGRootItem::createChildren()
45434578 return connections;
45444579}
45454580
4581+ QList<QAction*> QgsPGRootItem::actions ()
4582+ {
4583+ QList<QAction*> lst;
4584+
4585+ QAction* actionNew = new QAction ( tr ( " New..." ), this );
4586+ connect ( actionNew, SIGNAL ( triggered () ), this , SLOT ( newConnection () ) );
4587+ lst.append ( actionNew );
4588+
4589+ return lst;
4590+ }
4591+
45464592QWidget * QgsPGRootItem::paramWidget ()
45474593{
45484594 QgsPgSourceSelect *select = new QgsPgSourceSelect ( 0 , 0 , true , true );
@@ -4554,6 +4600,15 @@ void QgsPGRootItem::connectionsChanged()
45544600 refresh ();
45554601}
45564602
4603+ void QgsPGRootItem::newConnection ()
4604+ {
4605+ QgsPgNewConnection nc ( NULL );
4606+ if ( nc.exec () )
4607+ {
4608+ refresh ();
4609+ }
4610+ }
4611+
45574612// ---------------------------------------------------------------------------
45584613
45594614QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem )
0 commit comments