77 const bool isEditSelection = mEditSelectionModel && mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );
79 QStyleOptionViewItem textOption = option;
80 textOption.state |= QStyle::State_Enabled;
81 if ( isEditSelection )
83 textOption.state |= QStyle::State_Selected;
85 drawBackground( painter, textOption, index );
88 static QPixmap sSelectedIcon;
89 if ( sSelectedIcon.isNull() )
91 static QPixmap sDeselectedIcon;
92 if ( sDeselectedIcon.isNull() )
95 const QString text = index.model()->data( index, Qt::EditRole ).toString();
99 const QStyleOptionViewItem iconOption;
101 QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
103 QPixmap icon = mFeatureSelectionModel->isSelected( index ) ? sSelectedIcon : sDeselectedIcon;
108 icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
111 drawDecoration( painter, iconOption, iconLayoutBounds, icon );
114 const QVariant conditionalIcon = index.model()->data( index, Qt::DecorationRole );
115 if ( conditionalIcon.isValid() )
117 const QPixmap pixmap = conditionalIcon.value<QPixmap>();
118 iconLayoutBounds.moveLeft( iconLayoutBounds.x() + icon.width() + QFontMetrics( textOption.font ).horizontalAdvance(
'X' ) );
119 iconLayoutBounds.setTop( option.rect.y() + ( option.rect.height() - pixmap.height() ) / 2.0 );
120 iconLayoutBounds.setHeight( pixmap.height() );
121 drawDecoration( painter, iconOption, iconLayoutBounds, pixmap );
125 const QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );
128 const QVariant font = index.model()->data( index, Qt::FontRole );
129 if ( font.isValid() )
131 textOption.font = font.value<QFont>();
133 const QVariant textColor = index.model()->data( index, Qt::ForegroundRole );
134 if ( textColor.isValid() )
136 textOption.palette.setColor( QPalette::Text, textColor.value<QColor>() );
139 if ( featInfo.
isNew )
141 textOption.font.setStyle( QFont::StyleItalic );
142 textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
143 textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
145 else if ( featInfo.
isEdited || ( mCurrentFeatureEdited && isEditSelection ) )
147 textOption.font.setStyle( QFont::StyleItalic );
148 textOption.palette.setColor( QPalette::Text, Qt::red );
149 textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
152 drawDisplay( painter, textOption, textLayoutBounds, text );