Skip to content

Commit

Permalink
allow using generic vector layer (table) source type in the
Browse files Browse the repository at this point in the history
QgsProcessingParameterMapLayer (fix #56344)
  • Loading branch information
alexbruy authored and nyalldawson committed Jan 28, 2025
1 parent 99b201a commit f7c2c00
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/processing/qgsprocessingparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3294,6 +3294,10 @@ QString QgsProcessingParameterMapLayer::asScriptCode() const
{
switch ( static_cast< Qgis::ProcessingSourceType >( type ) )
{
case Qgis::ProcessingSourceType::Vector:
code += QLatin1String( "table " );
break;

case Qgis::ProcessingSourceType::VectorAnyGeometry:
code += QLatin1String( "hasgeometry " );
break;
Expand Down Expand Up @@ -3345,6 +3349,12 @@ QgsProcessingParameterMapLayer *QgsProcessingParameterMapLayer::fromScriptCode(
QString def = definition;
while ( true )
{
if ( def.startsWith( QLatin1String( "table" ), Qt::CaseInsensitive ) )
{
types << static_cast< int >( Qgis::ProcessingSourceType::Vector );
def = def.mid( 6 );
continue;
}
if ( def.startsWith( QLatin1String( "hasgeometry" ), Qt::CaseInsensitive ) )
{
types << static_cast< int >( Qgis::ProcessingSourceType::VectorAnyGeometry );
Expand Down
2 changes: 2 additions & 0 deletions src/gui/processing/qgsprocessingmaplayercombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ QgsProcessingMapLayerComboBox::QgsProcessingMapLayerComboBox( const QgsProcessin
QList<int> dataTypes;
dataTypes = static_cast<QgsProcessingParameterMapLayer *>( mParameter.get() )->dataTypes();

if ( dataTypes.contains( static_cast<int>( Qgis::ProcessingSourceType::Vector ) ) )
filters |= Qgis::LayerFilter::VectorLayer;
if ( dataTypes.contains( static_cast<int>( Qgis::ProcessingSourceType::VectorAnyGeometry ) ) )
filters |= Qgis::LayerFilter::HasGeometry;
if ( dataTypes.contains( static_cast<int>( Qgis::ProcessingSourceType::VectorPoint ) ) )
Expand Down
1 change: 1 addition & 0 deletions src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6698,6 +6698,7 @@ QgsProcessingMapLayerParameterDefinitionWidget::QgsProcessingMapLayerParameterDe
mLayerTypeComboBox->addItem( tr( "Vector (Line)" ), static_cast<int>( Qgis::ProcessingSourceType::VectorLine ) );
mLayerTypeComboBox->addItem( tr( "Vector (Polygon)" ), static_cast<int>( Qgis::ProcessingSourceType::VectorPolygon ) );
mLayerTypeComboBox->addItem( tr( "Vector (Any Geometry Type)" ), static_cast<int>( Qgis::ProcessingSourceType::VectorAnyGeometry ) );
mLayerTypeComboBox->addItem( tr( "Vector (No Geometry Required)" ), static_cast<int>( Qgis::ProcessingSourceType::Vector ) );
mLayerTypeComboBox->addItem( tr( "Raster" ), static_cast<int>( Qgis::ProcessingSourceType::Raster ) );
mLayerTypeComboBox->addItem( tr( "Mesh" ), static_cast<int>( Qgis::ProcessingSourceType::Mesh ) );
mLayerTypeComboBox->addItem( tr( "Plugin" ), static_cast<int>( Qgis::ProcessingSourceType::Plugin ) );
Expand Down

0 comments on commit f7c2c00

Please sign in to comment.