16 #include <QItemDelegate>
32 QgsVectorLayer* QgsAttributeTableDelegate::layer(
const QAbstractItemModel *model )
60 const QStyleOptionViewItem &option,
61 const QModelIndex &
index )
const
74 QWidget* w = eww->
widget();
76 w->setAutoFillBackground(
true );
91 QVariant oldValue = model->data( index, Qt::EditRole );
98 newValue = eww->
value();
100 if (( oldValue != newValue && newValue.isValid() ) || oldValue.isNull() != newValue.isNull() )
114 eww->
setValue( index.model()->data( index, Qt::EditRole ) );
119 mFeatureSelectionModel = featureSelectionModel;
123 const QStyleOptionViewItem & option,
124 const QModelIndex &
index )
const
128 QStyleOptionViewItem myOpt = option;
130 if ( index.model()->data( index, Qt::EditRole ).isNull() )
132 myOpt.font.setItalic(
true );
133 myOpt.palette.setColor( QPalette::Text, QColor(
"gray" ) );
136 if ( mFeatureSelectionModel && mFeatureSelectionModel->
isSelected( fid ) )
137 myOpt.state |= QStyle::State_Selected;
139 QItemDelegate::paint( painter, myOpt, index );
141 if ( option.state & QStyle::State_HasFocus )
143 QRect r = option.rect.adjusted( 1, 1, -1, -1 );
144 QPen p( QBrush( QColor( 0, 255, 127 ) ), 2 );
146 painter->setPen( p );
147 painter->drawRect( r );