mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Added static QgsLayerItem::iconName(LayerType) for reuse and consistency
This commit is contained in:
parent
51abef4d37
commit
31b51178b8
@ -414,7 +414,14 @@ Returns provider key
|
||||
|
||||
static QString layerTypeAsString( const LayerType &layerType );
|
||||
%Docstring
|
||||
Returns the string representatio of the given ``layerType``
|
||||
Returns the string representation of the given ``layerType``
|
||||
.. versionadded:: 3
|
||||
:rtype: str
|
||||
%End
|
||||
|
||||
static QString iconName( const LayerType &layerType );
|
||||
%Docstring
|
||||
Returns the icon name of the given ``layerType``
|
||||
.. versionadded:: 3
|
||||
:rtype: str
|
||||
%End
|
||||
|
@ -546,31 +546,7 @@ QgsLayerItem::QgsLayerItem( QgsDataItem *parent, const QString &name, const QStr
|
||||
, mUri( uri )
|
||||
, mLayerType( layerType )
|
||||
{
|
||||
switch ( layerType )
|
||||
{
|
||||
case Point:
|
||||
mIconName = QStringLiteral( "/mIconPointLayer.svg" );
|
||||
break;
|
||||
case Line:
|
||||
mIconName = QStringLiteral( "/mIconLineLayer.svg" );
|
||||
break;
|
||||
case Polygon:
|
||||
mIconName = QStringLiteral( "/mIconPolygonLayer.svg" );
|
||||
break;
|
||||
// TODO add a new icon for generic Vector layers
|
||||
case Vector :
|
||||
mIconName = QStringLiteral( "/mIconPolygonLayer.svg" );
|
||||
break;
|
||||
case TableLayer:
|
||||
mIconName = QStringLiteral( "/mIconTableLayer.svg" );
|
||||
break;
|
||||
case Raster:
|
||||
mIconName = QStringLiteral( "/mIconRaster.svg" );
|
||||
break;
|
||||
default:
|
||||
mIconName = QStringLiteral( "/mIconLayer.png" );
|
||||
break;
|
||||
}
|
||||
mIconName = iconName( layerType );
|
||||
}
|
||||
|
||||
QgsMapLayer::LayerType QgsLayerItem::mapLayerType() const
|
||||
@ -588,6 +564,36 @@ QString QgsLayerItem::layerTypeAsString( const QgsLayerItem::LayerType &layerTyp
|
||||
return staticMetaObject.enumerator( enumIdx ).valueToKey( layerType );
|
||||
}
|
||||
|
||||
QString QgsLayerItem::iconName( const QgsLayerItem::LayerType &layerType )
|
||||
{
|
||||
switch ( layerType )
|
||||
{
|
||||
case Point:
|
||||
return QStringLiteral( "/mIconPointLayer.svg" );
|
||||
break;
|
||||
case Line:
|
||||
return QStringLiteral( "/mIconLineLayer.svg" );
|
||||
break;
|
||||
case Polygon:
|
||||
return QStringLiteral( "/mIconPolygonLayer.svg" );
|
||||
break;
|
||||
// TODO add a new icon for generic Vector layers
|
||||
case Vector :
|
||||
return QStringLiteral( "/mIconPolygonLayer.svg" );
|
||||
break;
|
||||
case TableLayer:
|
||||
case Table:
|
||||
return QStringLiteral( "/mIconTableLayer.svg" );
|
||||
break;
|
||||
case Raster:
|
||||
return QStringLiteral( "/mIconRaster.svg" );
|
||||
break;
|
||||
default:
|
||||
return QStringLiteral( "/mIconLayer.png" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool QgsLayerItem::equal( const QgsDataItem *other )
|
||||
{
|
||||
//QgsDebugMsg ( mPath + " x " + other->mPath );
|
||||
|
@ -384,11 +384,16 @@ class CORE_EXPORT QgsLayerItem : public QgsDataItem
|
||||
*/
|
||||
virtual QString comments() const { return QString(); }
|
||||
|
||||
/** Returns the string representatio of the given \a layerType
|
||||
/** Returns the string representation of the given \a layerType
|
||||
* \since QGIS 3
|
||||
*/
|
||||
static QString layerTypeAsString( const LayerType &layerType );
|
||||
|
||||
/** Returns the icon name of the given \a layerType
|
||||
* \since QGIS 3
|
||||
*/
|
||||
static QString iconName( const LayerType &layerType );
|
||||
|
||||
protected:
|
||||
|
||||
//! The provider key
|
||||
|
Loading…
x
Reference in New Issue
Block a user