@@ -4455,6 +4455,41 @@ bool QgsPGConnectionItem::equal( const QgsDataItem *other )
4455
4455
const QgsPGConnectionItem *o = dynamic_cast <const QgsPGConnectionItem *>( other );
4456
4456
return ( mPath == o->mPath && mName == o->mName && mConnInfo == o->mConnInfo );
4457
4457
}
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
+
4458
4493
// ---------------------------------------------------------------------------
4459
4494
QgsPGLayerItem::QgsPGLayerItem ( QgsDataItem* parent, QString name, QString path, QString connInfo, QgsLayerItem::LayerType layerType, QgsPostgresLayerProperty layerProperty )
4460
4495
: QgsLayerItem( parent, name, path, QString(), layerType, "postgres" ),
@@ -4543,6 +4578,17 @@ QVector<QgsDataItem*>QgsPGRootItem::createChildren()
4543
4578
return connections;
4544
4579
}
4545
4580
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
+
4546
4592
QWidget * QgsPGRootItem::paramWidget ()
4547
4593
{
4548
4594
QgsPgSourceSelect *select = new QgsPgSourceSelect ( 0 , 0 , true , true );
@@ -4554,6 +4600,15 @@ void QgsPGRootItem::connectionsChanged()
4554
4600
refresh ();
4555
4601
}
4556
4602
4603
+ void QgsPGRootItem::newConnection ()
4604
+ {
4605
+ QgsPgNewConnection nc ( NULL );
4606
+ if ( nc.exec () )
4607
+ {
4608
+ refresh ();
4609
+ }
4610
+ }
4611
+
4557
4612
// ---------------------------------------------------------------------------
4558
4613
4559
4614
QGISEXTERN QgsDataItem * dataItem ( QString thePath, QgsDataItem* parentItem )
0 commit comments