QGIS API Documentation
2.2.0-Valmiera
|
Container of fields for a vector layer. More...
#include <qgsfield.h>
Classes | |
struct | Field |
Public Types | |
enum | FieldOrigin { OriginUnknown, OriginProvider, OriginJoin, OriginEdit } |
typedef struct QgsFields::Field | Field |
Public Member Functions | |
void | clear () |
Remove all fields. | |
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) | |
void | remove (int fieldIdx) |
Remove a field with the given index. | |
void | extend (const QgsFields &other) |
Extend with fields from another QgsFields container. | |
bool | isEmpty () const |
Check whether the container is empty. | |
int | count () const |
Return number of items. | |
int | size () const |
Return number of items. | |
bool | exists (int i) const |
Return if a field index is valid. | |
const QgsField & | operator[] (int i) const |
Get field at particular index (must be in range 0..N-1) | |
QgsField & | operator[] (int i) |
Get field at particular index (must be in range 0..N-1) | |
const QgsField & | at (int i) const |
Get field at particular index (must be in range 0..N-1) | |
const QgsField & | field (int fieldIdx) 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 | fieldOriginIndex (int fieldIdx) const |
Get field's origin index (its meaning is specific to each type of origin) | |
int | indexFromName (const QString &name) const |
Look up field's index from name. Returns -1 on error. | |
QList< QgsField > | toList () const |
Utility function to return a list of QgsField instances. |
Protected Attributes | |
QVector< Field > | mFields |
internal storage of the container | |
QHash< QString, int > | mNameToIndex |
map for quick resolution of name to index |
Container of fields for a vector layer.
In addition to storing a list of QgsField instances, it also:
Definition at line 162 of file qgsfield.h.
typedef struct QgsFields::Field QgsFields::Field |
Definition at line 166 of file qgsfield.h.
bool QgsFields::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)
Definition at line 137 of file qgsfield.cpp.
References mFields, mNameToIndex, QgsField::name(), and OriginProvider.
Referenced by QgsOverlayAnalyzer::combineFieldLists(), QgsGeometryAnalyzer::convexHull(), QgsPointSample::createRandomPoints(), QgsTransectSample::createSample(), extend(), QgsGeometryAnalyzer::extent(), QgsVectorLayerJoinBuffer::updateFields(), and QgsVectorLayerEditBuffer::updateFields().
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 209 of file qgsfield.h.
Referenced by extend(), QgsFeature::fieldNameIndex(), QgsRelation::getRelatedFeaturesRequest(), QgsDataDefinedButton::init(), QgsRelationEditorWidget::on_mUnlinkFeatureButton_clicked(), QgsPalLayerSettings::readDataDefinedProperty(), and QgsProjectFileTransform::transform0110to1000().
void QgsFields::clear | ( | ) |
Remove all fields.
Definition at line 131 of file qgsfield.cpp.
References mFields, and mNameToIndex.
|
inline |
Return number of items.
Definition at line 196 of file qgsfield.h.
Referenced by QgsAttributeDialog::accept(), QgsVectorLayerEditBuffer::addAttribute(), QgsVectorLayerEditBuffer::addFeature(), QgsVectorLayerFeatureIterator::addJoinedAttributes(), QgsOfflineEditing::applyFeaturesAdded(), QgsVectorLayer::attributeDisplayName(), QgsVectorDataProvider::attributeIndexes(), QgsVectorLayerEditBuffer::changeAttributeValue(), QgsVectorLayer::checkedState(), QgsOverlayAnalyzer::combineFieldLists(), QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::copyVectorLayer(), QgsFormAnnotationItem::createDesignerWidget(), QgsVectorFileWriter::createFeature(), QgsVectorLayerEditBuffer::deleteAttribute(), QgsVectorLayer::editType(), QgsAttributeAction::expandAction(), extend(), QgsVectorLayer::fieldEditable(), QgsVectorDataProvider::fieldNameIndex(), QgsFeature::fieldNameIndex(), QgsVectorLayer::fieldNameIndex(), QgsVectorDataProvider::fieldNameMap(), QgsVectorDataProvider::fillMinMaxCache(), QgsComposerAttributeTable::getHeaderLabels(), QgsZonalStatistics::getUniqueFieldName(), QgsVectorLayerImport::importLayer(), QgsDataDefinedButton::init(), QgsAttributeDialog::init(), QgsComposerAttributeTable::initializeAliasMap(), QgsLabel::labelField(), QgsVectorLayer::labelOnTop(), QgsAttributeTableModel::loadAttributes(), QgsExpressionBuilderWidget::loadFieldNames(), QgsVectorLayer::pendingAllAttributesList(), QgsVectorLayer::pendingPkAttributesList(), QgsSearchQueryBuilder::populateFields(), QgsQueryBuilder::populateFields(), QgsExpression::NodeColumnRef::prepare(), QgsFeature::QgsFeature(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), QgsVectorLayerUndoCommandAddAttribute::QgsVectorLayerUndoCommandAddAttribute(), QgsVectorLayer::range(), QgsLabel::readLabelField(), QgsVectorLayer::setCheckedState(), QgsVectorLayer::setDisplayField(), QgsVectorLayer::setEditType(), QgsVectorLayer::setFieldEditable(), QgsFeature::setFields(), QgsVectorLayer::setLabelOnTop(), QgsFeatureRequest::setSubsetOfAttributes(), QgsProjectFileTransform::transform0110to1000(), QgsVectorLayerJoinBuffer::updateFields(), QgsVectorLayer::valueMap(), and QgsVectorLayer::valueRelation().
|
inline |
Return if a field index is valid.
i | Index of the field which needs to be checked |
Definition at line 202 of file qgsfield.h.
Referenced by QgsVectorLayerFeatureIterator::prepareJoins().
void QgsFields::extend | ( | const QgsFields & | other | ) |
Extend with fields from another QgsFields container.
Definition at line 156 of file qgsfield.cpp.
References append(), at(), count(), fieldOrigin(), and fieldOriginIndex().
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 211 of file qgsfield.h.
Referenced by QgsTransectSample::createSample(), remove(), and QgsVectorLayerJoinBuffer::updateFields().
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 213 of file qgsfield.h.
|
inline |
Get field's origin (value from an enumeration)
Definition at line 216 of file qgsfield.h.
Referenced by QgsOfflineEditing::applyFeaturesAdded(), QgsVectorLayerEditBuffer::changeAttributeValue(), QgsVectorLayerEditBuffer::deleteAttribute(), extend(), QgsVectorLayer::fieldEditable(), QgsVectorLayerJoinBuffer::joinForFieldIndex(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayer::pendingPkAttributesList(), QgsVectorLayerFeatureIterator::prepareJoins(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), QgsVectorLayerUndoCommandAddAttribute::QgsVectorLayerUndoCommandAddAttribute(), QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute(), and QgsVectorLayer::uniqueValues().
|
inline |
Get field's origin index (its meaning is specific to each type of origin)
Definition at line 218 of file qgsfield.h.
Referenced by QgsOfflineEditing::applyFeaturesAdded(), QgsVectorLayerEditBuffer::deleteAttribute(), extend(), QgsVectorLayerJoinBuffer::joinForFieldIndex(), QgsVectorLayer::pendingPkAttributesList(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), QgsVectorLayerUndoCommandDeleteAttribute::QgsVectorLayerUndoCommandDeleteAttribute(), and QgsVectorLayerUndoCommandAddAttribute::undo().
|
inline |
Look up field's index from name. Returns -1 on error.
Definition at line 221 of file qgsfield.h.
Referenced by QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsPalLayerSettings::dataDefinedValue(), QgsRelation::getRelatedFeaturesRequest(), QgsRelationEditorWidget::on_mAddFeatureButton_clicked(), and QgsVectorLayerFeatureIterator::prepareJoins().
|
inline |
Check whether the container is empty.
Definition at line 194 of file qgsfield.h.
Referenced by QgsAttributeDialog::init(), and QgsExpressionBuilderWidget::loadFieldNames().
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 205 of file qgsfield.h.
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 207 of file qgsfield.h.
void QgsFields::remove | ( | int | fieldIdx | ) |
Remove a field with the given index.
Definition at line 150 of file qgsfield.cpp.
References field(), mFields, mNameToIndex, and QgsField::name().
Referenced by QgsVectorLayerEditBuffer::updateFields().
|
inline |
Return number of items.
Definition at line 198 of file qgsfield.h.
Referenced by QgsVectorLayerEditBuffer::commitChanges(), QgsGml::QgsGml(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsPalLayerSettings::readDataDefinedProperty(), and QgsVectorLayer::setDisplayField().
QList< QgsField > QgsFields::toList | ( | ) | const |
Utility function to return a list of QgsField instances.
Definition at line 164 of file qgsfield.cpp.
References mFields.
Referenced by QgsDualView::columnBoxInit(), QgsGeometryAnalyzer::eventLayer(), and QgsRelationAddDlg::loadLayerAttributes().
|
protected |
|
protected |
map for quick resolution of name to index
Definition at line 231 of file qgsfield.h.