Skip to content
Permalink
Browse files

Cache pixmaps in feature list view

  • Loading branch information
nyalldawson committed Mar 8, 2016
1 parent ea10c5d commit 47d97b21d4f0bd3746f0942486b3cd0911a6ef17
Showing with 8 additions and 12 deletions.
  1. +8 −12 src/gui/attributetable/qgsfeaturelistviewdelegate.cpp
@@ -58,6 +58,13 @@ QSize QgsFeatureListViewDelegate::sizeHint( const QStyleOptionViewItem& option,

void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const
{
static QPixmap selectedIcon;
if ( selectedIcon.isNull() )
selectedIcon = QgsApplication::getThemePixmap( "/mIconSelected.svg" );
static QPixmap deselectedIcon;
if ( deselectedIcon.isNull() )
deselectedIcon = QgsApplication::getThemePixmap( "/mIconDeselected.svg" );

QString text = index.model()->data( index, Qt::EditRole ).toString();
QgsFeatureListModel::FeatureInfo featInfo = index.model()->data( index, Qt::UserRole ).value<QgsFeatureListModel::FeatureInfo>();

@@ -68,25 +75,14 @@ void QgsFeatureListViewDelegate::paint( QPainter *painter, const QStyleOptionVie

QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );

QPixmap icon;

if ( mFeatureSelectionModel->isSelected( index ) )
{
// Item is selected
icon = QgsApplication::getThemePixmap( "/mIconSelected.svg" );
}
else
{
icon = QgsApplication::getThemePixmap( "/mIconDeselected.svg" );
}
QPixmap icon = mFeatureSelectionModel->isSelected( index ) ? selectedIcon : deselectedIcon;

// Scale up the icon if needed
if ( option.rect.height() > sIconSize )
{
icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
}


// Text layout options
QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );

0 comments on commit 47d97b2

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