|
17 | 17 | #include "moc_qgsextentbufferdialog.cpp"
|
18 | 18 | #include "qdialogbuttonbox.h"
|
19 | 19 | #include "qgsexpressioncontext.h"
|
| 20 | +#include "qgsexpressioncontextutils.h" |
20 | 21 | #include "qgshelp.h"
|
| 22 | +#include "qgsmapcanvas.h" |
21 | 23 | #include "qgspanelwidget.h"
|
| 24 | +#include "qgsproject.h" |
22 | 25 | #include "qgssymbol.h"
|
23 | 26 | #include "qgssymbolwidgetcontext.h"
|
24 | 27 | #include "qgsunittypes.h"
|
@@ -78,8 +81,28 @@ void QgsExtentBufferWidget::registerDataDefinedButton( QgsPropertyOverrideButton
|
78 | 81 |
|
79 | 82 | QgsExpressionContext QgsExtentBufferWidget::createExpressionContext() const
|
80 | 83 | {
|
81 |
| - QList<QgsExpressionContextScope *> scopes = mContext.globalProjectAtlasMapLayerScopes( mLayer ); |
82 |
| - QgsExpressionContext expContext( scopes ); |
| 84 | + if ( QgsExpressionContext *lExpressionContext = mContext.expressionContext() ) |
| 85 | + return *lExpressionContext; |
| 86 | + |
| 87 | + QgsExpressionContext expContext; |
| 88 | + |
| 89 | + if ( mContext.mapCanvas() ) |
| 90 | + { |
| 91 | + expContext = mContext.mapCanvas()->createExpressionContext(); |
| 92 | + } |
| 93 | + else |
| 94 | + { |
| 95 | + expContext << QgsExpressionContextUtils::globalScope() |
| 96 | + << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) |
| 97 | + << QgsExpressionContextUtils::atlasScope( nullptr ) |
| 98 | + << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); |
| 99 | + } |
| 100 | + |
| 101 | + if ( mLayer ) |
| 102 | + expContext << QgsExpressionContextUtils::layerScope( mLayer ); |
| 103 | + |
| 104 | + expContext.setOriginalValueVariable( mExtentBufferSpinBox->value() ); |
| 105 | + expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE ); |
83 | 106 |
|
84 | 107 | return expContext;
|
85 | 108 | }
|
@@ -149,6 +172,12 @@ QgsExtentBufferWidget *QgsExtentBufferDialog::widget() const
|
149 | 172 | return mWidget;
|
150 | 173 | }
|
151 | 174 |
|
| 175 | +void QgsExtentBufferDialog::setContext( const QgsSymbolWidgetContext &context ) |
| 176 | +{ |
| 177 | + mWidget->setContext( context ); |
| 178 | +} |
| 179 | + |
| 180 | + |
152 | 181 | void QgsExtentBufferDialog::showHelp()
|
153 | 182 | {
|
154 | 183 | QgsHelp::openHelp( QStringLiteral( "working_with_vector/vector_properties.html#extent-buffer" ) );
|
|
0 commit comments