16 #include <QItemDelegate> 20 #include <QToolButton> 36 QgsVectorLayer *QgsAttributeTableDelegate::layer(
const QAbstractItemModel *model )
73 QWidget *w = eww->
widget();
75 w->setAutoFillBackground(
true );
76 w->setFocusPolicy( Qt::StrongFocus );
91 eww->setEnabled( !readOnly );
104 QVariant oldValue = model->data( index, Qt::EditRole );
111 newValue = eww->
value();
113 if ( ( oldValue != newValue && newValue.isValid() ) || oldValue.isNull() != newValue.isNull() )
136 eww->
setValue( index.model()->data( index, Qt::EditRole ) );
141 mFeatureSelectionModel = featureSelectionModel;
156 QStyleOptionViewItem myOpt = option;
158 if ( index.model()->data( index, Qt::EditRole ).isNull() )
160 myOpt.font.setItalic(
true );
161 myOpt.palette.setColor( QPalette::Text, QColor(
"gray" ) );
164 if ( mFeatureSelectionModel && mFeatureSelectionModel->
isSelected( fid ) )
165 myOpt.state |= QStyle::State_Selected;
167 QItemDelegate::paint( painter, myOpt, index );
169 if ( option.state & QStyle::State_HasFocus )
171 QRect r = option.rect.adjusted( 1, 1, -1, -1 );
172 QPen p( QBrush( QColor( 0, 255, 127 ) ), 2 );
174 painter->setPen( p );
175 painter->drawRect( r );
bool isValid() const
Returns the validity of this feature.
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
QgsVectorLayer * layer() const
Returns the layer this model uses as backend.
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
QgsAttributeTableModel * masterModel() const
Returns the table model this filter is using.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
Overloads the paint method form the QItemDelegate base class.
Get the field index of this column.
void beginEditCommand(const QString &text)
Create edit command for undo/redo operations.
This class contains context information for attribute editor widgets.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
void actionColumnItemPainted(const QModelIndex &index) const
Is emitted when an action column item is painted.
void setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel)
Get the feature id of the feature in this row.
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.
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.
QgsVectorLayer * joinLayer() const
Returns joined layer (may be null if the reference was set by layer ID and not resolved yet) ...
QgsFields fields() const override
Returns the list of fields of this layer.
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories...
Defines left outer join from our vector layer to some other vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsEditFormConfig editFormConfig
This column shows action buttons.
void endEditCommand()
Finish edit command and add it to undo/redo stack.
QgsVectorLayerJoinBuffer * joinBuffer()
Accessor to the join buffer object.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
Sets data from editor back to model.
const QgsVectorLayerJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
ColumnType
The type of a column.
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant(), bool skipDefaultValues=false)
Changes an attribute value for a feature (but does not immediately commit the changes).
QList< int > QgsAttributeList
bool isEditable() const
Returns whether joined fields may be edited through the form of the target layer. ...
bool nextFeature(QgsFeature &f)
Geometry is not required. It may still be returned if e.g. required for a filter condition.
The type of a given column.
Represents a vector layer which manages a vector based data sets.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Set flags that affect how features will be fetched.