Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class GetLayerVisibility : public QgsScopedExpressionFunction
- {
- public:
- GetLayerVisibility( const QgsMapSettings& ms )
- : QgsScopedExpressionFunction( QStringLiteral( "is_layer_visible" ), QgsExpression::ParameterList() << QgsExpression::Parameter( QStringLiteral( "id" ) ), QStringLiteral( "General" ) )
- , mMapSettings( ms )
- {}
- virtual QVariant func( const QVariantList& values, const QgsExpressionContext*, QgsExpression* ) override
- {
- QgsMapLayer* layer = _qgis_findLayer( mMapSettings.layers(), values.at( 0 ).toString() );
- if ( layer )
- {
- return QVariant( true );
- }
- else
- {
- return QVariant( false );
- }
- }
- QgsScopedExpressionFunction* clone() const override
- {
- return new GetLayerVisibility( mMapSettings );
- }
- private:
- const QgsMapSettings& mMapSettings;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement