16 #include <QItemDelegate>
49 const QStyleOptionViewItem &option,
50 const QModelIndex &
index )
const
61 w->setAutoFillBackground(
true );
66 w->setMinimumWidth( tv->columnWidth( index.column() ) );
71 QLineEdit *le = w->findChild<QLineEdit*>();
73 w->setMinimumHeight( le->height()*2 );
90 QVariant oldValue = model->data( index, Qt::EditRole );
117 const QStyleOptionViewItem & option,
118 const QModelIndex &
index )
const
122 QStyleOptionViewItem myOpt = option;
125 myOpt.state |= QStyle::State_Selected;
127 QItemDelegate::paint( painter, myOpt, index );
129 if ( option.state & QStyle::State_HasFocus )
131 QRect r = option.rect.adjusted( 1, 1, -1, -1 );
132 QPen p( QBrush( QColor( 0, 255, 127 ) ), 2 );
134 painter->setPen( p );
135 painter->drawRect( r );
bool fieldEditable(int idx)
is edit widget editable
Provides a table view of features of a QgsVectorLayer.
virtual bool isSelected(QgsFeatureId fid)
Returns the selection status of a given feature id.
static bool retrieveValue(QWidget *widget, QgsVectorLayer *vl, int idx, QVariant &value)
void beginEditCommand(QString text)
Create edit command for undo/redo operations.
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
Used to create an editor for when the user tries to change the contents of a cell.
A model backed by a QgsVectorLayerCache which is able to provide feature/attribute information to a Q...
void setFeatureSelectionModel(QgsFeatureSelectionModel *featureSelectionModel)
QgsVectorLayer * layer() const
Returns the layer this filter acts on.
QgsVectorLayer * layer(const QAbstractItemModel *model) const
EditType editType(int idx)
get edit type
static bool setValue(QWidget *widget, QgsVectorLayer *vl, int idx, const QVariant &value)
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.
QgsFeatureSelectionModel * mFeatureSelectionModel
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
Sets data from editor back to model.
void setEditorData(QWidget *editor, const QModelIndex &index) const
Sets data from model into the editor.
static QWidget * createAttributeEditor(QWidget *parent, QWidget *editor, QgsVectorLayer *vl, int idx, const QVariant &value, QMap< int, QWidget * > &proxyWidgets)
Creates or prepares a attribute editor widget.
QgsVectorLayer * layer() const
Returns the layer this model uses as backend.
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Overloads the paint method form the QItemDelegate bas class.
Represents a vector layer which manages a vector based data sets.