78 const bool isEditSelection = mEditSelectionModel && mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );
80 QStyleOptionViewItem textOption = option;
81 textOption.state |= QStyle::State_Enabled;
82 if ( isEditSelection )
84 textOption.state |= QStyle::State_Selected;
86 drawBackground( painter, textOption, index );
89 static QPixmap sSelectedIcon;
90 if ( sSelectedIcon.isNull() )
92 static QPixmap sDeselectedIcon;
93 if ( sDeselectedIcon.isNull() )
96 const QString text = index.model()->data( index, Qt::EditRole ).toString();
100 const QStyleOptionViewItem iconOption;
102 QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
104 QPixmap icon = mFeatureSelectionModel->isSelected( index ) ? sSelectedIcon : sDeselectedIcon;
109 icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
112 drawDecoration( painter, iconOption, iconLayoutBounds, icon );
115 const QVariant conditionalIcon = index.model()->data( index, Qt::DecorationRole );
116 if ( conditionalIcon.isValid() )
118 const QPixmap pixmap = conditionalIcon.value<QPixmap>();
119 iconLayoutBounds.moveLeft( iconLayoutBounds.x() + icon.width() + QFontMetrics( textOption.font ).horizontalAdvance(
'X' ) );
120 iconLayoutBounds.setTop( option.rect.y() + ( option.rect.height() - pixmap.height() ) / 2.0 );
121 iconLayoutBounds.setHeight( pixmap.height() );
122 drawDecoration( painter, iconOption, iconLayoutBounds, pixmap );
126 const QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );
129 const QVariant font = index.model()->data( index, Qt::FontRole );
130 if ( font.isValid() )
132 textOption.font = font.value<QFont>();
134 const QVariant textColor = index.model()->data( index, Qt::ForegroundRole );
135 if ( textColor.isValid() )
137 textOption.palette.setColor( QPalette::Text, textColor.value<QColor>() );
140 if ( featInfo.
isNew )
142 textOption.font.setStyle( QFont::StyleItalic );
143 textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
144 textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
146 else if ( featInfo.
isEdited || ( mCurrentFeatureEdited && isEditSelection ) )
148 textOption.font.setStyle( QFont::StyleItalic );
149 textOption.palette.setColor( QPalette::Text, Qt::red );
150 textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
153 drawDisplay( painter, textOption, textLayoutBounds, text );