Skip to content

Commit

Permalink
Fix slow icon rendering in field combo box (refs #14041)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 30, 2015
1 parent b737850 commit 34c9daa
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/gui/qgsfieldmodel.cpp
Expand Up @@ -240,6 +240,25 @@ int QgsFieldModel::columnCount( const QModelIndex &parent ) const

QVariant QgsFieldModel::data( const QModelIndex &index, int role ) const
{
static QIcon intIcon;
if ( intIcon.isNull() )
intIcon = QgsApplication::getThemeIcon( "/mIconFieldInteger.svg" );
static QIcon floatIcon;
if ( floatIcon.isNull() )
floatIcon = QgsApplication::getThemeIcon( "/mIconFieldFloat.svg" );
static QIcon stringIcon;
if ( stringIcon.isNull() )
stringIcon = QgsApplication::getThemeIcon( "/mIconFieldText.svg" );
static QIcon dateIcon;
if ( dateIcon.isNull() )
dateIcon = QgsApplication::getThemeIcon( "/mIconFieldDate.svg" );
static QIcon dateTimeIcon;
if ( dateTimeIcon.isNull() )
dateTimeIcon = QgsApplication::getThemeIcon( "/mIconFieldDateTime.svg" );
static QIcon timeIcon;
if ( timeIcon.isNull() )
timeIcon = QgsApplication::getThemeIcon( "/mIconFieldTime.svg" );

if ( !index.isValid() )
return QVariant();

Expand Down Expand Up @@ -304,7 +323,7 @@ QVariant QgsFieldModel::data( const QModelIndex &index, int role ) const
if ( exprIdx < 0 )
{
QgsField field = mFields[index.row()];
return ( int )field.type();
return static_cast< int >( field.type() );
}
return QVariant();
}
Expand Down Expand Up @@ -364,7 +383,7 @@ QVariant QgsFieldModel::data( const QModelIndex &index, int role ) const
if ( exprIdx < 0 )
{
QgsField field = mFields[index.row()];
int fieldType = ( int )field.type();
int fieldType = static_cast< int >( field.type() );

switch ( fieldType )
{
Expand All @@ -373,27 +392,27 @@ QVariant QgsFieldModel::data( const QModelIndex &index, int role ) const
case QVariant::LongLong:
case QVariant::ULongLong:
{
return QgsApplication::getThemeIcon( "/mIconFieldInteger.svg" );
return intIcon;
}
case QVariant::Double:
{
return QgsApplication::getThemeIcon( "/mIconFieldFloat.svg" );
return floatIcon;
}
case QVariant::String:
{
return QgsApplication::getThemeIcon( "/mIconFieldText.svg" );
return stringIcon;
}
case QVariant::Date:
{
return QgsApplication::getThemeIcon( "/mIconFieldDate.svg" );
return dateIcon;
}
case QVariant::DateTime:
{
return QgsApplication::getThemeIcon( "/mIconFieldDateTime.svg" );
return dateTimeIcon;
}
case QVariant::Time:
{
return QgsApplication::getThemeIcon( "/mIconFieldTime.svg" );
return timeIcon;
}
default:
return QIcon();
Expand Down

0 comments on commit 34c9daa

Please sign in to comment.