37 if ( !input.isValid() )
40 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( input ) ) )
45 if ( input.type() == QVariant::String )
47 if ( input.toString().isEmpty() )
56 else if ( input.type() == QVariant::List )
58 if ( input.toList().isEmpty() )
61 const QVariantList layerList = input.toList();
62 for (
const QVariant &variantLayer : layerList )
64 if ( qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( variantLayer ) ) )
67 if ( variantLayer.type() == QVariant::String )
76 else if ( variantLayer.type() == QVariant::Map )
78 const QVariantMap layerMap = variantLayer.toMap();
80 if ( !layerMap.contains( QStringLiteral(
"layer" ) ) && !layerMap.contains( QStringLiteral(
"attributeIndex" ) ) )
95 if ( layerMap.value( QStringLiteral(
"attributeIndex" ) ).toInt() >= vectorLayer->
fields().
count() )
105 else if ( input.type() == QVariant::StringList )
107 const auto constToStringList = input.toStringList();
108 if ( constToStringList.isEmpty() )
114 for (
const QString &v : constToStringList )
128 const QList<QgsDxfExport::DxfLayer> layers =
parameterAsLayers( value, context );
131 QStringList layerDefParts;
133 if ( layer.layerOutputAttributeIndex() >= -1 )
136 const QString layerDef = QStringLiteral(
"{%1}" ).arg( layerDefParts.join(
',' ) );
139 return parts.join(
',' ).prepend(
'[' ).append(
']' );
144 switch ( outputType )
148 QString code = QStringLiteral(
"QgsProcessingParameterDxfLayers('%1', %2)" )
158 QList<QgsDxfExport::DxfLayer> layers;
160 if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( layersVariant ) ) )
165 if ( layersVariant.type() == QVariant::String )
168 layers << QgsDxfExport::DxfLayer( static_cast<QgsVectorLayer *>( mapLayer ) );
170 else if ( layersVariant.type() == QVariant::List )
172 const QVariantList layersVariantList = layersVariant.toList();
173 for (
const QVariant &layerItem : layersVariantList )
175 if ( layerItem.type() == QVariant::Map )
177 const QVariantMap layerVariantMap = layerItem.toMap();
180 else if ( layerItem.type() == QVariant::String )
183 layers << QgsDxfExport::DxfLayer( static_cast<QgsVectorLayer *>( mapLayer ) );
187 else if ( layersVariant.type() == QVariant::StringList )
189 const auto layersStringList = layersVariant.toStringList();
190 for (
const QString &layerItem : layersStringList )
193 layers << QgsDxfExport::DxfLayer( static_cast<QgsVectorLayer *>( mapLayer ) );
202 const QVariant layerVariant = layerVariantMap[ QStringLiteral(
"layer" ) ];
205 if ( ( inputLayer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( layerVariant ) ) ) )
218 QgsDxfExport::DxfLayer dxfLayer( inputLayer, layerVariantMap[ QStringLiteral(
"attributeIndex" ) ].toInt() );
225 if ( !layer.
layer() )
228 vm[ QStringLiteral(
"layer" )] = layer.
layer()->
id();