QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
Container of fields for a vector layer. More...
#include <qgsfields.h>
Classes | |
struct | Field |
Public Types | |
typedef struct QgsFields::Field | Field |
enum | FieldOrigin { OriginUnknown, OriginProvider, OriginJoin, OriginEdit, OriginExpression } |
Public Member Functions | |
QgsFields () | |
Constructor for an empty field container. More... | |
QgsFields (const QgsFields &other) | |
Copy constructor. More... | |
virtual | ~QgsFields () |
QgsAttributeList | allAttributesList () const |
Utility function to get list of attribute indexes. More... | |
bool | append (const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1) |
Appends a field. The field must have unique name, otherwise it is rejected (returns false ) More... | |
bool | appendExpressionField (const QgsField &field, int originIndex) |
Appends an expression field. The field must have unique name, otherwise it is rejected (returns false ) More... | |
QgsField | at (int i) const |
Gets field at particular index (must be in range 0..N-1) More... | |
const_iterator | begin () const noexcept |
Returns a const STL-style iterator pointing to the first item in the list. More... | |
iterator | begin () |
Returns an STL-style iterator pointing to the first item in the list. More... | |
void | clear () |
Removes all fields. More... | |
const_iterator | constBegin () const noexcept |
Returns a const STL-style iterator pointing to the first item in the list. More... | |
const_iterator | constEnd () const noexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. More... | |
int | count () const |
Returns number of items. More... | |
const_iterator | end () const noexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. More... | |
iterator | end () |
Returns an STL-style iterator pointing to the imaginary item after the last item in the list. More... | |
bool | exists (int i) const |
Returns if a field index is valid. More... | |
void | extend (const QgsFields &other) |
Extends with fields from another QgsFields container. More... | |
QgsField | field (int fieldIdx) const |
Gets field at particular index (must be in range 0..N-1) More... | |
QgsField | field (const QString &name) const |
Gets field with matching name. More... | |
FieldOrigin | fieldOrigin (int fieldIdx) const |
Gets field's origin (value from an enumeration) More... | |
int | fieldOriginIndex (int fieldIdx) const |
Gets field's origin index (its meaning is specific to each type of origin) More... | |
QIcon | iconForField (int fieldIdx) const |
Returns an icon corresponding to a field index, based on the field's type and source. More... | |
int | indexFromName (const QString &fieldName) const |
Gets the field index from the field name. More... | |
int | indexOf (const QString &fieldName) const |
Gets the field index from the field name. More... | |
bool | isEmpty () const |
Checks whether the container is empty. More... | |
int | lookupField (const QString &fieldName) const |
Looks up field's index from the field name. More... | |
QStringList | names () const |
Returns a list with field names. More... | |
operator QVariant () const | |
Allows direct construction of QVariants from fields. More... | |
bool | operator!= (const QgsFields &other) const |
QgsFields & | operator= (const QgsFields &other) |
Assignment operator. More... | |
bool | operator== (const QgsFields &other) const |
QgsField | operator[] (int i) const |
Gets field at particular index (must be in range 0..N-1) More... | |
QgsField & | operator[] (int i) |
Gets field at particular index (must be in range 0..N-1) More... | |
void | remove (int fieldIdx) |
Removes a field with the given index. More... | |
bool | rename (int fieldIdx, const QString &name) |
Renames a name of field. More... | |
int | size () const |
Returns number of items. More... | |
QList< QgsField > | toList () const |
Utility function to return a list of QgsField instances. More... | |
Container of fields for a vector layer.
In addition to storing a list of QgsField instances, it also:
Definition at line 42 of file qgsfields.h.
typedef struct QgsFields::Field QgsFields::Field |
Enumerator | |
---|---|
OriginUnknown | It has not been specified where the field comes from. |
OriginProvider | Field comes from the underlying data provider of the vector layer (originIndex = index in provider's fields) |
OriginJoin | Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index within the join) |
OriginEdit | Field has been temporarily added in editing mode (originIndex = index in the list of added attributes) |
OriginExpression | Field is calculated from an expression. |
Definition at line 46 of file qgsfields.h.
QgsFields::QgsFields | ( | ) |
Constructor for an empty field container.
Definition at line 28 of file qgsfields.cpp.
QgsFields::QgsFields | ( | const QgsFields & | other | ) |
Copy constructor.
Definition at line 33 of file qgsfields.cpp.
|
virtual |
Definition at line 44 of file qgsfields.cpp.
QgsAttributeList QgsFields::allAttributesList | ( | ) | const |
Utility function to get list of attribute indexes.
Definition at line 351 of file qgsfields.cpp.
bool QgsFields::append | ( | const QgsField & | field, |
FieldOrigin | origin = OriginProvider , |
||
int | originIndex = -1 |
||
) |
Appends a field. The field must have unique name, otherwise it is rejected (returns false
)
Definition at line 59 of file qgsfields.cpp.
bool QgsFields::appendExpressionField | ( | const QgsField & | field, |
int | originIndex | ||
) |
Appends an expression field. The field must have unique name, otherwise it is rejected (returns false
)
Definition at line 90 of file qgsfields.cpp.
QgsField QgsFields::at | ( | int | i | ) | const |
Gets field at particular index (must be in range 0..N-1)
Definition at line 163 of file qgsfields.cpp.
|
noexcept |
Returns a const STL-style iterator pointing to the first item in the list.
Definition at line 241 of file qgsfields.cpp.
QgsFields::iterator QgsFields::begin | ( | ) |
Returns an STL-style iterator pointing to the first item in the list.
Definition at line 257 of file qgsfields.cpp.
void QgsFields::clear | ( | ) |
Removes all fields.
Definition at line 47 of file qgsfields.cpp.
|
noexcept |
Returns a const STL-style iterator pointing to the first item in the list.
Definition at line 225 of file qgsfields.cpp.
|
noexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.
Definition at line 233 of file qgsfields.cpp.
int QgsFields::count | ( | ) | const |
Returns number of items.
Definition at line 133 of file qgsfields.cpp.
|
noexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.
Definition at line 249 of file qgsfields.cpp.
QgsFields::iterator QgsFields::end | ( | ) |
Returns an STL-style iterator pointing to the imaginary item after the last item in the list.
Definition at line 266 of file qgsfields.cpp.
bool QgsFields::exists | ( | int | i | ) | const |
Returns if a field index is valid.
i | Index of the field which needs to be checked |
true
if the field exists Definition at line 153 of file qgsfields.cpp.
void QgsFields::extend | ( | const QgsFields & | other | ) |
Extends with fields from another QgsFields container.
Definition at line 114 of file qgsfields.cpp.
QgsField QgsFields::field | ( | int | fieldIdx | ) | const |
Gets field at particular index (must be in range 0..N-1)
Definition at line 168 of file qgsfields.cpp.
QgsField QgsFields::field | ( | const QString & | name | ) | const |
Gets field with matching name.
Definition at line 173 of file qgsfields.cpp.
QgsFields::FieldOrigin QgsFields::fieldOrigin | ( | int | fieldIdx | ) | const |
Gets field's origin (value from an enumeration)
Definition at line 189 of file qgsfields.cpp.
int QgsFields::fieldOriginIndex | ( | int | fieldIdx | ) | const |
Gets field's origin index (its meaning is specific to each type of origin)
Definition at line 197 of file qgsfields.cpp.
QIcon QgsFields::iconForField | ( | int | fieldIdx | ) | const |
Returns an icon corresponding to a field index, based on the field's type and source.
Definition at line 275 of file qgsfields.cpp.
int QgsFields::indexFromName | ( | const QString & | fieldName | ) | const |
Gets the field index from the field name.
This method is case sensitive and only matches the data source name of the field. Alias for indexOf
fieldName | The name of the field. |
Definition at line 202 of file qgsfields.cpp.
int QgsFields::indexOf | ( | const QString & | fieldName | ) | const |
Gets the field index from the field name.
This method is case sensitive and only matches the data source name of the field.
fieldName | The name of the field. |
Definition at line 207 of file qgsfields.cpp.
bool QgsFields::isEmpty | ( | ) | const |
Checks whether the container is empty.
Definition at line 128 of file qgsfields.cpp.
int QgsFields::lookupField | ( | const QString & | fieldName | ) | const |
Looks up field's index from the field name.
This method matches in the following order:
fieldName | The name to look for. |
Definition at line 324 of file qgsfields.cpp.
QStringList QgsFields::names | ( | ) | const |
|
inline |
Allows direct construction of QVariants from fields.
Definition at line 340 of file qgsfields.h.
|
inline |
Definition at line 318 of file qgsfields.h.
Assignment operator.
Definition at line 38 of file qgsfields.cpp.
bool QgsFields::operator== | ( | const QgsFields & | other | ) | const |
Definition at line 220 of file qgsfields.cpp.
QgsField QgsFields::operator[] | ( | int | i | ) | const |
Gets field at particular index (must be in range 0..N-1)
Definition at line 184 of file qgsfields.cpp.
QgsField & QgsFields::operator[] | ( | int | i | ) |
Gets field at particular index (must be in range 0..N-1)
Definition at line 158 of file qgsfields.cpp.
void QgsFields::remove | ( | int | fieldIdx | ) |
Removes a field with the given index.
Definition at line 101 of file qgsfields.cpp.
bool QgsFields::rename | ( | int | fieldIdx, |
const QString & | name | ||
) |
Renames a name of field.
The field must have unique name, otherwise change is rejected (returns false
)
Definition at line 72 of file qgsfields.cpp.
int QgsFields::size | ( | ) | const |
Returns number of items.
Definition at line 138 of file qgsfields.cpp.
QList< QgsField > QgsFields::toList | ( | ) | const |
Utility function to return a list of QgsField instances.
Definition at line 212 of file qgsfields.cpp.