QGIS API Documentation
2.0.1-Dufour
|
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. | |
~QgsField () | |
Destructor. | |
bool | operator== (const QgsField &other) const |
bool | operator!= (const QgsField &other) const |
const QString & | name () const |
Gets the name of the field. | |
QVariant::Type | type () const |
Gets variant type of the field as it will be retrieved from data source. | |
const QString & | typeName () const |
Gets the field type. | |
int | length () const |
Gets the length of the field. | |
int | precision () const |
Gets the precision of the field. | |
const QString & | comment () const |
Returns the field comment. | |
void | setName (const QString &nam) |
Set the field name. | |
void | setType (QVariant::Type type) |
Set variant type. | |
void | setTypeName (const QString &typ) |
Set the field type. | |
void | setLength (int len) |
Set the field length. | |
void | setPrecision (int prec) |
Set the field precision. | |
void | setComment (const QString &comment) |
Set the field comment. | |
QString | displayString (const QVariant &v) const |
Formats string for display. |
Private Attributes | |
QString | mName |
Name. | |
QVariant::Type | mType |
Variant type. | |
QString | mTypeName |
Type name from provider. | |
int | mLength |
Length. | |
int | mPrecision |
Precision. | |
QString | mComment |
Comment. |
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 29 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 32 of file qgsfield.cpp.
QgsField::~QgsField | ( | ) |
Destructor.
Definition at line 39 of file qgsfield.cpp.
const QString & QgsField::comment | ( | ) | const |
Returns the field comment.
Definition at line 80 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 114 of file qgsfield.cpp.
References mPrecision, and mType.
Referenced by QgsAttributeTableModel::data(), and QgsAttributeEditor::setValue().
int QgsField::length | ( | ) | const |
Gets the length of the field.
Definition at line 70 of file qgsfield.cpp.
References mLength.
Referenced by 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 55 of file qgsfield.cpp.
References mName.
Referenced by QgsVectorLayerEditBuffer::addAttribute(), QgsFields::append(), QgsOfflineEditing::applyAttributesAdded(), QgsDualView::columnBoxInit(), QgsOverlayAnalyzer::combineFieldLists(), QgsVectorLayerEditBuffer::commitChanges(), QgsOfflineEditing::committedAttributesAdded(), QgsFeature::fieldNameIndex(), QgsAttributeTableModel::headerData(), QgsDataDefinedButton::init(), QgsVectorLayer::metadata(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsPalLayerSettings::readDataDefinedProperty(), QgsFields::remove(), and QgsVectorLayerJoinBuffer::updateFields().
bool QgsField::operator!= | ( | const QgsField & | other | ) | const |
Definition at line 49 of file qgsfield.cpp.
bool QgsField::operator== | ( | const QgsField & | other | ) | const |
Definition at line 43 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 75 of file qgsfield.cpp.
References mPrecision.
Referenced by QgsOfflineEditing::committedAttributesAdded(), QgsVectorLayer::metadata(), QgsFieldValidator::QgsFieldValidator(), QgsVectorFileWriter::QgsVectorFileWriter(), and QgsVectorDataProvider::supportedType().
void QgsField::setComment | ( | const QString & | comment | ) |
Set the field comment.
Definition at line 109 of file qgsfield.cpp.
void QgsField::setLength | ( | int | len | ) |
Set the field length.
len | Length of the field |
Definition at line 100 of file qgsfield.cpp.
References mLength.
void QgsField::setName | ( | const QString & | nam | ) |
Set the field name.
nam | Name of the field |
Definition at line 85 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 104 of file qgsfield.cpp.
References mPrecision.
void QgsField::setType | ( | QVariant::Type | type | ) |
Set variant type.
Definition at line 90 of file qgsfield.cpp.
Referenced by QgsGmlSchema::endElement().
void QgsField::setTypeName | ( | const QString & | typ | ) |
Set the field type.
typ | Field type |
Definition at line 95 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 60 of file qgsfield.cpp.
References mType.
Referenced by QgsOfflineEditing::applyAttributesAdded(), QgsOverlayAnalyzer::combineFieldLists(), QgsOfflineEditing::committedAttributesAdded(), QgsAttributeEditor::createAttributeEditor(), QgsAttributeTableModel::data(), QgsGmlSchema::endElement(), QgsFieldValidator::fixup(), QgsSearchQueryBuilder::getFieldValues(), QgsDataDefinedButton::init(), QgsAttributeDialog::QgsAttributeDialog(), QgsFieldValidator::QgsFieldValidator(), QgsVectorFileWriter::QgsVectorFileWriter(), QgsAttributeEditor::retrieveValue(), setType(), QgsAttributeEditor::setValue(), 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 65 of file qgsfield.cpp.
References mTypeName.
Referenced by QgsVectorLayer::metadata(), and setTypeName().
|
private |
|
private |
Length.
Definition at line 140 of file qgsfield.h.
Referenced by length(), operator==(), and setLength().
|
private |
|
private |
Precision.
Definition at line 143 of file qgsfield.h.
Referenced by displayString(), operator==(), precision(), and setPrecision().
|
private |
Variant type.
Definition at line 134 of file qgsfield.h.
Referenced by displayString(), operator==(), setType(), and type().
|
private |
Type name from provider.
Definition at line 137 of file qgsfield.h.
Referenced by setTypeName(), and typeName().