47 QVariant::Type type = QVariant::Invalid,
48 QString typeName = QString(),
51 QString comment = QString() );
60 const QString & name()
const;
63 QVariant::Type type()
const;
71 const QString & typeName()
const;
85 int precision()
const;
90 const QString & comment()
const;
96 void setName(
const QString & nam );
101 void setType( QVariant::Type type );
107 void setTypeName(
const QString & typ );
113 void setLength(
int len );
119 void setPrecision(
int prec );
125 void setComment(
const QString & comment );
128 QString displayString(
const QVariant& v )
const;
175 Field(): origin( OriginUnknown ), originIndex( -1 ) {}
186 bool append(
const QgsField& field,
FieldOrigin origin = OriginProvider,
int originIndex = -1 );
188 void remove(
int fieldIdx );
193 inline bool isEmpty()
const {
return mFields.isEmpty(); }
195 inline int count()
const {
return mFields.count(); }
197 inline int size()
const {
return mFields.count(); }
201 inline bool exists(
int i )
const {
return i >= 0 && i < mFields.count(); }
208 const QgsField&
at(
int i )
const {
return mFields[i].field; }
210 const QgsField&
field(
int fieldIdx )
const {
return mFields[fieldIdx].field; }
212 const QgsField&
field(
const QString& name )
const {
return mFields[ indexFromName( name )].field; }
220 int indexFromName(
const QString& name )
const {
return mNameToIndex.value( name, -1 ); }
225 int fieldNameIndex(
const QString& fieldName )
const;
232 QList<QgsField> toList()
const;
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
QString mTypeName
Type name from provider.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
const QgsField & field(int fieldIdx) const
Get field at particular index (must be in range 0..N-1)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Container of fields for a vector layer.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
it has not been specified where the field comes from
bool exists(int i) const
Return if a field index is valid.
Field(const QgsField &f, FieldOrigin o, int oi)
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
QList< int > QgsAttributeList
QHash< QString, int > mNameToIndex
map for quick resolution of name to index
QVariant::Type mType
Variant type.
int count() const
Return number of items.
Encapsulate a field in an attribute table or data source.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
const QgsField & operator[](int i) const
Get field at particular index (must be in range 0..N-1)
const QgsField & field(const QString &name) const
Get field at particular index (must be in range 0..N-1)
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
int size() const
Return number of items.
QVector< Field > mFields
internal storage of the container
QgsField & operator[](int i)
Get field at particular index (must be in range 0..N-1)
QList< int > QgsAttributeList
int originIndex
index specific to the origin
FieldOrigin origin
origin of the field
bool isEmpty() const
Check whether the container is empty.