QGIS API Documentation
2.4.0-Chugiak
|
Encapsulate a field in an attribute table or data source. More...
#include <qgsfield.h>
Public Member Functions | |
QgsField (QString name=QString(), QVariant::Type type=QVariant::Invalid, QString typeName=QString(), int len=0, int prec=0, QString comment=QString()) | |
Constructor. More... | |
~QgsField () | |
Destructor. More... | |
bool | operator== (const QgsField &other) const |
bool | operator!= (const QgsField &other) const |
const QString & | name () const |
Gets the name of the field. More... | |
QVariant::Type | type () const |
Gets variant type of the field as it will be retrieved from data source. More... | |
const QString & | typeName () const |
Gets the field type. More... | |
int | length () const |
Gets the length of the field. More... | |
int | precision () const |
Gets the precision of the field. More... | |
const QString & | comment () const |
Returns the field comment. More... | |
void | setName (const QString &nam) |
Set the field name. More... | |
void | setType (QVariant::Type type) |
Set variant type. More... | |
void | setTypeName (const QString &typ) |
Set the field type. More... | |
void | setLength (int len) |
Set the field length. More... | |
void | setPrecision (int prec) |
Set the field precision. More... | |
void | setComment (const QString &comment) |
Set the field comment. More... | |
QString | displayString (const QVariant &v) const |
Formats string for display. More... | |
Private Attributes | |
QString | mName |
Name. More... | |
QVariant::Type | mType |
Variant type. More... | |
QString | mTypeName |
Type name from provider. More... | |
int | mLength |
Length. More... | |
int | mPrecision |
Precision. More... | |
QString | mComment |
Comment. More... | |
Encapsulate a field in an attribute table or data source.
QgsField stores metadata about an attribute field, including name, type length, and if applicable, precision.
Definition at line 31 of file qgsfield.h.
QgsField::QgsField | ( | QString | name = QString() , |
QVariant::Type | type = QVariant::Invalid , |
||
QString | typeName = QString() , |
||
int | len = 0 , |
||
int | prec = 0 , |
||
QString | comment = QString() |
||
) |
Constructor.
Constructs a new QgsField object.
name | Field name |
type | Field variant type, currently supported: String / Int / Double |
typeName | Field type (eg. char, varchar, text, int, serial, double). Field types are usually unique to the source and are stored exactly as returned from the data store. |
len | Field length |
prec | Field precision. Usually decimal places but may also be used in conjunction with other fields types (eg. variable character fields) |
comment | Comment for the field |
Definition at line 35 of file qgsfield.cpp.
QgsField::~QgsField | ( | ) |
Destructor.
Definition at line 42 of file qgsfield.cpp.
const QString & QgsField::comment | ( | ) | const |
Returns the field comment.
Definition at line 83 of file qgsfield.cpp.
References mComment.
Referenced by QgsOfflineEditing::committedAttributesAdded(), QgsVectorLayer::metadata(), and setComment().
QString QgsField::displayString | ( | const QVariant & | v | ) | const |
Formats string for display.
Definition at line 117 of file qgsfield.cpp.
References mPrecision, and mType.
int QgsField::length | ( | ) | const |
Gets the length of the field.
Definition at line 73 of file qgsfield.cpp.
References mLength.
Referenced by QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::committedAttributesAdded(), QgsFieldValidator::fixup(), QgsVectorLayer::metadata(), QgsFieldValidator::QgsFieldValidator(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsVectorDataProvider::supportedType(), and QgsFieldValidator::validate().
const QString & QgsField::name | ( | ) | const |
Gets the name of the field.
Definition at line 58 of file qgsfield.cpp.
References mName.
Referenced by QgsVectorLayerEditBuffer::addAttribute(), QgsFields::append(), QgsOfflineEditing::applyAttributesAdded(), QgsDualView::columnBoxInit(), QgsOverlayAnalyzer::combineFieldLists(), QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::committedAttributesAdded(), QgsAttributeForm::createWrappers(), QgsFieldModel::data(), QgsFields::fieldNameIndex(), QgsFeature::fieldNameIndex(), QgsAttributeTableModel::headerData(), QgsDataDefinedButton::init(), QgsAttributeForm::init(), QgsRelationAddDlg::loadLayerAttributes(), QgsVectorLayer::metadata(), QgsVectorLayerRenderer::prepareDiagrams(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsPalLayerSettings::readDataDefinedProperty(), QgsFields::remove(), QgsVectorDataProvider::supportedType(), QgsVectorLayerJoinBuffer::updateFields(), and QgsVectorLayer::writeSymbology().
bool QgsField::operator!= | ( | const QgsField & | other | ) | const |
Definition at line 52 of file qgsfield.cpp.
bool QgsField::operator== | ( | const QgsField & | other | ) | const |
Definition at line 46 of file qgsfield.cpp.
References mLength, mName, mPrecision, and mType.
int QgsField::precision | ( | ) | const |
Gets the precision of the field.
Not all field types have a related precision.
Definition at line 78 of file qgsfield.cpp.
References mPrecision.
Referenced by QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::committedAttributesAdded(), QgsVectorLayer::metadata(), QgsFieldValidator::QgsFieldValidator(), QgsVectorFileWriter::QgsVectorFileWriter(), and QgsVectorDataProvider::supportedType().
void QgsField::setComment | ( | const QString & | comment | ) |
Set the field comment.
Definition at line 112 of file qgsfield.cpp.
void QgsField::setLength | ( | int | len | ) |
Set the field length.
len | Length of the field |
Definition at line 103 of file qgsfield.cpp.
References mLength.
void QgsField::setName | ( | const QString & | nam | ) |
Set the field name.
nam | Name of the field |
Definition at line 88 of file qgsfield.cpp.
References mName.
Referenced by QgsVectorLayerJoinBuffer::updateFields().
void QgsField::setPrecision | ( | int | prec | ) |
Set the field precision.
prec | Precision of the field |
Definition at line 107 of file qgsfield.cpp.
References mPrecision.
void QgsField::setType | ( | QVariant::Type | type | ) |
Set variant type.
Definition at line 93 of file qgsfield.cpp.
Referenced by QgsGmlSchema::addAttribute().
void QgsField::setTypeName | ( | const QString & | typ | ) |
Set the field type.
typ | Field type |
Definition at line 98 of file qgsfield.cpp.
References mTypeName, and typeName().
Referenced by QgsOfflineEditing::applyAttributesAdded().
QVariant::Type QgsField::type | ( | ) | const |
Gets variant type of the field as it will be retrieved from data source.
Definition at line 63 of file qgsfield.cpp.
References mType.
Referenced by QgsGmlSchema::addAttribute(), QgsOfflineEditing::applyAttributesAdded(), QgsOverlayAnalyzer::combineFieldLists(), QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::committedAttributesAdded(), QgsTransectSample::createSample(), QgsAttributeTableModel::data(), QgsFieldModel::data(), QgsFieldValidator::fixup(), QgsSearchQueryBuilder::getFieldValues(), QgsRelation::getRelatedFeaturesRequest(), QgsDataDefinedButton::init(), QgsFieldValidator::QgsFieldValidator(), QgsVectorFileWriter::QgsVectorFileWriter(), setType(), QgsVectorDataProvider::supportedType(), and QgsFieldValidator::validate().
const QString & QgsField::typeName | ( | ) | const |
Gets the field type.
Field types vary depending on the data source. Examples are char, int, double, blob, geometry, etc. The type is stored exactly as the data store reports it, with no attenpt to standardize the value.
Definition at line 68 of file qgsfield.cpp.
References mTypeName.
Referenced by QgsVectorLayerEditBuffer::commitChanges(), QgsVectorLayer::metadata(), and setTypeName().
|
private |
|
private |
Length.
Definition at line 142 of file qgsfield.h.
Referenced by length(), operator==(), and setLength().
|
private |
|
private |
Precision.
Definition at line 145 of file qgsfield.h.
Referenced by displayString(), operator==(), precision(), and setPrecision().
|
private |
Variant type.
Definition at line 136 of file qgsfield.h.
Referenced by displayString(), operator==(), setType(), and type().
|
private |
Type name from provider.
Definition at line 139 of file qgsfield.h.
Referenced by setTypeName(), and typeName().