10 #include <QPushButton>
12 #include <QApplication>
13 #include <QMouseEvent>
17 : QItemDelegate( parent )
18 , mFeatureSelectionModel( NULL )
19 , mEditSelectionModel( NULL )
20 , mListModel( listModel )
21 , mCurrentFeatureEdited( false )
39 mFeatureSelectionModel = featureSelectionModel;
44 mCurrentFeatureEdited = state;
49 mEditSelectionModel = editSelectionModel;
55 return QSize( option.rect.width(),
sIconSize );
60 QString text = index.model()->data( index, Qt::EditRole ).toString();
63 bool isEditSelection = mEditSelectionModel && mEditSelectionModel->isSelected( mListModel->
mapToMaster( index ) );
66 QStyleOptionViewItem iconOption;
68 QRect iconLayoutBounds( option.rect.x(), option.rect.y(), option.rect.height(), option.rect.height() );
72 if ( mFeatureSelectionModel->
isSelected( index ) )
83 QRect textLayoutBounds( iconLayoutBounds.x() + iconLayoutBounds.width(), option.rect.y(), option.rect.width() - ( iconLayoutBounds.x() + iconLayoutBounds.width() ), option.rect.height() );
85 QStyleOptionViewItem textOption;
86 textOption.state |= QStyle::State_Enabled;
87 if ( isEditSelection )
89 textOption.state |= QStyle::State_Selected;
94 textOption.font.setStyle( QFont::StyleItalic );
95 textOption.palette.setColor( QPalette::Text, Qt::darkGreen );
96 textOption.palette.setColor( QPalette::HighlightedText, Qt::darkGreen );
98 else if ( featInfo.
isEdited || ( mCurrentFeatureEdited && isEditSelection ) )
100 textOption.font.setStyle( QFont::StyleItalic );
101 textOption.palette.setColor( QPalette::Text, Qt::red );
102 textOption.palette.setColor( QPalette::HighlightedText, Qt::red );
105 drawDisplay( painter, textOption, textLayoutBounds, text );
106 drawDecoration( painter, iconOption, iconLayoutBounds, icon );