More contexts for expression builder dialogs

This commit is contained in:
Nyall Dawson 2015-08-19 16:15:01 +10:00
parent a7d8519c7f
commit 1c1e574d64
8 changed files with 48 additions and 8 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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() )
{

View File

@ -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 )
{

View File

@ -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() );

View File

@ -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 )

View File

@ -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() );