Skip to content
Permalink
Browse files

Tweak context for composer items

- Attribute tables have access to layer context when applicable
- Frames have access to parent multiframe's context
  • Loading branch information
nyalldawson committed Aug 22, 2015
1 parent be26c61 commit 00892ce06869827c73998ce95cb174b3d21042c9
@@ -583,6 +583,18 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co
return true;
}

QgsExpressionContext *QgsComposerAttributeTableV2::createExpressionContext() const
{
QgsExpressionContext* context = QgsComposerTableV2::createExpressionContext();

if ( mSource == LayerAttributes )
{
context->appendScope( QgsExpressionContextUtils::layerScope( mVectorLayer ) );
}

return context;
}

QVariant QgsComposerAttributeTableV2::replaceWrapChar( const QVariant &variant ) const
{
//avoid converting variants to string if not required (try to maintain original type for sorting)
@@ -293,6 +293,8 @@ class CORE_EXPORT QgsComposerAttributeTableV2: public QgsComposerTableV2
*/
bool getTableContents( QgsComposerTableContents &contents ) override;

virtual QgsExpressionContext* createExpressionContext() const override;

private:

/** Attribute source*/
@@ -115,6 +115,19 @@ bool QgsComposerFrame::isEmpty() const

}

QgsExpressionContext *QgsComposerFrame::createExpressionContext() const
{
if ( !mMultiFrame )
return QgsComposerItem::createExpressionContext();

//start with multiframe's context
QgsExpressionContext* context = mMultiFrame->createExpressionContext();
//add frame's individual context
context->appendScope( QgsExpressionContextUtils::composerItemScope( this ) );

return context;
}

QString QgsComposerFrame::displayName() const
{
if ( !id().isEmpty() )
@@ -100,6 +100,8 @@ class CORE_EXPORT QgsComposerFrame: public QgsComposerItem
*/
bool isEmpty() const;

virtual QgsExpressionContext* createExpressionContext() const override;

private:
QgsComposerFrame(); //forbidden
QgsComposerMultiFrame* mMultiFrame;

0 comments on commit 00892ce

Please sign in to comment.
You can’t perform that action at this time.