Skip to content

Commit

Permalink
Context for the used expressions in the project properties server wms…
Browse files Browse the repository at this point in the history
… online resourse
  • Loading branch information
signedav committed May 13, 2020
1 parent 062bd50 commit 8824d06
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/app/qgsprojectproperties.cpp
Expand Up @@ -446,6 +446,8 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas *mapCanvas, QWidget *pa
mWMSUrlLineEdit->setText( QgsProject::instance()->readEntry( QStringLiteral( "WMSUrl" ), QStringLiteral( "/" ), QString() ) );
mWMSKeywordList->setText( QgsProject::instance()->readListEntry( QStringLiteral( "WMSKeywordList" ), QStringLiteral( "/" ) ).join( QStringLiteral( ", " ) ) );

mWMSOnlineResourceExpressionButton->registerExpressionContextGenerator( this );

// WMS Name validator
QValidator *shortNameValidator = new QRegExpValidator( QgsApplication::shortNameRegExp(), this );
mWMSName->setValidator( shortNameValidator );
Expand Down Expand Up @@ -995,6 +997,16 @@ void QgsProjectProperties::setSelectedCrs( const QgsCoordinateReferenceSystem &c
crsChanged( projectionSelector->crs() );
}

QgsExpressionContext QgsProjectProperties::createExpressionContext() const
{
QgsExpressionContext context;
context
<< QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope( QgsProject::instance() );

return context;
}

void QgsProjectProperties::apply()
{
mMapCanvas->enableMapTileRendering( mMapTileRenderingCheckBox->isChecked() );
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsprojectproperties.h
Expand Up @@ -42,7 +42,7 @@ class QgsBearingNumericFormat;
\note actual state is stored in QgsProject singleton instance
*/
class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui::QgsProjectPropertiesBase
class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui::QgsProjectPropertiesBase, public QgsExpressionContextGenerator
{
Q_OBJECT

Expand All @@ -65,6 +65,7 @@ class APP_EXPORT QgsProjectProperties : public QgsOptionsDialogBase, private Ui:
*/
void setSelectedCrs( const QgsCoordinateReferenceSystem &crs );

QgsExpressionContext createExpressionContext() const override;
public slots:

/**
Expand Down
4 changes: 2 additions & 2 deletions src/server/qgsserverprojectutils.cpp
Expand Up @@ -67,10 +67,10 @@ QString QgsServerProjectUtils::owsServiceOnlineResource( const QgsProject &proje
{
QString wmsOnlineResource = project.readEntry( QStringLiteral( "WMSOnlineResource" ), QStringLiteral( "/" ) );

QgsProperty wmsOnlineResourceExpression = project.readPropertyEntry( QStringLiteral( "WMSOnlineResource" ), QStringLiteral( "/" ) );
QgsProperty wmsOnlineResourceExpression = project.readPropertyEntry( QStringLiteral( "WMSOnlineResourceExpression" ), QStringLiteral( "/" ) );
if ( wmsOnlineResourceExpression.isActive() && ! wmsOnlineResourceExpression.expressionString().isEmpty() )
{
QgsExpressionContext context;
QgsExpressionContext context = project.createExpressionContext();
return wmsOnlineResourceExpression.valueAsString( context, wmsOnlineResource );
}

Expand Down

0 comments on commit 8824d06

Please sign in to comment.