75 const bool isEditSelection = mEditSelectionModel && mEditSelectionModel->isSelected( mListModel->mapToMaster( index ) );
77 QStyleOptionViewItem textOption = option;
78 textOption.state |= QStyle::State_Enabled;
79 if ( isEditSelection )
81 textOption.state |= QStyle::State_Selected;
83 drawBackground( painter, textOption, index );
86 static QPixmap sSelectedIcon;
87 if ( sSelectedIcon.isNull() )
89 static QPixmap sDeselectedIcon;
90 if ( sDeselectedIcon.isNull() )
93 const QString text = index.model()->data( index, Qt::EditRole ).toString();
97 const QStyleOptionViewItem iconOption;
99 QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
101 QPixmap icon = mFeatureSelectionModel->isSelected( index ) ? sSelectedIcon : sDeselectedIcon;
106 icon = icon.scaledToHeight( option.rect.height(), Qt::SmoothTransformation );
109 drawDecoration( painter, iconOption, iconLayoutBounds, icon );
112 const QVariant conditionalIcon = index.model()->data( index, Qt::DecorationRole );
113 if ( conditionalIcon.isValid() )
115 const QPixmap pixmap = conditionalIcon.value<QPixmap>();
116 iconLayoutBounds.moveLeft( iconLayoutBounds.x() + icon.width() + QFontMetrics( textOption.font ).horizontalAdvance(
'X' ) );
117 iconLayoutBounds.setTop( option.rect.y() + ( option.rect.height() - pixmap.height() ) / 2.0 );
118 iconLayoutBounds.setHeight( pixmap.height() );
119 drawDecoration( painter, iconOption, iconLayoutBounds, pixmap );
123 const QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );
126 const QVariant font = index.model()->data( index, Qt::FontRole );
127 if ( font.isValid() )
129 textOption.font = font.value<QFont>();
131 const QVariant textColor = index.model()->data( index, Qt::ForegroundRole );
132 if ( textColor.isValid() )
134 textOption.palette.setColor( QPalette::Text, textColor.value<QColor>() );
137 if ( featInfo.
isNew )
139 textOption.font.setStyle( QFont::StyleItalic );
140 textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
141 textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
143 else if ( featInfo.
isEdited || ( mCurrentFeatureEdited && isEditSelection ) )
145 textOption.font.setStyle( QFont::StyleItalic );
146 textOption.palette.setColor( QPalette::Text, Qt::red );
147 textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
150 drawDisplay( painter, textOption, textLayoutBounds, text );