Example #1
0
QString QgsProcessingAlgorithm::invalidSinkError( const QVariantMap &parameters, const QString &name )
{
  if ( !parameters.contains( name ) )
    return QObject::tr( "Could not create destination layer for %1: no value specified for parameter" ).arg( name );
  else
  {
    QVariant var = parameters.value( name );
    if ( var.canConvert<QgsProcessingOutputLayerDefinition>() )
    {
      QgsProcessingOutputLayerDefinition fromVar = qvariant_cast<QgsProcessingOutputLayerDefinition>( var );
      var = fromVar.sink;
    }
    if ( var.canConvert<QgsProperty>() )
    {
      QgsProperty p = var.value< QgsProperty >();
      if ( p.propertyType() == QgsProperty::StaticProperty )
      {
        var = p.staticValue();
      }
    }
    if ( !var.toString().isEmpty() )
      return QObject::tr( "Could not create destination layer for %1: %2" ).arg( name, var.toString() );
    else
      return QObject::tr( "Could not create destination layer for %1: invalid value" ).arg( name );
  }
}
Example #2
0
QString QgsProcessingAlgorithm::invalidRasterError( const QVariantMap &parameters, const QString &name )
{
  if ( !parameters.contains( name ) )
    return QObject::tr( "Could not load source layer for %1: no value specified for parameter" ).arg( name );
  else
  {
    QVariant var = parameters.value( name );
    if ( var.canConvert<QgsProperty>() )
    {
      QgsProperty p = var.value< QgsProperty >();
      if ( p.propertyType() == QgsProperty::StaticProperty )
      {
        var = p.staticValue();
      }
    }
    if ( !var.toString().isEmpty() )
      return QObject::tr( "Could not load source layer for %1: %2 not found" ).arg( name, var.toString() );
    else
      return QObject::tr( "Could not load source layer for %1: invalid value" ).arg( name );
  }
}