Skip to content

Commit 63e8188

Browse files
committedOct 18, 2012
#6533 QGIS WFS Server Transaction Request
1 parent 9faa401 commit 63e8188

14 files changed

+1802
-1040
lines changed
 

‎src/app/qgsprojectproperties.cpp

Lines changed: 133 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "qgsrenderer.h"
3434
#include "qgssnappingdialog.h"
3535
#include "qgsrasterlayer.h"
36+
#include "qgsvectorlayer.h"
37+
#include "qgsvectordataprovider.h"
3638
#include "qgsscaleutils.h"
3739
#include "qgsgenericprojectionselector.h"
3840
#include "qgsstylev2.h"
@@ -298,8 +300,20 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
298300
}
299301

300302
QStringList wfsLayerIdList = QgsProject::instance()->readListEntry( "WFSLayers", "/" );
301-
302-
twWFSLayers->setColumnCount( 2 );
303+
QStringList wfstUpdateLayerIdList = QgsProject::instance()->readListEntry( "WFSTLayers", "Update" );
304+
QStringList wfstInsertLayerIdList = QgsProject::instance()->readListEntry( "WFSTLayers", "Insert" );
305+
QStringList wfstDeleteLayerIdList = QgsProject::instance()->readListEntry( "WFSTLayers", "Delete" );
306+
307+
QSignalMapper *smPublied = new QSignalMapper(this);
308+
connect(smPublied, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSPublied_stateChanged(int)));
309+
QSignalMapper *smUpdate = new QSignalMapper(this);
310+
connect(smUpdate, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSUpdate_stateChanged(int)));
311+
QSignalMapper *smInsert = new QSignalMapper(this);
312+
connect(smInsert, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSInsert_stateChanged(int)));
313+
QSignalMapper *smDelete = new QSignalMapper(this);
314+
connect(smDelete, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSDelete_stateChanged(int)));
315+
316+
twWFSLayers->setColumnCount( 5 );
303317
twWFSLayers->horizontalHeader()->setVisible( true );
304318
twWFSLayers->setRowCount( mapLayers.size() );
305319

@@ -319,11 +333,44 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
319333
twi->setFlags( twi->flags() & ~Qt::ItemIsEditable );
320334
twWFSLayers->setItem( j, 0, twi );
321335

322-
QCheckBox *cb = new QCheckBox();
323-
cb->setChecked( wfsLayerIdList.contains( currentLayer->id() ) );
324-
twWFSLayers->setCellWidget( j, 1, cb );
325-
j++;
336+
QCheckBox* cbp = new QCheckBox();
337+
cbp->setChecked( wfsLayerIdList.contains( currentLayer->id() ) );
338+
twWFSLayers->setCellWidget( j, 1, cbp );
339+
340+
smPublied->setMapping(cbp, j);
341+
connect(cbp, SIGNAL(stateChanged(int)), smPublied, SLOT(map()));
342+
343+
QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( currentLayer );
344+
QgsVectorDataProvider* provider = vlayer->dataProvider();
345+
if ( (provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) && (provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) )
346+
{
347+
QCheckBox* cbu = new QCheckBox();
348+
cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) );
349+
twWFSLayers->setCellWidget( j, 2, cbu );
350+
351+
smUpdate->setMapping(cbu, j);
352+
connect(cbu, SIGNAL(stateChanged(int)), smUpdate, SLOT(map()));
353+
}
354+
if ( ( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
355+
{
356+
QCheckBox* cbi = new QCheckBox();
357+
cbi->setChecked( wfstInsertLayerIdList.contains( currentLayer->id() ) );
358+
twWFSLayers->setCellWidget( j, 3, cbi );
359+
360+
smInsert->setMapping(cbi, j);
361+
connect(cbi, SIGNAL(stateChanged(int)), smInsert, SLOT(map()));
362+
}
363+
if ( ( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
364+
{
365+
QCheckBox* cbd = new QCheckBox();
366+
cbd->setChecked( wfstDeleteLayerIdList.contains( currentLayer->id() ) );
367+
twWFSLayers->setCellWidget( j, 4, cbd );
368+
369+
smDelete->setMapping(cbd, j);
370+
connect(cbd, SIGNAL(stateChanged(int)), smDelete, SLOT(map()));
371+
}
326372

373+
j++;
327374
}
328375
}
329376
twWFSLayers->setRowCount( j );
@@ -610,16 +657,38 @@ void QgsProjectProperties::apply()
610657
}
611658

612659
QStringList wfsLayerList;
660+
QStringList wfstUpdateLayerList;
661+
QStringList wfstInsertLayerList;
662+
QStringList wfstDeleteLayerList;
613663
for ( int i = 0; i < twWFSLayers->rowCount(); i++ )
614664
{
615-
QCheckBox *cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 1 ) );
665+
QString id = twWFSLayers->item( i, 0 )->data( Qt::UserRole ).toString();
666+
QCheckBox* cb;
667+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 1 ) );
616668
if ( cb && cb->isChecked() )
617669
{
618-
QString id = twWFSLayers->item( i, 0 )->data( Qt::UserRole ).toString();
619670
wfsLayerList << id;
620671
}
672+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 2 ) );
673+
if ( cb && cb->isChecked() )
674+
{
675+
wfstUpdateLayerList << id;
676+
}
677+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 3 ) );
678+
if ( cb && cb->isChecked() )
679+
{
680+
wfstInsertLayerList << id;
681+
}
682+
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 4 ) );
683+
if ( cb && cb->isChecked() )
684+
{
685+
wfstDeleteLayerList << id;
686+
}
621687
}
622688
QgsProject::instance()->writeEntry( "WFSLayers", "/", wfsLayerList );
689+
QgsProject::instance()->writeEntry( "WFSTLayers", "Update", wfstUpdateLayerList );
690+
QgsProject::instance()->writeEntry( "WFSTLayers", "Insert", wfstInsertLayerList );
691+
QgsProject::instance()->writeEntry( "WFSTLayers", "Delete", wfstDeleteLayerList );
623692

624693
// Default Styles
625694
QgsProject::instance()->writeEntry( "DefaultStyles", "/Marker", cboStyleMarker->currentText() );
@@ -691,6 +760,62 @@ void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
691760
}
692761
}
693762

763+
void QgsProjectProperties::on_cbxWFSPublied_stateChanged( int aIdx )
764+
{
765+
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
766+
if ( cb && !cb->isChecked() )
767+
{
768+
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
769+
if ( cbn )
770+
cbn->setChecked(false);
771+
}
772+
}
773+
774+
void QgsProjectProperties::on_cbxWFSUpdate_stateChanged( int aIdx )
775+
{
776+
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
777+
if ( cb && cb->isChecked() )
778+
{
779+
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
780+
if ( cbn )
781+
cbn->setChecked(true);
782+
}
783+
else if ( cb && !cb->isChecked() )
784+
{
785+
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
786+
if ( cbn )
787+
cbn->setChecked(false);
788+
}
789+
}
790+
791+
void QgsProjectProperties::on_cbxWFSInsert_stateChanged( int aIdx )
792+
{
793+
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
794+
if ( cb && cb->isChecked() )
795+
{
796+
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
797+
if ( cbn )
798+
cbn->setChecked(true);
799+
}
800+
else if ( cb && !cb->isChecked() )
801+
{
802+
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
803+
if ( cbn )
804+
cbn->setChecked(false);
805+
}
806+
}
807+
808+
void QgsProjectProperties::on_cbxWFSDelete_stateChanged( int aIdx )
809+
{
810+
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
811+
if ( cb && cb->isChecked() )
812+
{
813+
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
814+
if ( cbn )
815+
cbn->setChecked(true);
816+
}
817+
}
818+
694819
void QgsProjectProperties::setMapUnitsToCurrentProjection()
695820
{
696821
long myCRSID = projectionSelector->selectedCrsId();

‎src/app/qgsprojectproperties.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
139139
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
140140

141141
void on_cbxProjectionEnabled_stateChanged( int state );
142+
143+
/*!
144+
* Slot to link WFS checkboxes
145+
*/
146+
void on_cbxWFSPublied_stateChanged( int aIdx );
147+
void on_cbxWFSUpdate_stateChanged( int aIdx );
148+
void on_cbxWFSInsert_stateChanged( int aIdx );
149+
void on_cbxWFSDelete_stateChanged( int aIdx );
142150

143151
/*!
144152
* If user changes the CRS, set the corresponding map units

0 commit comments

Comments
 (0)
Please sign in to comment.