QGIS API Documentation  2.9.0-Master
Public Types | Public Slots | Public Member Functions | Protected Slots | Protected Attributes | List of all members
QgsFieldModel Class Reference

The QgsFieldModel class is a model to display the list of fields of a layer in widgets. More...

#include <qgsfieldmodel.h>

Inheritance diagram for QgsFieldModel:
Inheritance graph
[legend]

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...
 
bool allowExpression ()
 
int columnCount (const QModelIndex &parent) const override
 
QVariant data (const QModelIndex &index, int role) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex indexFromName (const QString &fieldName)
 return the index corresponding to a given fieldName More...
 
bool isField (const QString &expression)
 
QgsVectorLayerlayer ()
 returns the currently used layer More...
 
QModelIndex parent (const QModelIndex &child) const override
 
void removeExpression ()
 remove expressions from the model More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
void setAllowExpression (bool allowExpression)
 returns the currently used layer More...
 
void setExpression (const QString &expression)
 setExpression sets a single expression to be added after the fields at the end of the model More...
 

Protected Slots

virtual void updateModel ()
 

Protected Attributes

bool mAllowExpression
 
QList< QString > mExpression
 
QgsFields mFields
 
QgsVectorLayermLayer
 

Detailed Description

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.

Note
added in 2.3

Definition at line 31 of file qgsfieldmodel.h.

Member Enumeration Documentation

Enumerator
FieldNameRole 

return field name if index corresponds to a field

FieldIndexRole 

return field index if index corresponds to a field

ExpressionRole 

return field name or expression

IsExpressionRole 

return if index corresponds to an expression

ExpressionValidityRole 

return if expression is valid or not

FieldTypeRole 

return the field type (if a field, return QVariant if expression)

Definition at line 35 of file qgsfieldmodel.h.

Constructor & Destructor Documentation

QgsFieldModel::QgsFieldModel ( QObject *  parent = 0)
explicit

QgsFieldModel creates a model to display the fields of a given layer.

Definition at line 24 of file qgsfieldmodel.cpp.

Member Function Documentation

bool QgsFieldModel::allowExpression ( )
inline

Definition at line 55 of file qgsfieldmodel.h.

int QgsFieldModel::columnCount ( const QModelIndex &  parent) const
override

Definition at line 235 of file qgsfieldmodel.cpp.

QVariant QgsFieldModel::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 241 of file qgsfieldmodel.cpp.

QModelIndex QgsFieldModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

Definition at line 209 of file qgsfieldmodel.cpp.

QModelIndex QgsFieldModel::indexFromName ( const QString &  fieldName)

return the index corresponding to a given fieldName

Definition at line 31 of file qgsfieldmodel.cpp.

bool QgsFieldModel::isField ( const QString &  expression)

Definition at line 64 of file qgsfieldmodel.cpp.

QgsVectorLayer* QgsFieldModel::layer ( )
inline

returns the currently used layer

Definition at line 68 of file qgsfieldmodel.h.

QModelIndex QgsFieldModel::parent ( const QModelIndex &  child) const
override

Definition at line 219 of file qgsfieldmodel.cpp.

void QgsFieldModel::removeExpression ( )

remove expressions from the model

Definition at line 202 of file qgsfieldmodel.cpp.

int QgsFieldModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 225 of file qgsfieldmodel.cpp.

void QgsFieldModel::setAllowExpression ( bool  allowExpression)

returns the currently used layer

Definition at line 169 of file qgsfieldmodel.cpp.

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 186 of file qgsfieldmodel.cpp.

void QgsFieldModel::setLayer ( QgsVectorLayer layer)
slot

set the layer of whch fields are displayed

Definition at line 70 of file qgsfieldmodel.cpp.

void QgsFieldModel::updateModel ( )
protectedvirtualslot

Definition at line 97 of file qgsfieldmodel.cpp.

Member Data Documentation

bool QgsFieldModel::mAllowExpression
protected

Definition at line 85 of file qgsfieldmodel.h.

QList<QString> QgsFieldModel::mExpression
protected

Definition at line 82 of file qgsfieldmodel.h.

QgsFields QgsFieldModel::mFields
protected

Definition at line 81 of file qgsfieldmodel.h.

QgsVectorLayer* QgsFieldModel::mLayer
protected

Definition at line 84 of file qgsfieldmodel.h.


The documentation for this class was generated from the following files: