Skip to content

Commit

Permalink
WFS server: insert/update/delete are only dependent on wfs publish pr…
Browse files Browse the repository at this point in the history
…operty. Funded by Sourcepole QGIS Enterprise
  • Loading branch information
mhugent committed Sep 22, 2014
1 parent 6f84cdc commit f58fbe0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 72 deletions.
78 changes: 15 additions & 63 deletions src/app/qgsprojectproperties.cpp 100755 → 100644
Expand Up @@ -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 );
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -1010,54 +995,21 @@ void QgsProjectProperties::cbxWFSPubliedStateChanged( 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::cbxWFSUpdateStateChanged( 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::cbxWFSInsertStateChanged( 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::cbxWFSDeleteStateChanged( 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 );
QCheckBox* cbUpdate = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 3 ) );
if ( cbUpdate )
{
cbUpdate->setChecked( false );
}
QCheckBox* cbInsert = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 4 ) );
if ( cbInsert )
{
cbInsert->setChecked( false );
}
QCheckBox* cbDelete = qobject_cast<QCheckBox *>( twWFSLayers->cellWidget( aIdx, 5 ) );
if ( cbDelete )
{
cbDelete->setChecked( false );
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/app/qgsprojectproperties.h
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions src/mapserver/qgswfsprojectparser.cpp
Expand Up @@ -201,7 +201,7 @@ void QgsWFSProjectParser::featureTypeList( QDomElement& parentElement, QDomDocum

QSet<QString> QgsWFSProjectParser::wfstUpdateLayers() const
{
QStringList publiedIds = mProjectParser.wfsLayers();
QSet<QString> publishedIds = wfsLayerSet();
QSet<QString> wfsList;
if ( !mProjectParser.xmlDocument() )
{
Expand All @@ -227,7 +227,7 @@ QSet<QString> 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 );
}
Expand All @@ -237,7 +237,7 @@ QSet<QString> QgsWFSProjectParser::wfstUpdateLayers() const

QSet<QString> QgsWFSProjectParser::wfstInsertLayers() const
{
QSet<QString> updateIds = wfstUpdateLayers();
QSet<QString> publishedIds = wfsLayerSet();
QSet<QString> wfsList;
if ( !mProjectParser.xmlDocument() )
{
Expand All @@ -263,7 +263,7 @@ QSet<QString> 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 );
}
Expand All @@ -273,7 +273,7 @@ QSet<QString> QgsWFSProjectParser::wfstInsertLayers() const

QSet<QString> QgsWFSProjectParser::wfstDeleteLayers() const
{
QSet<QString> insertIds = wfstInsertLayers();
QSet<QString> publishedIds = wfsLayerSet();
QSet<QString> wfsList;
if ( !mProjectParser.xmlDocument() )
{
Expand All @@ -299,7 +299,7 @@ QSet<QString> 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 );
}
Expand Down Expand Up @@ -463,6 +463,11 @@ QStringList QgsWFSProjectParser::wfsLayers() const
return mProjectParser.wfsLayers();
}

QSet<QString> QgsWFSProjectParser::wfsLayerSet() const
{
return QSet<QString>::fromList( wfsLayers() );
}

int QgsWFSProjectParser::wfsLayerPrecision( const QString& aLayerId ) const
{
QStringList wfsLayersId = mProjectParser.wfsLayers();
Expand Down
1 change: 1 addition & 0 deletions src/mapserver/qgswfsprojectparser.h
Expand Up @@ -34,6 +34,7 @@ class QgsWFSProjectParser
void describeFeatureType( const QString& aTypeName, QDomElement& parentElement, QDomDocument& doc ) const;

QStringList wfsLayers() const;
QSet<QString> wfsLayerSet() const;
int wfsLayerPrecision( const QString& aLayerId ) const;

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

0 comments on commit f58fbe0

Please sign in to comment.