76 const bool isEditSelection = mEditSelectionModel && mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );
78 QStyleOptionViewItem textOption = option;
79 textOption.state |= QStyle::State_Enabled;
80 if ( isEditSelection )
82 textOption.state |= QStyle::State_Selected;
84 drawBackground( painter, textOption, index );
87 static QPixmap sSelectedIcon;
88 if ( sSelectedIcon.isNull() )
90 static QPixmap sDeselectedIcon;
91 if ( sDeselectedIcon.isNull() )
94 const QString text = index.model()->data( index, Qt::EditRole ).toString();
98 const QStyleOptionViewItem iconOption;
100 QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
102 QPixmap icon = mFeatureSelectionModel->isSelected( index ) ? sSelectedIcon : sDeselectedIcon;
107 icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
110 drawDecoration( painter, iconOption, iconLayoutBounds, icon );
113 const QVariant conditionalIcon = index.model()->data( index, Qt::DecorationRole );
114 if ( conditionalIcon.isValid() )
116 const QPixmap pixmap = conditionalIcon.value<QPixmap>();
117 iconLayoutBounds.moveLeft( iconLayoutBounds.x() + icon.width() + QFontMetrics( textOption.font ).horizontalAdvance(
'X' ) );
118 iconLayoutBounds.setTop( option.rect.y() + ( option.rect.height() - pixmap.height() ) / 2.0 );
119 iconLayoutBounds.setHeight( pixmap.height() );
120 drawDecoration( painter, iconOption, iconLayoutBounds, pixmap );
124 const QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );
127 const QVariant font = index.model()->data( index, Qt::FontRole );
128 if ( font.isValid() )
130 textOption.font = font.value<QFont>();
132 const QVariant textColor = index.model()->data( index, Qt::ForegroundRole );
133 if ( textColor.isValid() )
135 textOption.palette.setColor( QPalette::Text, textColor.value<QColor>() );
138 if ( featInfo.
isNew )
140 textOption.font.setStyle( QFont::StyleItalic );
141 textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
142 textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
144 else if ( featInfo.
isEdited || ( mCurrentFeatureEdited && isEditSelection ) )
146 textOption.font.setStyle( QFont::StyleItalic );
147 textOption.palette.setColor( QPalette::Text, Qt::red );
148 textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
151 drawDisplay( painter, textOption, textLayoutBounds, text );