QGIS API Documentation 3.38.0-Grenoble (exported)
|
Container of fields for a vector layer. More...
#include <qgsfields.h>
Classes | |
struct | Field |
Public Types | |
typedef struct QgsFields::Field | Field |
Public Member Functions | |
QgsFields () | |
Constructor for an empty field container. | |
QgsFields (const QgsFields &other) | |
Copy constructor. | |
virtual | ~QgsFields () |
QgsAttributeList | allAttributesList () const |
Utility function to get list of attribute indexes. | |
bool | append (const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1) |
Appends a field. | |
bool | appendExpressionField (const QgsField &field, int originIndex) |
Appends an expression field. The field must have unique name, otherwise it is rejected (returns false ) | |
QgsField | at (int i) const |
Returns the field at particular index (must be in range 0..N-1). | |
iterator | begin () |
Returns an STL-style iterator pointing to the first item in the list. | |
const_iterator | begin () const noexcept |
Returns a const STL-style iterator pointing to the first item in the list. | |
void | clear () |
Removes all fields. | |
const_iterator | constBegin () const noexcept |
Returns a const STL-style iterator pointing to the first item in the list. | |
const_iterator | constEnd () const noexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. | |
int | count () const |
Returns number of items. | |
iterator | end () |
Returns an STL-style iterator pointing to the imaginary item after the last item in the list. | |
const_iterator | end () const noexcept |
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list. | |
Q_INVOKABLE bool | exists (int i) const |
Returns if a field index is valid. | |
void | extend (const QgsFields &other) |
Extends with fields from another QgsFields container. | |
QgsField | field (const QString &name) const |
Returns the field with matching name. | |
QgsField | field (int fieldIdx) const |
Returns the field at particular index (must be in range 0..N-1). | |
Qgis::FieldOrigin | fieldOrigin (int fieldIdx) const |
Returns the field's origin (value from an enumeration). | |
int | fieldOriginIndex (int fieldIdx) const |
Returns the field's origin index (its meaning is specific to each type of origin). | |
QIcon | iconForField (int fieldIdx, bool considerOrigin=false) const |
Returns an icon corresponding to a field index, based on the field's type and source. | |
Q_INVOKABLE int | indexFromName (const QString &fieldName) const |
Gets the field index from the field name. | |
Q_INVOKABLE int | indexOf (const QString &fieldName) const |
Gets the field index from the field name. | |
bool | isEmpty () const |
Checks whether the container is empty. | |
Q_INVOKABLE int | lookupField (const QString &fieldName) const |
Looks up field's index from the field name. | |
QStringList | names () const |
Returns a list with field names. | |
operator QVariant () const | |
Allows direct construction of QVariants from fields. | |
bool | operator!= (const QgsFields &other) const |
QgsFields & | operator= (const QgsFields &other) |
Assignment operator. | |
bool | operator== (const QgsFields &other) const |
QgsField & | operator[] (int i) |
Gets field at particular index (must be in range 0..N-1) | |
QgsField | operator[] (int i) const |
Gets field at particular index (must be in range 0..N-1) | |
void | remove (int fieldIdx) |
Removes the field with the given index. | |
bool | rename (int fieldIdx, const QString &name) |
Renames a name of field. | |
int | size () const |
Returns number of items. | |
QList< QgsField > | toList () const |
Utility function to return a list of QgsField instances. | |
Static Public Member Functions | |
static QIcon | iconForFieldType (QMetaType::Type type, QMetaType::Type subType=QMetaType::Type::UnknownType, const QString &typeString=QString()) |
Returns an icon corresponding to a field type. | |
static Q_DECL_DEPRECATED QIcon | iconForFieldType (QVariant::Type type, QVariant::Type subType, const QString &typeString=QString()) |
Returns an icon corresponding to a field type. | |
Properties | |
int | count |
bool | isEmpty |
QStringList | names |
Container of fields for a vector layer.
In addition to storing a list of QgsField instances, it also:
Definition at line 45 of file qgsfields.h.
typedef struct QgsFields::Field QgsFields::Field |
QgsFields::QgsFields | ( | ) |
Constructor for an empty field container.
Definition at line 29 of file qgsfields.cpp.
QgsFields::QgsFields | ( | const QgsFields & | other | ) |
Copy constructor.
Definition at line 34 of file qgsfields.cpp.
|
virtual |
Definition at line 45 of file qgsfields.cpp.
QgsAttributeList QgsFields::allAttributesList | ( | ) | const |
Utility function to get list of attribute indexes.
Definition at line 392 of file qgsfields.cpp.
bool QgsFields::append | ( | const QgsField & | field, |
Qgis::FieldOrigin | origin = Qgis::FieldOrigin::Provider , |
||
int | originIndex = -1 |
||
) |
Appends a field.
The field must have a unique name, otherwise it is rejected (returns false
).
The originIndex argument must be set to a value corresponding to the origin type:
Definition at line 60 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 91 of file qgsfields.cpp.
QgsField QgsFields::at | ( | int | i | ) | const |
Returns the field at particular index (must be in range 0..N-1).
Definition at line 164 of file qgsfields.cpp.
QgsFields::iterator QgsFields::begin | ( | ) |
Returns an STL-style iterator pointing to the first item in the list.
Definition at line 258 of file qgsfields.cpp.
|
noexcept |
Returns a const STL-style iterator pointing to the first item in the list.
Definition at line 242 of file qgsfields.cpp.
void QgsFields::clear | ( | ) |
Removes all fields.
Definition at line 48 of file qgsfields.cpp.
|
noexcept |
Returns a const STL-style iterator pointing to the first item in the list.
Definition at line 226 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 234 of file qgsfields.cpp.
int QgsFields::count | ( | ) | const |
Returns number of items.
Definition at line 134 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 267 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 250 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 154 of file qgsfields.cpp.
void QgsFields::extend | ( | const QgsFields & | other | ) |
Extends with fields from another QgsFields container.
Definition at line 115 of file qgsfields.cpp.
QgsField QgsFields::field | ( | const QString & | name | ) | const |
Returns the field with matching name.
Definition at line 174 of file qgsfields.cpp.
QgsField QgsFields::field | ( | int | fieldIdx | ) | const |
Returns the field at particular index (must be in range 0..N-1).
Definition at line 169 of file qgsfields.cpp.
Qgis::FieldOrigin QgsFields::fieldOrigin | ( | int | fieldIdx | ) | const |
Returns the field's origin (value from an enumeration).
Definition at line 190 of file qgsfields.cpp.
int QgsFields::fieldOriginIndex | ( | int | fieldIdx | ) | const |
Returns the field's origin index (its meaning is specific to each type of origin).
Definition at line 198 of file qgsfields.cpp.
QIcon QgsFields::iconForField | ( | int | fieldIdx, |
bool | considerOrigin = false |
||
) | const |
Returns an icon corresponding to a field index, based on the field's type and source.
fieldIdx | the field index |
considerOrigin | if true the icon will the origin of the field |
Definition at line 276 of file qgsfields.cpp.
|
static |
Returns an icon corresponding to a field type.
Since QGIS 3.24, the optional subType argument can be used to specify the type of variant list or map values. Since QGIS 3.30, the optional typeString argument can be used to specify field type strings for handling user field types.
Definition at line 295 of file qgsfields.cpp.
|
static |
Returns an icon corresponding to a field type.
Since QGIS 3.24, the optional subType argument can be used to specify the type of variant list or map values. Since QGIS 3.30, the optional typeString argument can be used to specify field type strings for handling user field types.
Definition at line 354 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 203 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 208 of file qgsfields.cpp.
bool QgsFields::isEmpty | ( | ) | const |
Checks whether the container is empty.
Definition at line 129 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 365 of file qgsfields.cpp.
QStringList QgsFields::names | ( | ) | const |
Returns a list with field names.
Definition at line 144 of file qgsfields.cpp.
|
inline |
Allows direct construction of QVariants from fields.
Definition at line 466 of file qgsfields.h.
|
inline |
Definition at line 412 of file qgsfields.h.
Assignment operator.
Definition at line 39 of file qgsfields.cpp.
bool QgsFields::operator== | ( | const QgsFields & | other | ) | const |
Definition at line 221 of file qgsfields.cpp.
QgsField & QgsFields::operator[] | ( | int | i | ) |
Gets field at particular index (must be in range 0..N-1)
Definition at line 159 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 185 of file qgsfields.cpp.
void QgsFields::remove | ( | int | fieldIdx | ) |
Removes the field with the given index.
Definition at line 102 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 73 of file qgsfields.cpp.
int QgsFields::size | ( | ) | const |
Returns number of items.
Definition at line 139 of file qgsfields.cpp.
QList< QgsField > QgsFields::toList | ( | ) | const |
Utility function to return a list of QgsField instances.
Definition at line 213 of file qgsfields.cpp.
|
read |
Definition at line 50 of file qgsfields.h.
|
read |
Definition at line 49 of file qgsfields.h.
|
read |
Definition at line 51 of file qgsfields.h.