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 );
const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
bool fieldEditable(int idx)
is edit widget editable
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Overloads the paint method form the QItemDelegate bas class.
This class contains context information for attribute editor widgets.
void beginEditCommand(QString text)
Create edit command for undo/redo operations.
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
void setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Used to create an editor for when the user tries to change the contents of a cell.
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
A widget was opened as a popup (e.g. attribute table editor widget)
void setEditorData(QWidget *editor, const QModelIndex &index) const override
Sets data from model into the editor.
const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
Q_DECL_DEPRECATED bool changeAttributeValue(QgsFeatureId fid, int field, QVariant value, bool emitSignal)
Changes an attribute value (but does not commit it)
void endEditCommand()
Finish edit command and add it to undo/redo stack.
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Sets data from editor back to model.
QgsVectorLayer * layer() const
Returns the layer this model uses as backend.
Represents a vector layer which manages a vector based data sets.