16 #ifndef QGSFIELDMODEL_H 17 #define QGSFIELDMODEL_H 19 #include <QAbstractItemModel> 21 #include <QItemSelectionModel> 24 #include "qgis_core.h" 41 Q_PROPERTY(
bool allowExpression READ allowExpression WRITE setAllowExpression )
42 Q_PROPERTY(
bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
50 FieldNameRole = Qt::UserRole + 1,
51 FieldIndexRole = Qt::UserRole + 2,
52 ExpressionRole = Qt::UserRole + 3,
53 IsExpressionRole = Qt::UserRole + 4,
54 ExpressionValidityRole = Qt::UserRole + 5,
55 FieldTypeRole = Qt::UserRole + 6,
56 FieldOriginRole = Qt::UserRole + 7,
57 IsEmptyRole = Qt::UserRole + 8,
68 QModelIndex indexFromName(
const QString &fieldName );
75 void setAllowExpression(
bool allowExpression );
88 void setAllowEmptyFieldName(
bool allowEmpty );
101 bool isField(
const QString &expression )
const;
109 void setExpression(
const QString &expression );
116 void removeExpression();
125 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
126 QModelIndex parent(
const QModelIndex &child )
const override;
127 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
128 int columnCount(
const QModelIndex &parent )
const override;
129 QVariant data(
const QModelIndex &index,
int role )
const override;
136 static QString fieldToolTip(
const QgsField &field );
151 virtual void updateModel();
161 bool mAllowExpression =
false;
162 bool mAllowEmpty =
false;
168 #endif // QGSFIELDMODEL_H
Container of fields for a vector layer.
The QgsFieldModel class is a model to display the list of fields of a layer in widgets.
QgsVectorLayer * layer()
Returns the layer associated with the model.
Encapsulate a field in an attribute table or data source.
FieldRoles
Roles utilized by the model.
QList< QString > mExpression
bool allowEmptyFieldName() const
Returns true if the model allows the empty field ("not set") choice.
Represents a vector layer which manages a vector based data sets.
bool allowExpression()
Returns true if the model allows custom expressions to be created and displayed.