QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | List of all members
QgsFields Class Reference

Container of fields for a vector layer. More...

#include <qgsfield.h>

Classes

struct  Field
 

Public Types

typedef struct QgsFields::Field Field
 
enum  FieldOrigin {
  OriginUnknown, OriginProvider, OriginJoin, OriginEdit,
  OriginExpression
}
 

Public Member Functions

 QgsFields ()
 Constructor for an empty field container. More...
 
 QgsFields (const QgsFields &other)
 Copy constructor. More...
 
virtual ~QgsFields ()
 
QgsAttributeList allAttributesList () const
 Utility function to get list of attribute indexes. 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...
 
bool appendExpressionField (const QgsField &field, int originIndex)
 Append an expression field. The field must have unique name, otherwise it is rejected (returns false) More...
 
const QgsFieldat (int i) const
 Get field at particular index (must be in range 0..N-1) More...
 
void clear ()
 Remove all fields. More...
 
int count () const
 Return number of items. More...
 
bool exists (int i) const
 Return if a field index is valid. More...
 
void extend (const QgsFields &other)
 Extend with fields from another QgsFields container. More...
 
const QgsFieldfield (int fieldIdx) const
 Get field at particular index (must be in range 0..N-1) More...
 
const QgsFieldfield (const QString &name) const
 Get field at particular index (must be in range 0..N-1) 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...
 
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...
 
bool isEmpty () const
 Check whether the container is empty. More...
 
bool operator!= (const QgsFields &other) const
 
QgsFieldsoperator= (const QgsFields &other)
 Assignment operator. More...
 
bool operator== (const QgsFields &other) const
 
const QgsFieldoperator[] (int i) const
 Get field at particular index (must be in range 0..N-1) More...
 
QgsFieldoperator[] (int i)
 Get field at particular index (must be in range 0..N-1) More...
 
void remove (int fieldIdx)
 Remove a field with the given index. More...
 
int size () const
 Return number of items. More...
 
QList< QgsFieldtoList () const
 Utility function to return a list of QgsField instances. More...
 

Detailed Description

Container of fields for a vector layer.

In addition to storing a list of QgsField instances, it also:

Definition at line 177 of file qgsfield.h.

Member Typedef Documentation

Member Enumeration Documentation

Enumerator
OriginUnknown 

it has not been specified where the field comes from

OriginProvider 

field comes from the underlying data provider of the vector layer (originIndex = index in provider's fields)

OriginJoin 

field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index within the join)

OriginEdit 

field has been temporarily added in editing mode (originIndex = index in the list of added attributes)

OriginExpression 

field is calculated from an expression

Definition at line 181 of file qgsfield.h.

Constructor & Destructor Documentation

QgsFields::QgsFields ( )

Constructor for an empty field container.

Definition at line 208 of file qgsfield.cpp.

QgsFields::QgsFields ( const QgsFields other)

Copy constructor.

Definition at line 213 of file qgsfield.cpp.

QgsFields::~QgsFields ( )
virtual

Definition at line 224 of file qgsfield.cpp.

Member Function Documentation

QgsAttributeList QgsFields::allAttributesList ( ) const

Utility function to get list of attribute indexes.

Note
added in 2.4

Definition at line 368 of file qgsfield.cpp.

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 235 of file qgsfield.cpp.

bool QgsFields::appendExpressionField ( const QgsField field,
int  originIndex 
)

Append an expression field. The field must have unique name, otherwise it is rejected (returns false)

Definition at line 248 of file qgsfield.cpp.

const QgsField & QgsFields::at ( int  i) const

Get field at particular index (must be in range 0..N-1)

Definition at line 305 of file qgsfield.cpp.

void QgsFields::clear ( )

Remove all fields.

Definition at line 229 of file qgsfield.cpp.

int QgsFields::count ( ) const

Return number of items.

Definition at line 285 of file qgsfield.cpp.

bool QgsFields::exists ( int  i) const

Return if a field index is valid.

Parameters
iIndex of the field which needs to be checked
Returns
True if the field exists

Definition at line 295 of file qgsfield.cpp.

void QgsFields::extend ( const QgsFields other)

Extend with fields from another QgsFields container.

Definition at line 272 of file qgsfield.cpp.

const QgsField & QgsFields::field ( int  fieldIdx) const

Get field at particular index (must be in range 0..N-1)

Definition at line 310 of file qgsfield.cpp.

const QgsField & QgsFields::field ( const QString name) const

Get field at particular index (must be in range 0..N-1)

Definition at line 315 of file qgsfield.cpp.

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.

Note
added in 2.4

Definition at line 356 of file qgsfield.cpp.

QgsFields::FieldOrigin QgsFields::fieldOrigin ( int  fieldIdx) const

Get field's origin (value from an enumeration)

Definition at line 325 of file qgsfield.cpp.

int QgsFields::fieldOriginIndex ( int  fieldIdx) const

Get field's origin index (its meaning is specific to each type of origin)

Definition at line 333 of file qgsfield.cpp.

int QgsFields::indexFromName ( const QString name) const

Look up field's index from name. Returns -1 on error.

Definition at line 338 of file qgsfield.cpp.

bool QgsFields::isEmpty ( ) const

Check whether the container is empty.

Definition at line 280 of file qgsfield.cpp.

bool QgsFields::operator!= ( const QgsFields other) const
inline
Note
added in 2.6

Definition at line 275 of file qgsfield.h.

QgsFields & QgsFields::operator= ( const QgsFields other)

Assignment operator.

Definition at line 218 of file qgsfield.cpp.

bool QgsFields::operator== ( const QgsFields other) const
Note
added in 2.6

Definition at line 351 of file qgsfield.cpp.

const QgsField & QgsFields::operator[] ( int  i) const

Get field at particular index (must be in range 0..N-1)

Definition at line 320 of file qgsfield.cpp.

QgsField & QgsFields::operator[] ( int  i)

Get field at particular index (must be in range 0..N-1)

Definition at line 300 of file qgsfield.cpp.

void QgsFields::remove ( int  fieldIdx)

Remove a field with the given index.

Definition at line 259 of file qgsfield.cpp.

int QgsFields::size ( ) const

Return number of items.

Definition at line 290 of file qgsfield.cpp.

QList< QgsField > QgsFields::toList ( ) const

Utility function to return a list of QgsField instances.

Definition at line 343 of file qgsfield.cpp.


The documentation for this class was generated from the following files: