24 : mName( nam ), mType( typ ), mLength( len ), mPrecision( prec ), mNumeric( num )
35 QgsField::QgsField( QString name, QVariant::Type type, QString typeName,
int len,
int prec, QString comment )
36 : mName( name ), mType( type ), mTypeName( typeName )
37 , mLength( len ), mPrecision( prec ), mComment( comment )
54 return !( *
this == other );
122 return settings.value(
"qgis/nullValue",
"NULL" ).toString();
126 return QString::number( v.toDouble(),
'f',
mPrecision );
161 for (
int i = 0; i < other.
count(); ++i )
170 for (
int i = 0; i <
mFields.count(); ++i )
171 lst.append(
mFields[i].field );
177 for (
int idx = 0; idx <
count(); ++idx )
179 if ( QString::compare(
mFields[idx].
field.
name(), fieldName, Qt::CaseInsensitive ) == 0 )
190 for (
int i = 0; i <
mFields.count(); ++i )
QList< QgsField > toList() const
Utility function to return a list of QgsField instances.
void setPrecision(int prec)
Set the field precision.
const QString & name() const
Gets the name of the field.
bool operator==(const QgsField &other) const
QString mTypeName
Type name from provider.
struct QgsFields::Field Field
QgsField(QString name=QString(), QVariant::Type type=QVariant::Invalid, QString typeName=QString(), int len=0, int prec=0, QString comment=QString())
Constructor.
void setTypeName(const QString &typ)
Set the field type.
QString displayString(const QVariant &v) const
Formats string for display.
const QgsField & field(int fieldIdx) const
Get field at particular index (must be in range 0..N-1)
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs...
int precision() const
Gets the precision of the field.
Container of fields for a vector layer.
void extend(const QgsFields &other)
Extend with fields from another QgsFields container.
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 ...
void setLength(int len)
Set the field length.
void clear()
Remove all fields.
bool operator!=(const QgsField &other) const
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
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Append a field. The field must have unique name, otherwise it is rejected (returns false) ...
QVariant::Type mType
Variant type.
int count() const
Return number of items.
Encapsulate a field in an attribute table or data source.
void remove(int fieldIdx)
Remove a field with the given index.
void setName(const QString &nam)
Set the field name.
void setType(QVariant::Type type)
Set variant type.
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
const QString & typeName() const
Gets the field type.
int length() const
Gets the length of the field.
const QString & comment() const
Returns the field comment.
QVector< Field > mFields
internal storage of the container
QgsAttributeList allAttributesList() const
Utility function to get list of attribute indexes.
void setComment(const QString &comment)
Set the field comment.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.