Skip to content

Commit f58fbe0

Browse files
committed
WFS server: insert/update/delete are only dependent on wfs publish property. Funded by Sourcepole QGIS Enterprise
1 parent 6f84cdc commit f58fbe0

File tree

4 files changed

+27
-72
lines changed

4 files changed

+27
-72
lines changed

src/app/qgsprojectproperties.cpp

100755100644
+15-63
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,6 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
373373

374374
QSignalMapper *smPublied = new QSignalMapper( this );
375375
connect( smPublied, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSPubliedStateChanged( int ) ) );
376-
QSignalMapper *smUpdate = new QSignalMapper( this );
377-
connect( smUpdate, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSUpdateStateChanged( int ) ) );
378-
QSignalMapper *smInsert = new QSignalMapper( this );
379-
connect( smInsert, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSInsertStateChanged( int ) ) );
380-
QSignalMapper *smDelete = new QSignalMapper( this );
381-
connect( smDelete, SIGNAL( mapped( int ) ), this, SLOT( cbxWFSDeleteStateChanged( int ) ) );
382376

383377
twWFSLayers->setColumnCount( 6 );
384378
twWFSLayers->horizontalHeader()->setVisible( true );
@@ -418,27 +412,18 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
418412
QCheckBox* cbu = new QCheckBox();
419413
cbu->setChecked( wfstUpdateLayerIdList.contains( currentLayer->id() ) );
420414
twWFSLayers->setCellWidget( j, 3, cbu );
421-
422-
smUpdate->setMapping( cbu, j );
423-
connect( cbu, SIGNAL( stateChanged( int ) ), smUpdate, SLOT( map() ) );
424415
}
425416
if (( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
426417
{
427418
QCheckBox* cbi = new QCheckBox();
428419
cbi->setChecked( wfstInsertLayerIdList.contains( currentLayer->id() ) );
429420
twWFSLayers->setCellWidget( j, 4, cbi );
430-
431-
smInsert->setMapping( cbi, j );
432-
connect( cbi, SIGNAL( stateChanged( int ) ), smInsert, SLOT( map() ) );
433421
}
434422
if (( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
435423
{
436424
QCheckBox* cbd = new QCheckBox();
437425
cbd->setChecked( wfstDeleteLayerIdList.contains( currentLayer->id() ) );
438426
twWFSLayers->setCellWidget( j, 5, cbd );
439-
440-
smDelete->setMapping( cbd, j );
441-
connect( cbd, SIGNAL( stateChanged( int ) ), smDelete, SLOT( map() ) );
442427
}
443428

444429
j++;
@@ -1010,54 +995,21 @@ void QgsProjectProperties::cbxWFSPubliedStateChanged( int aIdx )
1010995
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
1011996
if ( cb && !cb->isChecked() )
1012997
{
1013-
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
1014-
if ( cbn )
1015-
cbn->setChecked( false );
1016-
}
1017-
}
1018-
1019-
void QgsProjectProperties::cbxWFSUpdateStateChanged( int aIdx )
1020-
{
1021-
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
1022-
if ( cb && cb->isChecked() )
1023-
{
1024-
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 1 ) );
1025-
if ( cbn )
1026-
cbn->setChecked( true );
1027-
}
1028-
else if ( cb && !cb->isChecked() )
1029-
{
1030-
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
1031-
if ( cbn )
1032-
cbn->setChecked( false );
1033-
}
1034-
}
1035-
1036-
void QgsProjectProperties::cbxWFSInsertStateChanged( int aIdx )
1037-
{
1038-
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
1039-
if ( cb && cb->isChecked() )
1040-
{
1041-
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 2 ) );
1042-
if ( cbn )
1043-
cbn->setChecked( true );
1044-
}
1045-
else if ( cb && !cb->isChecked() )
1046-
{
1047-
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
1048-
if ( cbn )
1049-
cbn->setChecked( false );
1050-
}
1051-
}
1052-
1053-
void QgsProjectProperties::cbxWFSDeleteStateChanged( int aIdx )
1054-
{
1055-
QCheckBox* cb = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
1056-
if ( cb && cb->isChecked() )
1057-
{
1058-
QCheckBox* cbn = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
1059-
if ( cbn )
1060-
cbn->setChecked( true );
998+
QCheckBox* cbUpdate = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
999+
if ( cbUpdate )
1000+
{
1001+
cbUpdate->setChecked( false );
1002+
}
1003+
QCheckBox* cbInsert = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
1004+
if ( cbInsert )
1005+
{
1006+
cbInsert->setChecked( false );
1007+
}
1008+
QCheckBox* cbDelete = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 5 ) );
1009+
if ( cbDelete )
1010+
{
1011+
cbDelete->setChecked( false );
1012+
}
10611013
}
10621014
}
10631015

src/app/qgsprojectproperties.h

-3
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,6 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
143143
* Slot to link WFS checkboxes
144144
*/
145145
void cbxWFSPubliedStateChanged( int aIdx );
146-
void cbxWFSUpdateStateChanged( int aIdx );
147-
void cbxWFSInsertStateChanged( int aIdx );
148-
void cbxWFSDeleteStateChanged( int aIdx );
149146

150147
/*!
151148
* Slot to link WCS checkboxes

src/mapserver/qgswfsprojectparser.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void QgsWFSProjectParser::featureTypeList( QDomElement& parentElement, QDomDocum
201201

202202
QSet<QString> QgsWFSProjectParser::wfstUpdateLayers() const
203203
{
204-
QStringList publiedIds = mProjectParser.wfsLayers();
204+
QSet<QString> publishedIds = wfsLayerSet();
205205
QSet<QString> wfsList;
206206
if ( !mProjectParser.xmlDocument() )
207207
{
@@ -227,7 +227,7 @@ QSet<QString> QgsWFSProjectParser::wfstUpdateLayers() const
227227
for ( int i = 0; i < valueList.size(); ++i )
228228
{
229229
QString id = valueList.at( i ).toElement().text();
230-
if ( publiedIds.contains( id ) )
230+
if ( publishedIds.contains( id ) )
231231
{
232232
wfsList.insert( id );
233233
}
@@ -237,7 +237,7 @@ QSet<QString> QgsWFSProjectParser::wfstUpdateLayers() const
237237

238238
QSet<QString> QgsWFSProjectParser::wfstInsertLayers() const
239239
{
240-
QSet<QString> updateIds = wfstUpdateLayers();
240+
QSet<QString> publishedIds = wfsLayerSet();
241241
QSet<QString> wfsList;
242242
if ( !mProjectParser.xmlDocument() )
243243
{
@@ -263,7 +263,7 @@ QSet<QString> QgsWFSProjectParser::wfstInsertLayers() const
263263
for ( int i = 0; i < valueList.size(); ++i )
264264
{
265265
QString id = valueList.at( i ).toElement().text();
266-
if ( updateIds.contains( id ) )
266+
if ( publishedIds.contains( id ) )
267267
{
268268
wfsList.insert( id );
269269
}
@@ -273,7 +273,7 @@ QSet<QString> QgsWFSProjectParser::wfstInsertLayers() const
273273

274274
QSet<QString> QgsWFSProjectParser::wfstDeleteLayers() const
275275
{
276-
QSet<QString> insertIds = wfstInsertLayers();
276+
QSet<QString> publishedIds = wfsLayerSet();
277277
QSet<QString> wfsList;
278278
if ( !mProjectParser.xmlDocument() )
279279
{
@@ -299,7 +299,7 @@ QSet<QString> QgsWFSProjectParser::wfstDeleteLayers() const
299299
for ( int i = 0; i < valueList.size(); ++i )
300300
{
301301
QString id = valueList.at( i ).toElement().text();
302-
if ( insertIds.contains( id ) )
302+
if ( publishedIds.contains( id ) )
303303
{
304304
wfsList.insert( id );
305305
}
@@ -463,6 +463,11 @@ QStringList QgsWFSProjectParser::wfsLayers() const
463463
return mProjectParser.wfsLayers();
464464
}
465465

466+
QSet<QString> QgsWFSProjectParser::wfsLayerSet() const
467+
{
468+
return QSet<QString>::fromList( wfsLayers() );
469+
}
470+
466471
int QgsWFSProjectParser::wfsLayerPrecision( const QString& aLayerId ) const
467472
{
468473
QStringList wfsLayersId = mProjectParser.wfsLayers();

src/mapserver/qgswfsprojectparser.h

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class QgsWFSProjectParser
3434
void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const;
3535

3636
QStringList wfsLayers() const;
37+
QSet<QString> wfsLayerSet() const;
3738
int wfsLayerPrecision( const QString& aLayerId ) const;
3839

3940
QList<QgsMapLayer*> mapLayerFromTypeName( const QString& aTypeName, bool useCache = true ) const;

0 commit comments

Comments
 (0)