From f58fbe0d7cac662ffff28421964c4c06b5a5fefe Mon Sep 17 00:00:00 2001 From: Marco Hugentobler Date: Mon, 22 Sep 2014 09:37:47 +0200 Subject: [PATCH] WFS server: insert/update/delete are only dependent on wfs publish property. Funded by Sourcepole QGIS Enterprise --- src/app/qgsprojectproperties.cpp | 78 ++++++--------------------- src/app/qgsprojectproperties.h | 3 -- src/mapserver/qgswfsprojectparser.cpp | 17 +++--- src/mapserver/qgswfsprojectparser.h | 1 + 4 files changed, 27 insertions(+), 72 deletions(-) mode change 100755 => 100644 src/app/qgsprojectproperties.cpp diff --git a/src/app/qgsprojectproperties.cpp b/src/app/qgsprojectproperties.cpp old mode 100755 new mode 100644 index 4aef03f9cea1..f8b6102d3861 --- a/src/app/qgsprojectproperties.cpp +++ b/src/app/qgsprojectproperties.cpp @@ -373,12 +373,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa QSignalMapper *smPublied = new QSignalMapper( this ); connect( smPublied, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSPubliedStateChanged( int ) ) ); - QSignalMapper *smUpdate = new QSignalMapper( this ); - connect( smUpdate, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSUpdateStateChanged( int ) ) ); - QSignalMapper *smInsert = new QSignalMapper( this ); - connect( smInsert, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSInsertStateChanged( int ) ) ); - QSignalMapper *smDelete = new QSignalMapper( this ); - connect( smDelete, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSDeleteStateChanged( int ) ) ); twWFSLayers->setColumnCount( 6 ); twWFSLayers->horizontalHeader()->setVisible( true ); @@ -418,27 +412,18 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa QCheckBox* cbu = new QCheckBox(); cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) ); twWFSLayers->setCellWidget( j, 3, 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, 4, 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, 5, cbd ); - - smDelete->setMapping( cbd, j ); - connect( cbd, SIGNAL( stateChanged( int ) ), smDelete, SLOT( map() ) ); } j++; @@ -1010,54 +995,21 @@ void QgsProjectProperties::cbxWFSPubliedStateChanged( int aIdx ) QCheckBox* cb = qobject_cast( twWFSLayers->cellWidget( aIdx, 1 ) ); if ( cb && !cb->isChecked() ) { - QCheckBox* cbn = qobject_cast( twWFSLayers->cellWidget( aIdx, 2 ) ); - if ( cbn ) - cbn->setChecked( false ); - } -} - -void QgsProjectProperties::cbxWFSUpdateStateChanged( int aIdx ) -{ - QCheckBox* cb = qobject_cast( twWFSLayers->cellWidget( aIdx, 2 ) ); - if ( cb && cb->isChecked() ) - { - QCheckBox* cbn = qobject_cast( twWFSLayers->cellWidget( aIdx, 1 ) ); - if ( cbn ) - cbn->setChecked( true ); - } - else if ( cb && !cb->isChecked() ) - { - QCheckBox* cbn = qobject_cast( twWFSLayers->cellWidget( aIdx, 3 ) ); - if ( cbn ) - cbn->setChecked( false ); - } -} - -void QgsProjectProperties::cbxWFSInsertStateChanged( int aIdx ) -{ - QCheckBox* cb = qobject_cast( twWFSLayers->cellWidget( aIdx, 3 ) ); - if ( cb && cb->isChecked() ) - { - QCheckBox* cbn = qobject_cast( twWFSLayers->cellWidget( aIdx, 2 ) ); - if ( cbn ) - cbn->setChecked( true ); - } - else if ( cb && !cb->isChecked() ) - { - QCheckBox* cbn = qobject_cast( twWFSLayers->cellWidget( aIdx, 4 ) ); - if ( cbn ) - cbn->setChecked( false ); - } -} - -void QgsProjectProperties::cbxWFSDeleteStateChanged( int aIdx ) -{ - QCheckBox* cb = qobject_cast( twWFSLayers->cellWidget( aIdx, 4 ) ); - if ( cb && cb->isChecked() ) - { - QCheckBox* cbn = qobject_cast( twWFSLayers->cellWidget( aIdx, 3 ) ); - if ( cbn ) - cbn->setChecked( true ); + QCheckBox* cbUpdate = qobject_cast( twWFSLayers->cellWidget( aIdx, 3 ) ); + if ( cbUpdate ) + { + cbUpdate->setChecked( false ); + } + QCheckBox* cbInsert = qobject_cast( twWFSLayers->cellWidget( aIdx, 4 ) ); + if ( cbInsert ) + { + cbInsert->setChecked( false ); + } + QCheckBox* cbDelete = qobject_cast( twWFSLayers->cellWidget( aIdx, 5 ) ); + if ( cbDelete ) + { + cbDelete->setChecked( false ); + } } } diff --git a/src/app/qgsprojectproperties.h b/src/app/qgsprojectproperties.h index a102c676d4da..116db6105d33 100644 --- a/src/app/qgsprojectproperties.h +++ b/src/app/qgsprojectproperties.h @@ -143,9 +143,6 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui: * Slot to link WFS checkboxes */ void cbxWFSPubliedStateChanged( int aIdx ); - void cbxWFSUpdateStateChanged( int aIdx ); - void cbxWFSInsertStateChanged( int aIdx ); - void cbxWFSDeleteStateChanged( int aIdx ); /*! * Slot to link WCS checkboxes diff --git a/src/mapserver/qgswfsprojectparser.cpp b/src/mapserver/qgswfsprojectparser.cpp index 7deff1a913b0..3bff183672d1 100644 --- a/src/mapserver/qgswfsprojectparser.cpp +++ b/src/mapserver/qgswfsprojectparser.cpp @@ -201,7 +201,7 @@ void QgsWFSProjectParser::featureTypeList( QDomElement& parentElement, QDomDocum QSet QgsWFSProjectParser::wfstUpdateLayers() const { - QStringList publiedIds = mProjectParser.wfsLayers(); + QSet publishedIds = wfsLayerSet(); QSet wfsList; if ( !mProjectParser.xmlDocument() ) { @@ -227,7 +227,7 @@ QSet QgsWFSProjectParser::wfstUpdateLayers() const for ( int i = 0; i < valueList.size(); ++i ) { QString id = valueList.at( i ).toElement().text(); - if ( publiedIds.contains( id ) ) + if ( publishedIds.contains( id ) ) { wfsList.insert( id ); } @@ -237,7 +237,7 @@ QSet QgsWFSProjectParser::wfstUpdateLayers() const QSet QgsWFSProjectParser::wfstInsertLayers() const { - QSet updateIds = wfstUpdateLayers(); + QSet publishedIds = wfsLayerSet(); QSet wfsList; if ( !mProjectParser.xmlDocument() ) { @@ -263,7 +263,7 @@ QSet QgsWFSProjectParser::wfstInsertLayers() const for ( int i = 0; i < valueList.size(); ++i ) { QString id = valueList.at( i ).toElement().text(); - if ( updateIds.contains( id ) ) + if ( publishedIds.contains( id ) ) { wfsList.insert( id ); } @@ -273,7 +273,7 @@ QSet QgsWFSProjectParser::wfstInsertLayers() const QSet QgsWFSProjectParser::wfstDeleteLayers() const { - QSet insertIds = wfstInsertLayers(); + QSet publishedIds = wfsLayerSet(); QSet wfsList; if ( !mProjectParser.xmlDocument() ) { @@ -299,7 +299,7 @@ QSet QgsWFSProjectParser::wfstDeleteLayers() const for ( int i = 0; i < valueList.size(); ++i ) { QString id = valueList.at( i ).toElement().text(); - if ( insertIds.contains( id ) ) + if ( publishedIds.contains( id ) ) { wfsList.insert( id ); } @@ -463,6 +463,11 @@ QStringList QgsWFSProjectParser::wfsLayers() const return mProjectParser.wfsLayers(); } +QSet QgsWFSProjectParser::wfsLayerSet() const +{ + return QSet::fromList( wfsLayers() ); +} + int QgsWFSProjectParser::wfsLayerPrecision( const QString& aLayerId ) const { QStringList wfsLayersId = mProjectParser.wfsLayers(); diff --git a/src/mapserver/qgswfsprojectparser.h b/src/mapserver/qgswfsprojectparser.h index 25835f3193bb..736c7d87c1f6 100644 --- a/src/mapserver/qgswfsprojectparser.h +++ b/src/mapserver/qgswfsprojectparser.h @@ -34,6 +34,7 @@ class QgsWFSProjectParser void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const; QStringList wfsLayers() const; + QSet wfsLayerSet() const; int wfsLayerPrecision( const QString& aLayerId ) const; QList mapLayerFromTypeName( const QString& aTypeName, bool useCache = true ) const;