Skip to content
Permalink
Browse files

more fixes to support other input types

  • Loading branch information
alexbruy committed Nov 2, 2020
1 parent 6f10e65 commit e5e87aca41abfb140f0eb2427875346ee7bf3763
@@ -155,12 +155,44 @@ QString QgsProcessingParameterDxfLayers::asPythonString( QgsProcessing::PythonOu
QList<QgsDxfExport::DxfLayer> QgsProcessingParameterDxfLayers::parameterAsLayers( const QVariant &layersVariant, QgsProcessingContext &context )
{
QList<QgsDxfExport::DxfLayer> layers;
const QVariantList layersVariantList = layersVariant.toList();
for ( const QVariant &layerItem : layersVariantList )

if ( QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( layersVariant ) ) )
{
QVariantMap layerVariantMap = layerItem.toMap();
layers << variantMapAsLayer( layerVariantMap, context );
layers << QgsDxfExport::DxfLayer( layer );
}

if ( layersVariant.type() == QVariant::String )
{
QgsMapLayer *mapLayer = QgsProcessingUtils::mapLayerFromString( layersVariant.toString(), context );
layers << QgsDxfExport::DxfLayer( static_cast<QgsVectorLayer *>( mapLayer ) );
}
else if ( layersVariant.type() == QVariant::List )
{
const QVariantList layersVariantList = layersVariant.toList();
for ( const QVariant &layerItem : layersVariantList )
{
if ( layerItem.type() == QVariant::Map )
{
QVariantMap layerVariantMap = layerItem.toMap();
layers << variantMapAsLayer( layerVariantMap, context );
}
else if ( layerItem.type() == QVariant::String )
{
QgsMapLayer *mapLayer = QgsProcessingUtils::mapLayerFromString( layerItem.toString(), context );
layers << QgsDxfExport::DxfLayer( static_cast<QgsVectorLayer *>( mapLayer ) );
}
}
}
else if ( layersVariant.type() == QVariant::StringList )
{
const auto layersStringList = layersVariant.toStringList();
for ( const QString &layerItem : layersStringList )
{
QgsMapLayer *mapLayer = QgsProcessingUtils::mapLayerFromString( layerItem, context );
layers << QgsDxfExport::DxfLayer( static_cast<QgsVectorLayer *>( mapLayer ) );
}
}

return layers;
}

@@ -24,6 +24,8 @@

#include "qgspanelwidget.h"
#include "qgsprocessingcontext.h"
#include "qgsprocessingparameters.h"
#include "qgsprocessingoutputs.h"
#include "qgsprocessingparameterdxflayers.h"

/// @cond private
@@ -308,12 +310,23 @@ QVariant QgsProcessingDxfLayersWidgetWrapper::widgetValue() const

QStringList QgsProcessingDxfLayersWidgetWrapper::compatibleParameterTypes() const
{
return QStringList();
return QStringList()
<< QgsProcessingParameterMultipleLayers::typeName()
<< QgsProcessingParameterMapLayer::typeName()
<< QgsProcessingParameterVectorLayer::typeName()
<< QgsProcessingParameterFeatureSource::typeName()
<< QgsProcessingParameterFile::typeName()
<< QgsProcessingParameterString::typeName();
}

QStringList QgsProcessingDxfLayersWidgetWrapper::compatibleOutputTypes() const
{
return QStringList();
return QStringList()
<< QgsProcessingOutputString::typeName()
<< QgsProcessingOutputMapLayer::typeName()
<< QgsProcessingOutputVectorLayer::typeName()
<< QgsProcessingOutputMultipleLayers::typeName()
<< QgsProcessingOutputFile::typeName();
}

/// @endcond

0 comments on commit e5e87ac

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