Skip to content

Commit

Permalink
Update vector layer variable widget on apply
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 14, 2015
1 parent 499d0da commit ddb80eb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,8 @@ void QgsVectorLayerProperties::syncToLayer( void )
}
}

mVariableEditor->context()->appendScope( QgsExpressionContextUtils::globalScope() );
mVariableEditor->context()->appendScope( QgsExpressionContextUtils::projectScope() );
mVariableEditor->context()->appendScope( QgsExpressionContextUtils::layerScope( layer ) );
mVariableEditor->reloadContext();
mVariableEditor->setEditableScopeIndex( 2 );

// set initial state for variable editor
updateVariableEditor();
} // syncToLayer()


Expand Down Expand Up @@ -626,6 +622,7 @@ void QgsVectorLayerProperties::apply()

//save variables
QgsExpressionContextUtils::setLayerVariables( layer, mVariableEditor->variablesInActiveScope() );
updateVariableEditor();

// update symbology
emit refreshLegend( layer->id() );
Expand Down Expand Up @@ -1295,3 +1292,14 @@ void QgsVectorLayerProperties::on_mSimplifyDrawingGroupBox_toggled( bool checked
mSimplifyDrawingAtProvider->setEnabled( checked );
}
}

void QgsVectorLayerProperties::updateVariableEditor()
{
QgsExpressionContext context;
mVariableEditor->setContext( &context );
mVariableEditor->context()->appendScope( QgsExpressionContextUtils::globalScope() );
mVariableEditor->context()->appendScope( QgsExpressionContextUtils::projectScope() );
mVariableEditor->context()->appendScope( QgsExpressionContextUtils::layerScope( layer ) );
mVariableEditor->reloadContext();
mVariableEditor->setEditableScopeIndex( 2 );
}
4 changes: 4 additions & 0 deletions src/app/qgsvectorlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private

void aboutToShowStyleMenu();

/** Updates the variable editor to reflect layer changes
*/
void updateVariableEditor();

protected:

void saveStyleAs( StyleType styleType );
Expand Down

0 comments on commit ddb80eb

Please sign in to comment.