Skip to content
Permalink
Browse files

QgsFields: make icon for type static

  • Loading branch information
elpaso authored and nyalldawson committed Jul 6, 2020
1 parent a0c3f6f commit f89fb2ae40b0eb157948176036a62a51157945c8
Showing with 21 additions and 1 deletion.
  1. +8 −0 python/core/auto_generated/qgsfields.sip.in
  2. +6 −1 src/core/qgsfields.cpp
  3. +7 −0 src/core/qgsfields.h
@@ -309,6 +309,14 @@ Returns an icon corresponding to a field index, based on the field's type and so
}
%End


static QIcon iconForFieldType( const QVariant::Type &type ) /Factory/;
%Docstring
Returns an icon corresponding to a field ``type``

.. versionadded:: 3.16
%End

operator QVariant() const;


@@ -274,7 +274,12 @@ QgsFields::iterator QgsFields::end()

QIcon QgsFields::iconForField( int fieldIdx ) const
{
switch ( d->fields.at( fieldIdx ).field.type() )
return QgsFields::iconForFieldType( d->fields.at( fieldIdx ).field.type() );
}

QIcon QgsFields::iconForFieldType( const QVariant::Type &type )
{
switch ( type )
{
case QVariant::Bool:
return QgsApplication::getThemeIcon( "/mIconFieldBool.svg" );
@@ -338,6 +338,13 @@ class CORE_EXPORT QgsFields
% End
#endif


/**
* Returns an icon corresponding to a field \a type
* \since QGIS 3.16
*/
static QIcon iconForFieldType( const QVariant::Type &type ) SIP_FACTORY;

//! Allows direct construction of QVariants from fields.
operator QVariant() const
{

0 comments on commit f89fb2a

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