mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
[layouts] Fix attribute table filtering not utilising expression context
Fixes #21078
This commit is contained in:
parent
009ee572d8
commit
60f252c2f2
@ -411,6 +411,7 @@ bool QgsLayoutItemAttributeTable::getTableContents( QgsLayoutTableContents &cont
|
||||
{
|
||||
activeFilter = true;
|
||||
req.setFilterExpression( mFeatureFilter );
|
||||
req.setExpressionContext( context );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,30 @@ void TestQgsLayoutTable::attributeTableFilterFeatures()
|
||||
|
||||
//retrieve rows and check
|
||||
compareTable( table, expectedRows );
|
||||
|
||||
table->setFeatureFilter( QStringLiteral( "\"Class\"=@airplane_class" ) );
|
||||
table->setFilterFeatures( true );
|
||||
expectedRows.clear();
|
||||
compareTable( table, expectedRows );
|
||||
|
||||
QgsExpressionContextUtils::setLayoutVariable( &l, QStringLiteral( "airplane_class" ), QStringLiteral( "Biplane" ) );
|
||||
|
||||
row.clear();
|
||||
row << QStringLiteral( "Biplane" ) << QStringLiteral( "0" ) << QStringLiteral( "1" ) << QStringLiteral( "3" ) << QStringLiteral( "3" ) << QStringLiteral( "6" );
|
||||
expectedRows.append( row );
|
||||
row.clear();
|
||||
row << QStringLiteral( "Biplane" ) << QStringLiteral( "340" ) << QStringLiteral( "1" ) << QStringLiteral( "3" ) << QStringLiteral( "3" ) << QStringLiteral( "6" );
|
||||
expectedRows.append( row );
|
||||
row.clear();
|
||||
row << QStringLiteral( "Biplane" ) << QStringLiteral( "300" ) << QStringLiteral( "1" ) << QStringLiteral( "3" ) << QStringLiteral( "2" ) << QStringLiteral( "5" );
|
||||
expectedRows.append( row );
|
||||
row.clear();
|
||||
row << QStringLiteral( "Biplane" ) << QStringLiteral( "270" ) << QStringLiteral( "1" ) << QStringLiteral( "3" ) << QStringLiteral( "4" ) << QStringLiteral( "7" );
|
||||
expectedRows.append( row );
|
||||
row.clear();
|
||||
row << QStringLiteral( "Biplane" ) << QStringLiteral( "240" ) << QStringLiteral( "1" ) << QStringLiteral( "3" ) << QStringLiteral( "2" ) << QStringLiteral( "5" );
|
||||
expectedRows.append( row );
|
||||
compareTable( table, expectedRows );
|
||||
}
|
||||
|
||||
void TestQgsLayoutTable::attributeTableSetAttributes()
|
||||
|
Loading…
x
Reference in New Issue
Block a user