Skip to content
Permalink
Browse files

Context for the used expressions in the project properties server wms…

… online resourse
  • Loading branch information
signedav committed May 13, 2020
1 parent 062bd50 commit 8824d06dd319a994d7deed41a7ab44bddebac641
Showing with 16 additions and 3 deletions.
  1. +12 −0 src/app/qgsprojectproperties.cpp
  2. +2 −1 src/app/qgsprojectproperties.h
  3. +2 −2 src/server/qgsserverprojectutils.cpp
@@ -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 );
@@ -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() );
@@ -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

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

QgsExpressionContext createExpressionContext() const override;
public slots:

/**
@@ -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 );
}

0 comments on commit 8824d06

Please sign in to comment.
You can’t perform that action at this time.