Skip to content

Commit

Permalink
#6533 QGIS WFS Server Transaction Request
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Oct 18, 2012
1 parent 9faa401 commit 63e8188
Show file tree
Hide file tree
Showing 14 changed files with 1,802 additions and 1,040 deletions.
141 changes: 133 additions & 8 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -33,6 +33,8 @@
#include "qgsrenderer.h"
#include "qgssnappingdialog.h"
#include "qgsrasterlayer.h"
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsscaleutils.h"
#include "qgsgenericprojectionselector.h"
#include "qgsstylev2.h"
Expand Down Expand Up @@ -298,8 +300,20 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
}

QStringList wfsLayerIdList = QgsProject::instance()->readListEntry( "WFSLayers", "/" );

twWFSLayers->setColumnCount( 2 );
QStringList wfstUpdateLayerIdList = QgsProject::instance()->readListEntry( "WFSTLayers", "Update" );
QStringList wfstInsertLayerIdList = QgsProject::instance()->readListEntry( "WFSTLayers", "Insert" );
QStringList wfstDeleteLayerIdList = QgsProject::instance()->readListEntry( "WFSTLayers", "Delete" );

QSignalMapper *smPublied = new QSignalMapper(this);
connect(smPublied, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSPublied_stateChanged(int)));
QSignalMapper *smUpdate = new QSignalMapper(this);
connect(smUpdate, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSUpdate_stateChanged(int)));
QSignalMapper *smInsert = new QSignalMapper(this);
connect(smInsert, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSInsert_stateChanged(int)));
QSignalMapper *smDelete = new QSignalMapper(this);
connect(smDelete, SIGNAL(mapped(int)), this, SLOT(on_cbxWFSDelete_stateChanged(int)));

twWFSLayers->setColumnCount( 5 );
twWFSLayers->horizontalHeader()->setVisible( true );
twWFSLayers->setRowCount( mapLayers.size() );

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

QCheckBox *cb = new QCheckBox();
cb->setChecked( wfsLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 1, cb );
j++;
QCheckBox* cbp = new QCheckBox();
cbp->setChecked( wfsLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 1, cbp );

smPublied->setMapping(cbp, j);
connect(cbp, SIGNAL(stateChanged(int)), smPublied, SLOT(map()));

QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer*>( currentLayer );
QgsVectorDataProvider* provider = vlayer->dataProvider();
if ( (provider->capabilities() & QgsVectorDataProvider::ChangeAttributeValues ) && (provider->capabilities() & QgsVectorDataProvider::ChangeGeometries ) )
{
QCheckBox* cbu = new QCheckBox();
cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 2, cbu );

smUpdate->setMapping(cbu, j);
connect(cbu, SIGNAL(stateChanged(int)), smUpdate, SLOT(map()));
}
if ( ( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
{
QCheckBox* cbi = new QCheckBox();
cbi->setChecked( wfstInsertLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 3, cbi );

smInsert->setMapping(cbi, j);
connect(cbi, SIGNAL(stateChanged(int)), smInsert, SLOT(map()));
}
if ( ( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
{
QCheckBox* cbd = new QCheckBox();
cbd->setChecked( wfstDeleteLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 4, cbd );

smDelete->setMapping(cbd, j);
connect(cbd, SIGNAL(stateChanged(int)), smDelete, SLOT(map()));
}

j++;
}
}
twWFSLayers->setRowCount( j );
Expand Down Expand Up @@ -610,16 +657,38 @@ void QgsProjectProperties::apply()
}

QStringList wfsLayerList;
QStringList wfstUpdateLayerList;
QStringList wfstInsertLayerList;
QStringList wfstDeleteLayerList;
for ( int i = 0; i < twWFSLayers->rowCount(); i++ )
{
QCheckBox *cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 1 ) );
QString id = twWFSLayers->item( i, 0 )->data( Qt::UserRole ).toString();
QCheckBox* cb;
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 1 ) );
if ( cb && cb->isChecked() )
{
QString id = twWFSLayers->item( i, 0 )->data( Qt::UserRole ).toString();
wfsLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 2 ) );
if ( cb && cb->isChecked() )
{
wfstUpdateLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 3 ) );
if ( cb && cb->isChecked() )
{
wfstInsertLayerList << id;
}
cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( i, 4 ) );
if ( cb && cb->isChecked() )
{
wfstDeleteLayerList << id;
}
}
QgsProject::instance()->writeEntry( "WFSLayers", "/", wfsLayerList );
QgsProject::instance()->writeEntry( "WFSTLayers", "Update", wfstUpdateLayerList );
QgsProject::instance()->writeEntry( "WFSTLayers", "Insert", wfstInsertLayerList );
QgsProject::instance()->writeEntry( "WFSTLayers", "Delete", wfstDeleteLayerList );

// Default Styles
QgsProject::instance()->writeEntry( "DefaultStyles", "/Marker", cboStyleMarker->currentText() );
Expand Down Expand Up @@ -691,6 +760,62 @@ void QgsProjectProperties::on_cbxProjectionEnabled_stateChanged( int state )
}
}

void QgsProjectProperties::on_cbxWFSPublied_stateChanged( int aIdx )
{
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
if ( cb && !cb->isChecked() )
{
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
if ( cbn )
cbn->setChecked(false);
}
}

void QgsProjectProperties::on_cbxWFSUpdate_stateChanged( int aIdx )
{
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
if ( cb && cb->isChecked() )
{
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
if ( cbn )
cbn->setChecked(true);
}
else if ( cb && !cb->isChecked() )
{
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
if ( cbn )
cbn->setChecked(false);
}
}

void QgsProjectProperties::on_cbxWFSInsert_stateChanged( int aIdx )
{
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
if ( cb && cb->isChecked() )
{
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
if ( cbn )
cbn->setChecked(true);
}
else if ( cb && !cb->isChecked() )
{
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
if ( cbn )
cbn->setChecked(false);
}
}

void QgsProjectProperties::on_cbxWFSDelete_stateChanged( int aIdx )
{
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
if ( cb && cb->isChecked() )
{
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
if ( cbn )
cbn->setChecked(true);
}
}

void QgsProjectProperties::setMapUnitsToCurrentProjection()
{
long myCRSID = projectionSelector->selectedCrsId();
Expand Down
8 changes: 8 additions & 0 deletions src/app/qgsprojectproperties.h
Expand Up @@ -139,6 +139,14 @@ class QgsProjectProperties : public QDialog, private Ui::QgsProjectPropertiesBas
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }

void on_cbxProjectionEnabled_stateChanged( int state );

/*!
* Slot to link WFS checkboxes
*/
void on_cbxWFSPublied_stateChanged( int aIdx );
void on_cbxWFSUpdate_stateChanged( int aIdx );
void on_cbxWFSInsert_stateChanged( int aIdx );
void on_cbxWFSDelete_stateChanged( int aIdx );

/*!
* If user changes the CRS, set the corresponding map units
Expand Down

0 comments on commit 63e8188

Please sign in to comment.