Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More contexts for expression builder dialogs
  • Loading branch information
nyalldawson committed Aug 22, 2015
1 parent a7d8519 commit 1c1e574
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/app/qgsattributeactiondialog.cpp
Expand Up @@ -181,7 +181,12 @@ void QgsAttributeActionDialog::insertExpression()
selText = selText.mid( 2, selText.size() - 4 );

// display the expression builder
QgsExpressionBuilderDialog dlg( mActions->layer(), selText, this );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mActions->layer() );

QgsExpressionBuilderDialog dlg( mActions->layer(), selText, this, "generic", context );
dlg.setWindowTitle( tr( "Insert expression" ) );

QgsDistanceArea myDa;
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgsattributetabledialog.cpp
Expand Up @@ -460,7 +460,12 @@ void QgsAttributeTableDialog::filterColumnChanged( QObject* filterAction )
void QgsAttributeTableDialog::filterExpressionBuilder()
{
// Show expression builder
QgsExpressionBuilderDialog dlg( mLayer, mFilterQuery->text(), this );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );

QgsExpressionBuilderDialog dlg( mLayer, mFilterQuery->text(), this, "generic", context );
dlg.setWindowTitle( tr( "Expression based filter" ) );

QgsDistanceArea myDa;
Expand Down
8 changes: 7 additions & 1 deletion src/app/qgsdiagramproperties.cpp
Expand Up @@ -776,7 +776,13 @@ void QgsDiagramProperties::showAddAttributeExpressionDialog()
{
expression = selections[0]->text( 0 );
}
QgsExpressionBuilderDialog dlg( mLayer, expression, this );

QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );

QgsExpressionBuilderDialog dlg( mLayer, expression, this, "generic", context );
dlg.setWindowTitle( tr( "Expression based attribute" ) );

QgsDistanceArea myDa;
Expand Down
6 changes: 5 additions & 1 deletion src/app/qgsfieldsproperties.cpp
Expand Up @@ -669,7 +669,11 @@ void QgsFieldsProperties::updateExpression()

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

QgsExpressionBuilderDialog dlg( mLayer, exp );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope();

QgsExpressionBuilderDialog dlg( mLayer, exp, 0, "generic", context );

if ( dlg.exec() )
{
Expand Down
7 changes: 6 additions & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -345,7 +345,12 @@ void QgsVectorLayerProperties::insertExpression()
selText = selText.mid( 2, selText.size() - 4 );

// display the expression builder
QgsExpressionBuilderDialog dlg( layer, selText.replace( QChar::ParagraphSeparator, '\n' ), this );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( layer );

QgsExpressionBuilderDialog dlg( layer, selText.replace( QChar::ParagraphSeparator, '\n' ), this, "generic", context );
dlg.setWindowTitle( tr( "Insert expression" ) );
if ( dlg.exec() == QDialog::Accepted )
{
Expand Down
7 changes: 6 additions & 1 deletion src/gui/attributetable/qgsdualview.cpp
Expand Up @@ -291,7 +291,12 @@ void QgsDualView::openConditionalStyles()
void QgsDualView::previewExpressionBuilder()
{
// Show expression builder
QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayerCache->layer() );

QgsExpressionBuilderDialog dlg( mLayerCache->layer(), mFeatureList->displayExpression(), this, "generic", context );
dlg.setWindowTitle( tr( "Expression based preview" ) );
dlg.setExpressionText( mFeatureList->displayExpression() );

Expand Down
7 changes: 6 additions & 1 deletion src/gui/editorwidgets/qgsvaluerelationconfigdlg.cpp
Expand Up @@ -63,7 +63,12 @@ void QgsValueRelationConfigDlg::editExpression()
if ( !vl )
return;

QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( vl );

QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this, "generic", context );
dlg.setWindowTitle( tr( "Edit filter expression" ) );

if ( dlg.exec() == QDialog::Accepted )
Expand Down
7 changes: 6 additions & 1 deletion src/gui/symbology-ng/qgsrulebasedrendererv2widget.cpp
Expand Up @@ -627,7 +627,12 @@ QgsRendererRulePropsDialog::~QgsRendererRulePropsDialog()

void QgsRendererRulePropsDialog::buildExpression()
{
QgsExpressionBuilderDialog dlg( mLayer, editFilter->text(), this );
QgsExpressionContext context;
context << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope()
<< QgsExpressionContextUtils::layerScope( mLayer );

QgsExpressionBuilderDialog dlg( mLayer, editFilter->text(), this, "generic", context );

if ( dlg.exec() )
editFilter->setText( dlg.expressionText() );
Expand Down

0 comments on commit 1c1e574

Please sign in to comment.