QGIS API Documentation
2.4.0-Chugiak
|
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. More... | |
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) More... | |
void | remove (int fieldIdx) |
Remove a field with the given index. More... | |
void | extend (const QgsFields &other) |
Extend with fields from another QgsFields container. More... | |
bool | isEmpty () const |
Check whether the container is empty. More... | |
int | count () const |
Return number of items. More... | |
int | size () const |
Return number of items. More... | |
bool | exists (int i) const |
Return if a field index is valid. More... | |
const QgsField & | operator[] (int i) const |
Get field at particular index (must be in range 0..N-1) More... | |
QgsField & | operator[] (int i) |
Get field at particular index (must be in range 0..N-1) More... | |
const QgsField & | at (int i) const |
Get field at particular index (must be in range 0..N-1) More... | |
const QgsField & | field (int fieldIdx) const |
Get field at particular index (must be in range 0..N-1) More... | |
const QgsField & | field (const QString &name) const |
Get field at particular index (must be in range 0..N-1) More... | |
FieldOrigin | fieldOrigin (int fieldIdx) const |
Get field's origin (value from an enumeration) More... | |
int | fieldOriginIndex (int fieldIdx) const |
Get field's origin index (its meaning is specific to each type of origin) More... | |
int | indexFromName (const QString &name) const |
Look up field's index from name. Returns -1 on error. More... | |
int | fieldNameIndex (const QString &fieldName) const |
Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs insensitive (fieldNameIndex()) calls. More... | |
QgsAttributeList | allAttributesList () const |
Utility function to get list of attribute indexes. More... | |
QList< QgsField > | toList () const |
Utility function to return a list of QgsField instances. More... | |
Protected Attributes | |
QVector< Field > | mFields |
internal storage of the container More... | |
QHash< QString, int > | mNameToIndex |
map for quick resolution of name to index More... | |
Container of fields for a vector layer.
In addition to storing a list of QgsField instances, it also:
Definition at line 161 of file qgsfield.h.
typedef struct QgsFields::Field QgsFields::Field |
Definition at line 165 of file qgsfield.h.
QgsAttributeList QgsFields::allAttributesList | ( | ) | const |
Utility function to get list of attribute indexes.
Definition at line 187 of file qgsfield.cpp.
References mFields.
Referenced by QgsVectorDataProvider::attributeIndexes(), QgsVectorLayer::pendingAllAttributesList(), and QgsVectorLayerFeatureIterator::prepareJoins().
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 140 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 208 of file qgsfield.h.
Referenced by extend(), QgsFeature::fieldNameIndex(), QgsRelation::getRelatedFeaturesRequest(), QgsDataDefinedButton::init(), QgsRelationEditorWidget::on_mUnlinkFeatureButton_clicked(), QgsVectorLayerRenderer::prepareDiagrams(), QgsPalLayerSettings::readDataDefinedProperty(), QgsComposerAttributeTable::readXML(), QgsProjectFileTransform::transform0110to1000(), and QgsFieldModel::updateModel().
void QgsFields::clear | ( | ) |
Remove all fields.
Definition at line 134 of file qgsfield.cpp.
References mFields, and mNameToIndex.
|
inline |
Return number of items.
Definition at line 195 of file qgsfield.h.
Referenced by QgsVectorLayerEditBuffer::addAttribute(), QgsVectorLayerEditBuffer::addFeature(), QgsVectorLayerFeatureIterator::addJoinedAttributes(), QgsOfflineEditing::applyFeaturesAdded(), QgsVectorLayer::attributeDisplayName(), QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsVectorLayerEditBuffer::changeAttributeValue(), QgsOverlayAnalyzer::combineFieldLists(), QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::copyVectorLayer(), QgsFormAnnotationItem::createDesignerWidget(), QgsVectorFileWriter::createFeature(), QgsFieldModel::data(), QgsVectorLayerEditBuffer::deleteAttribute(), QgsAttributeAction::expandAction(), extend(), QgsVectorLayer::fieldEditable(), fieldNameIndex(), QgsVectorDataProvider::fieldNameIndex(), QgsFeature::fieldNameIndex(), QgsVectorDataProvider::fieldNameMap(), QgsVectorDataProvider::fillMinMaxCache(), QgsZonalStatistics::getUniqueFieldName(), QgsVectorLayerImport::importLayer(), QgsFieldModel::indexFromName(), QgsDataDefinedButton::init(), QgsLabel::labelField(), QgsVectorLayer::labelOnTop(), QgsAttributeTableModel::loadAttributes(), QgsExpressionBuilderWidget::loadFieldNames(), QgsVectorLayer::pendingPkAttributesList(), QgsSearchQueryBuilder::populateFields(), QgsQueryBuilder::populateFields(), QgsExpression::NodeColumnRef::prepare(), QgsFeature::QgsFeature(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), QgsVectorLayerUndoCommandAddAttribute::QgsVectorLayerUndoCommandAddAttribute(), QgsLabel::readLabelField(), QgsAtlasComposition::readXML(), QgsComposerAttributeTable::resetColumns(), QgsFieldModel::rowCount(), QgsFieldModel::setAllowExpression(), QgsComposerAttributeTable::setDisplayAttributes(), QgsVectorLayer::setDisplayField(), QgsVectorLayer::setFieldEditable(), QgsFeature::setFields(), QgsVectorLayer::setLabelOnTop(), QgsAtlasComposition::setSortKeyAttributeIndex(), QgsProjectFileTransform::transform0110to1000(), QgsVectorLayerJoinBuffer::updateFields(), and QgsFieldModel::updateModel().
|
inline |
Return if a field index is valid.
i | Index of the field which needs to be checked |
Definition at line 201 of file qgsfield.h.
Referenced by QgsVectorLayerFeatureIterator::prepareJoins(), and QgsComposerAttributeTable::setDisplayAttributes().
void QgsFields::extend | ( | const QgsFields & | other | ) |
Extend with fields from another QgsFields container.
Definition at line 159 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 210 of file qgsfield.h.
Referenced by QgsTransectSample::createSample(), fieldNameIndex(), remove(), and QgsVectorLayerJoinBuffer::updateFields().
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 212 of file qgsfield.h.
int QgsFields::fieldNameIndex | ( | const QString & | fieldName | ) | const |
Look up field's index from name - case insensitive TODO: sort out case sensitive (indexFromName()) vs insensitive (fieldNameIndex()) calls.
Definition at line 175 of file qgsfield.cpp.
References count(), field(), mFields, and QgsField::name().
Referenced by QgsLegacyHelpers::convertEditType(), QgsVectorLayer::fieldNameIndex(), QgsFeatureRequest::setSubsetOfAttributes(), QgsPointDisplacementRenderer::startRender(), QgsVectorFieldSymbolLayer::startRender(), QgsGraduatedSymbolRendererV2::startRender(), and QgsCategorizedSymbolRendererV2::startRender().
|
inline |
Get field's origin (value from an enumeration)
Definition at line 215 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 217 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 220 of file qgsfield.h.
Referenced by QgsVectorLayerJoinBuffer::cacheJoinLayer(), QgsPalLayerSettings::dataDefinedValue(), QgsRelation::getRelatedFeaturesRequest(), QgsFieldModel::indexFromName(), QgsFieldModel::isField(), QgsRelationEditorWidget::on_mAddFeatureButton_clicked(), and QgsVectorLayerFeatureIterator::prepareJoins().
|
inline |
Check whether the container is empty.
Definition at line 193 of file qgsfield.h.
Referenced by QgsExpressionBuilderWidget::loadFieldNames().
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 204 of file qgsfield.h.
|
inline |
Get field at particular index (must be in range 0..N-1)
Definition at line 206 of file qgsfield.h.
void QgsFields::remove | ( | int | fieldIdx | ) |
Remove a field with the given index.
Definition at line 153 of file qgsfield.cpp.
References field(), mFields, mNameToIndex, and QgsField::name().
Referenced by QgsVectorLayerEditBuffer::updateFields(), and QgsFieldModel::updateModel().
|
inline |
Return number of items.
Definition at line 197 of file qgsfield.h.
Referenced by QgsVectorLayerEditBuffer::commitChanges(), QgsVectorLayer::metadata(), 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 167 of file qgsfield.cpp.
References mFields.
Referenced by QgsDualView::columnBoxInit(), QgsAttributeForm::createWrappers(), QgsGeometryAnalyzer::eventLayer(), QgsAttributeForm::init(), QgsRelationAddDlg::loadLayerAttributes(), and QgsFieldModel::updateModel().
|
protected |
internal storage of the container
Definition at line 236 of file qgsfield.h.
Referenced by allAttributesList(), append(), clear(), fieldNameIndex(), remove(), and toList().
|
protected |
map for quick resolution of name to index
Definition at line 239 of file qgsfield.h.