Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Support elements KeywordList, Fees, AccesConstraints in QGIS server c…
…apabilities
  • Loading branch information
mhugent committed Oct 26, 2012
1 parent 4ed1a66 commit ea6802e
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 71 deletions.
124 changes: 65 additions & 59 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -223,6 +223,9 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
mWMSAbstract->setPlainText( QgsProject::instance()->readEntry( "WMSServiceAbstract", "/", "" ) );
mWMSOnlineResourceLineEdit->setText( QgsProject::instance()->readEntry( "WMSOnlineResource", "/", "" ) );
mWMSUrlLineEdit->setText( QgsProject::instance()->readEntry( "WMSUrl", "/", "" ) );
mWMSFees->setText( QgsProject::instance()->readEntry( "WMSFees", "/", "" ) );
mWMSAccessConstraints->setText( QgsProject::instance()->readEntry( "WMSAccessConstraints", "/", "" ) );
mWMSKeywordList->setText( QgsProject::instance()->readListEntry( "WMSKeywordList", "/" ).join( "," ) );

bool ok;
QStringList values;
Expand Down Expand Up @@ -304,14 +307,14 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
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)));
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 );
Expand All @@ -337,37 +340,37 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
cbp->setChecked( wfsLayerIdList.contains( currentLayer->id() ) );
twWFSLayers->setCellWidget( j, 1, cbp );

smPublied->setMapping(cbp, j);
connect(cbp, SIGNAL(stateChanged(int)), smPublied, SLOT(map()));
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 ) )
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()));
smUpdate->setMapping( cbu, j );
connect( cbu, SIGNAL( stateChanged( int ) ), smUpdate, SLOT( map() ) );
}
if ( ( provider->capabilities() & QgsVectorDataProvider::AddFeatures ) )
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()));
smInsert->setMapping( cbi, j );
connect( cbi, SIGNAL( stateChanged( int ) ), smInsert, SLOT( map() ) );
}
if ( ( provider->capabilities() & QgsVectorDataProvider::DeleteFeatures ) )
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()));
smDelete->setMapping( cbd, j );
connect( cbd, SIGNAL( stateChanged( int ) ), smDelete, SLOT( map() ) );
}

j++;
Expand Down Expand Up @@ -567,6 +570,9 @@ void QgsProjectProperties::apply()
QgsProject::instance()->writeEntry( "WMSServiceAbstract", "/", mWMSAbstract->toPlainText() );
QgsProject::instance()->writeEntry( "WMSOnlineResource", "/", mWMSOnlineResourceLineEdit->text() );
QgsProject::instance()->writeEntry( "WMSUrl", "/", mWMSUrlLineEdit->text() );
QgsProject::instance()->writeEntry( "WMSFees", "/", mWMSFees->text() );
QgsProject::instance()->writeEntry( "WMSAccessConstraints", "/", mWMSAccessConstraints->text() );
QgsProject::instance()->writeEntry( "WMSKeywordList", "/", mWMSKeywordList->text().split( "," ) );

if ( grpWMSExt->isChecked() )
{
Expand Down Expand Up @@ -762,58 +768,58 @@ 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);
}
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);
}
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);
}
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);
}
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()
Expand Down
40 changes: 40 additions & 0 deletions src/mapserver/qgsprojectparser.cpp
Expand Up @@ -1719,6 +1719,26 @@ void QgsProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocu
serviceElem.appendChild( wmsAbstractElem );
}

//keyword list
QDomElement keywordListElem = propertiesElem.firstChildElement( "WMSKeywordList" );
if ( !keywordListElem.isNull() )
{
QDomElement wmsKeywordElem = doc.createElement( "KeywordList" );
QDomNodeList keywordList = keywordListElem.elementsByTagName( "value" );
for ( int i = 0; i < keywordList.size(); ++i )
{
QDomElement keywordElem = doc.createElement( "Keyword" );
QDomText keywordText = doc.createTextNode( keywordList.at( i ).toElement().text() );
keywordElem.appendChild( keywordText );
wmsKeywordElem.appendChild( keywordElem );
}

if ( keywordList.size() > 0 )
{
serviceElem.appendChild( wmsKeywordElem );
}
}

//OnlineResource element is mandatory according to the WMS specification
QDomElement wmsOnlineResourceElem = propertiesElem.firstChildElement( "WMSOnlineResource" );
QDomElement onlineResourceElem = doc.createElement( "OnlineResource" );
Expand Down Expand Up @@ -1785,6 +1805,26 @@ void QgsProjectParser::serviceCapabilities( QDomElement& parentElement, QDomDocu

serviceElem.appendChild( contactInfoElem );

//Fees
QDomElement feesElem = propertiesElem.firstChildElement( "WMSFees" );
if ( !feesElem.isNull() )
{
QDomElement wmsFeesElem = doc.createElement( "Fees" );
QDomText wmsFeesText = doc.createTextNode( feesElem.text() );
wmsFeesElem.appendChild( wmsFeesText );
serviceElem.appendChild( wmsFeesElem );
}

//AccessConstraints
QDomElement accessConstraintsElem = propertiesElem.firstChildElement( "WMSAccessConstraints" );
if ( !accessConstraintsElem.isNull() )
{
QDomElement wmsAccessConstraintsElem = doc.createElement( "AccessConstraints" );
QDomText wmsAccessConstraintsText = doc.createTextNode( accessConstraintsElem.text() );
wmsAccessConstraintsElem.appendChild( wmsAccessConstraintsText );
serviceElem.appendChild( wmsAccessConstraintsElem );
}

//MaxWidth / MaxHeight for WMS 1.3
QString version = doc.documentElement().attribute( "version" );
if ( version != "1.1.1" )
Expand Down
54 changes: 42 additions & 12 deletions src/ui/qgsprojectpropertiesbase.ui
Expand Up @@ -51,7 +51,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>489</height>
<height>497</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_13">
Expand Down Expand Up @@ -799,7 +799,7 @@
<x>0</x>
<y>0</y>
<width>600</width>
<height>984</height>
<height>1085</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
Expand All @@ -815,6 +815,16 @@
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_6">
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Person</string>
</property>
<property name="buddy">
<cstring>mWMSContactPerson</cstring>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
Expand Down Expand Up @@ -851,16 +861,6 @@
<item row="2" column="1">
<widget class="QLineEdit" name="mWMSOnlineResourceLineEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Person</string>
</property>
<property name="buddy">
<cstring>mWMSContactPerson</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="mWMSContactPerson"/>
</item>
Expand Down Expand Up @@ -900,6 +900,36 @@
<item row="6" column="1">
<widget class="QTextEdit" name="mWMSAbstract"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="mWMSFees"/>
</item>
<item row="7" column="0">
<widget class="QLabel" name="mWMSFeesLabel">
<property name="text">
<string>Fees</string>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLineEdit" name="mWMSAccessConstraints"/>
</item>
<item row="8" column="0">
<widget class="QLabel" name="mWMSAccessConstraintsLabel">
<property name="text">
<string>Access constraints</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLineEdit" name="mWMSKeywordList"/>
</item>
<item row="9" column="0">
<widget class="QLabel" name="mWMSKeywordListLabel">
<property name="text">
<string>Keyword list</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit ea6802e

Please sign in to comment.