Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. class GetLayerVisibility : public QgsScopedExpressionFunction
  3. {
  4.   public:
  5.     GetLayerVisibility( const QgsMapSettings& ms )
  6.         : QgsScopedExpressionFunction( QStringLiteral( "is_layer_visible" ), QgsExpression::ParameterList() << QgsExpression::Parameter( QStringLiteral( "id" ) ), QStringLiteral( "General" ) )
  7.         , mMapSettings( ms )
  8.     {}
  9.  
  10.     virtual QVariant func( const QVariantList& values, const QgsExpressionContext*, QgsExpression* ) override
  11.     {
  12.       QgsMapLayer* layer = _qgis_findLayer( mMapSettings.layers(), values.at( 0 ).toString() );
  13.       if ( layer )
  14.       {
  15.         return QVariant( true );
  16.       }
  17.       else
  18.       {
  19.         return QVariant( false );
  20.       }
  21.     }
  22.  
  23.     QgsScopedExpressionFunction* clone() const override
  24.     {
  25.       return new GetLayerVisibility( mMapSettings );
  26.     }
  27.  
  28.   private:
  29.  
  30.     const QgsMapSettings& mMapSettings;
  31.  
  32. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement