Skip to content
Permalink
Browse files
Add QgsIconUtils::iconForLayerType
  • Loading branch information
nyalldawson committed Jul 1, 2021
1 parent 4dc659c commit a51a9c4854f83056302c971720475d97565dbd39
Showing with 43 additions and 17 deletions.
  1. +7 −0 python/core/auto_generated/qgsiconutils.sip.in
  2. +29 −17 src/core/qgsiconutils.cpp
  3. +7 −0 src/core/qgsiconutils.h
@@ -75,6 +75,13 @@ Returns an icon representing point cloud layers.
static QIcon iconForLayer( const QgsMapLayer *layer );
%Docstring
Returns the icon corresponding to a specified map ``layer``.
%End

static QIcon iconForLayerType( QgsMapLayerType type );
%Docstring
Returns the default icon for the specified layer ``type``.

.. versionadded:: 3.22
%End

};
@@ -91,23 +91,13 @@ QIcon QgsIconUtils::iconForLayer( const QgsMapLayer *layer )
switch ( layer->type() )
{
case QgsMapLayerType::RasterLayer:
{
return QgsIconUtils::iconRaster();
}

case QgsMapLayerType::MeshLayer:
{
return QgsIconUtils::iconMesh();
}

case QgsMapLayerType::VectorTileLayer:
{
return QgsIconUtils::iconVectorTile();
}

case QgsMapLayerType::PointCloudLayer:
case QgsMapLayerType::PluginLayer:
case QgsMapLayerType::AnnotationLayer:
{
return QgsIconUtils::iconPointCloud();
return QgsIconUtils::iconForLayerType( layer->type() );
}

case QgsMapLayerType::VectorLayer:
@@ -142,11 +132,33 @@ QIcon QgsIconUtils::iconForLayer( const QgsMapLayer *layer )
}
}
}
}
return QIcon();
}

default:
{
return QIcon();
}
QIcon QgsIconUtils::iconForLayerType( QgsMapLayerType type )
{
switch ( type )
{
case QgsMapLayerType::RasterLayer:
return QgsIconUtils::iconRaster();

case QgsMapLayerType::MeshLayer:
return QgsIconUtils::iconMesh();

case QgsMapLayerType::VectorTileLayer:
return QgsIconUtils::iconVectorTile();

case QgsMapLayerType::PointCloudLayer:
return QgsIconUtils::iconPointCloud();

case QgsMapLayerType::VectorLayer:
return QgsIconUtils::iconPolygon();

case QgsMapLayerType::PluginLayer:
case QgsMapLayerType::AnnotationLayer:
break;
}
return QIcon();
}

@@ -90,6 +90,13 @@ class CORE_EXPORT QgsIconUtils
*/
static QIcon iconForLayer( const QgsMapLayer *layer );

/**
* Returns the default icon for the specified layer \a type.
*
* \since QGIS 3.22
*/
static QIcon iconForLayerType( QgsMapLayerType type );

};

#endif // QGSICONUTILS_H

0 comments on commit a51a9c4

Please sign in to comment.