QGIS API Documentation
2.4.0-Chugiak
|
The QgsFieldModel class is a model to display the list of fields of a layer in widgets. More...
#include <qgsfieldmodel.h>
Public Types | |
enum | FieldRoles { FieldNameRole = Qt::UserRole + 1, FieldIndexRole = Qt::UserRole + 2, ExpressionRole = Qt::UserRole + 3, IsExpressionRole = Qt::UserRole + 4, ExpressionValidityRole = Qt::UserRole + 5, FieldTypeRole = Qt::UserRole + 6 } |
Public Slots | |
void | setLayer (QgsVectorLayer *layer) |
set the layer of whch fields are displayed More... | |
Public Member Functions | |
QgsFieldModel (QObject *parent=0) | |
QgsFieldModel creates a model to display the fields of a given layer. More... | |
QModelIndex | indexFromName (const QString &fieldName) |
return the index corresponding to a given fieldName More... | |
void | setAllowExpression (bool allowExpression) |
returns the currently used layer More... | |
bool | allowExpression () |
bool | isField (const QString &expression) |
void | setExpression (const QString &expression) |
setExpression sets a single expression to be added after the fields at the end of the model More... | |
void | removeExpression () |
remove expressions from the model More... | |
QgsVectorLayer * | layer () |
returns the currently used layer More... | |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
QModelIndex | parent (const QModelIndex &child) const |
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
int | columnCount (const QModelIndex &parent) const |
QVariant | data (const QModelIndex &index, int role) const |
Protected Slots | |
virtual void | updateModel () |
Protected Attributes | |
QgsFields | mFields |
QList< QString > | mExpression |
QgsVectorLayer * | mLayer |
bool | mAllowExpression |
Private Slots | |
void | layerDeleted () |
Private Member Functions | |
void | fetchFeature () |
The QgsFieldModel class is a model to display the list of fields of a layer in widgets.
If allowed, expressions might be added to the end of the model. It can be associated with a QgsMapLayerModel to dynamically display a layer and its fields.
Definition at line 31 of file qgsfieldmodel.h.
Enumerator | |
---|---|
FieldNameRole | |
FieldIndexRole | |
ExpressionRole | |
IsExpressionRole | |
ExpressionValidityRole | |
FieldTypeRole |
Definition at line 35 of file qgsfieldmodel.h.
|
explicit |
QgsFieldModel creates a model to display the fields of a given layer.
Definition at line 24 of file qgsfieldmodel.cpp.
|
inline |
Definition at line 55 of file qgsfieldmodel.h.
Referenced by setAllowExpression().
int QgsFieldModel::columnCount | ( | const QModelIndex & | parent | ) | const |
Definition at line 223 of file qgsfieldmodel.cpp.
QVariant QgsFieldModel::data | ( | const QModelIndex & | index, |
int | role | ||
) | const |
Definition at line 229 of file qgsfieldmodel.cpp.
References QgsVectorLayer::attributeDisplayName(), QgsFields::count(), ExpressionRole, ExpressionValidityRole, FieldIndexRole, FieldNameRole, FieldTypeRole, QgsExpression::hasParserError(), IsExpressionRole, mExpression, mFields, mLayer, QgsField::name(), QgsVectorLayer::pendingFields(), QgsExpression::prepare(), and QgsField::type().
|
private |
QModelIndex QgsFieldModel::index | ( | int | row, |
int | column, | ||
const QModelIndex & | parent = QModelIndex() |
||
) | const |
Definition at line 197 of file qgsfieldmodel.cpp.
Referenced by indexFromName(), isField(), and updateModel().
QModelIndex QgsFieldModel::indexFromName | ( | const QString & | fieldName | ) |
return the index corresponding to a given fieldName
Definition at line 31 of file qgsfieldmodel.cpp.
References QgsFields::count(), index(), QgsFields::indexFromName(), mAllowExpression, mExpression, and mFields.
Referenced by QgsFieldExpressionWidget::expressionEditingFinished(), setExpression(), QgsFieldComboBox::setField(), and QgsFieldExpressionWidget::setField().
bool QgsFieldModel::isField | ( | const QString & | expression | ) |
Definition at line 52 of file qgsfieldmodel.cpp.
References index(), QgsFields::indexFromName(), and mFields.
Referenced by QgsFieldExpressionWidget::isExpression().
|
inline |
returns the currently used layer
Definition at line 68 of file qgsfieldmodel.h.
Referenced by QgsFieldComboBox::layer(), QgsFieldExpressionWidget::layer(), and setLayer().
|
privateslot |
Definition at line 79 of file qgsfieldmodel.cpp.
References mLayer, and updateModel().
Referenced by setLayer().
QModelIndex QgsFieldModel::parent | ( | const QModelIndex & | child | ) | const |
Definition at line 207 of file qgsfieldmodel.cpp.
void QgsFieldModel::removeExpression | ( | ) |
remove expressions from the model
Definition at line 190 of file qgsfieldmodel.cpp.
References mExpression.
int QgsFieldModel::rowCount | ( | const QModelIndex & | parent = QModelIndex() | ) | const |
Definition at line 213 of file qgsfieldmodel.cpp.
References QgsFields::count(), mAllowExpression, mExpression, and mFields.
Referenced by updateModel().
void QgsFieldModel::setAllowExpression | ( | bool | allowExpression | ) |
returns the currently used layer
Definition at line 157 of file qgsfieldmodel.cpp.
References allowExpression(), QgsFields::count(), mAllowExpression, mExpression, and mFields.
Referenced by QgsFieldExpressionWidget::QgsFieldExpressionWidget().
void QgsFieldModel::setExpression | ( | const QString & | expression | ) |
setExpression sets a single expression to be added after the fields at the end of the model
Definition at line 174 of file qgsfieldmodel.cpp.
References indexFromName(), mAllowExpression, and mExpression.
Referenced by QgsFieldExpressionWidget::expressionEditingFinished(), and QgsFieldExpressionWidget::setField().
|
slot |
set the layer of whch fields are displayed
Definition at line 58 of file qgsfieldmodel.cpp.
References layer(), layerDeleted(), mLayer, and updateModel().
Referenced by QgsFieldComboBox::setLayer(), and QgsFieldExpressionWidget::setLayer().
|
protectedvirtualslot |
Definition at line 85 of file qgsfieldmodel.cpp.
References QgsFields::at(), QgsFields::count(), index(), mFields, mLayer, QgsVectorLayer::pendingFields(), QgsFields::remove(), rowCount(), and QgsFields::toList().
Referenced by layerDeleted(), and setLayer().
|
protected |
Definition at line 85 of file qgsfieldmodel.h.
Referenced by indexFromName(), rowCount(), setAllowExpression(), and setExpression().
|
protected |
Definition at line 82 of file qgsfieldmodel.h.
Referenced by data(), indexFromName(), removeExpression(), rowCount(), setAllowExpression(), and setExpression().
|
protected |
Definition at line 81 of file qgsfieldmodel.h.
Referenced by data(), indexFromName(), isField(), rowCount(), setAllowExpression(), and updateModel().
|
protected |
Definition at line 84 of file qgsfieldmodel.h.
Referenced by data(), layerDeleted(), setLayer(), and updateModel().