Skip to content

Commit 1c1e574

Browse files
committedAug 22, 2015
More contexts for expression builder dialogs
1 parent a7d8519 commit 1c1e574

File tree

8 files changed

+48
-8
lines changed

8 files changed

+48
-8
lines changed
 

‎src/app/qgsattributeactiondialog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,12 @@ void QgsAttributeActionDialog::insertExpression()
181181
selText = selText.mid( 2, selText.size() - 4 );
182182

183183
// display the expression builder
184-
QgsExpressionBuilderDialog dlg( mActions->layer(), selText, this );
184+
QgsExpressionContext context;
185+
context << QgsExpressionContextUtils::globalScope()
186+
<< QgsExpressionContextUtils::projectScope()
187+
<< QgsExpressionContextUtils::layerScope( mActions->layer() );
188+
189+
QgsExpressionBuilderDialog dlg( mActions->layer(), selText, this, "generic", context );
185190
dlg.setWindowTitle( tr( "Insert expression" ) );
186191

187192
QgsDistanceArea myDa;

‎src/app/qgsattributetabledialog.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,12 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
460460
void QgsAttributeTableDialog::filterExpressionBuilder()
461461
{
462462
// Show expression builder
463-
QgsExpressionBuilderDialog dlg( mLayer, mFilterQuery->text(), this );
463+
QgsExpressionContext context;
464+
context << QgsExpressionContextUtils::globalScope()
465+
<< QgsExpressionContextUtils::projectScope()
466+
<< QgsExpressionContextUtils::layerScope( mLayer );
467+
468+
QgsExpressionBuilderDialog dlg( mLayer, mFilterQuery->text(), this, "generic", context );
464469
dlg.setWindowTitle( tr( "Expression based filter" ) );
465470

466471
QgsDistanceArea myDa;

‎src/app/qgsdiagramproperties.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,13 @@ void QgsDiagramProperties::showAddAttributeExpressionDialog()
776776
{
777777
expression = selections[0]->text( 0 );
778778
}
779-
QgsExpressionBuilderDialog dlg( mLayer, expression, this );
779+
780+
QgsExpressionContext context;
781+
context << QgsExpressionContextUtils::globalScope()
782+
<< QgsExpressionContextUtils::projectScope()
783+
<< QgsExpressionContextUtils::layerScope( mLayer );
784+
785+
QgsExpressionBuilderDialog dlg( mLayer, expression, this, "generic", context );
780786
dlg.setWindowTitle( tr( "Expression based attribute" ) );
781787

782788
QgsDistanceArea myDa;

‎src/app/qgsfieldsproperties.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,11 @@ void QgsFieldsProperties::updateExpression()
669669

670670
const QString exp = mLayer->expressionField( index );
671671

672-
QgsExpressionBuilderDialog dlg( mLayer, exp );
672+
QgsExpressionContext context;
673+
context << QgsExpressionContextUtils::globalScope()
674+
<< QgsExpressionContextUtils::projectScope();
675+
676+
QgsExpressionBuilderDialog dlg( mLayer, exp, 0, "generic", context );
673677

674678
if ( dlg.exec() )
675679
{

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ void QgsVectorLayerProperties::insertExpression()
345345
selText = selText.mid( 2, selText.size() - 4 );
346346

347347
// display the expression builder
348-
QgsExpressionBuilderDialog dlg( layer, selText.replace( QChar::ParagraphSeparator, '\n' ), this );
348+
QgsExpressionContext context;
349+
context << QgsExpressionContextUtils::globalScope()
350+
<< QgsExpressionContextUtils::projectScope()
351+
<< QgsExpressionContextUtils::layerScope( layer );
352+
353+
QgsExpressionBuilderDialog dlg( layer, selText.replace( QChar::ParagraphSeparator, '\n' ), this, "generic", context );
349354
dlg.setWindowTitle( tr( "Insert expression" ) );
350355
if ( dlg.exec() == QDialog::Accepted )
351356
{

‎src/gui/attributetable/qgsdualview.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,12 @@ void QgsDualView::openConditionalStyles()
291291
void QgsDualView::previewExpressionBuilder()
292292
{
293293
// Show expression builder
294-
QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this );
294+
QgsExpressionContext context;
295+
context << QgsExpressionContextUtils::globalScope()
296+
<< QgsExpressionContextUtils::projectScope()
297+
<< QgsExpressionContextUtils::layerScope( mLayerCache->layer() );
298+
299+
QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this, "generic", context );
295300
dlg.setWindowTitle( tr( "Expression based preview" ) );
296301
dlg.setExpressionText( mFeatureList->displayExpression() );
297302

‎src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,12 @@ void QgsValueRelationConfigDlg::editExpression()
6363
if ( !vl )
6464
return;
6565

66-
QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this );
66+
QgsExpressionContext context;
67+
context << QgsExpressionContextUtils::globalScope()
68+
<< QgsExpressionContextUtils::projectScope()
69+
<< QgsExpressionContextUtils::layerScope( vl );
70+
71+
QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this, "generic", context );
6772
dlg.setWindowTitle( tr( "Edit filter expression" ) );
6873

6974
if ( dlg.exec() == QDialog::Accepted )

‎src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,12 @@ QgsRendererRulePropsDialog::~QgsRendererRulePropsDialog()
627627

628628
void QgsRendererRulePropsDialog::buildExpression()
629629
{
630-
QgsExpressionBuilderDialog dlg( mLayer, editFilter->text(), this );
630+
QgsExpressionContext context;
631+
context << QgsExpressionContextUtils::globalScope()
632+
<< QgsExpressionContextUtils::projectScope()
633+
<< QgsExpressionContextUtils::layerScope( mLayer );
634+
635+
QgsExpressionBuilderDialog dlg( mLayer, editFilter->text(), this, "generic", context );
631636

632637
if ( dlg.exec() )
633638
editFilter->setText( dlg.expressionText() );

0 commit comments

Comments
 (0)
Please sign in to comment.