21 #include "qgis_core.h" 24 class QgsFieldsPrivate;
75 int originIndex = -1 ;
101 bool append(
const QgsField &field,
FieldOrigin origin = OriginProvider,
int originIndex = -1 );
104 bool appendExpressionField(
const QgsField &field,
int originIndex );
107 void remove(
int fieldIdx );
110 if ( a0 < 0 || a0 >= sipCpp->count() )
112 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
117 sipCpp->remove( a0 );
126 bool isEmpty()
const;
134 sipRes = sipCpp->count();
145 QStringList names()
const;
152 bool exists(
int i )
const;
163 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
167 sipRes =
new QgsField( sipCpp->operator[]( idx ) );
175 if ( a0 < 0 || a0 >= sipCpp->count() )
177 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
182 sipRes =
new QgsField( sipCpp->at( a0 ) );
191 if ( a0 < 0 || a0 >= sipCpp->count() )
193 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
198 sipRes =
new QgsField( sipCpp->field( a0 ) );
207 int fieldIdx = sipCpp->indexFromName( *a0 );
208 if ( fieldIdx == -1 )
210 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
215 sipRes =
new QgsField( sipCpp->field( *a0 ) );
224 if ( a0 < 0 || a0 >= sipCpp->count() )
226 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
231 sipRes = sipCpp->fieldOrigin( a0 );
237 int fieldOriginIndex(
int fieldIdx )
const;
240 if ( a0 < 0 || a0 >= sipCpp->count() )
242 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
247 sipRes = sipCpp->fieldOriginIndex( a0 );
263 int indexFromName(
const QString &fieldName )
const;
276 int indexOf(
const QString &fieldName )
const;
292 int lookupField(
const QString &fieldName )
const;
301 QList<QgsField> toList()
const;
312 QIcon iconForField(
int fieldIdx )
const SIP_FACTORY;
315 if ( a0 < 0 || a0 >= sipCpp->count() )
317 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
322 sipRes =
new QIcon( sipCpp->iconForField( a0 ) );
328 operator QVariant()
const 330 return QVariant::fromValue( *
this );
335 void __setitem__(
int key,
const QgsField &field );
337 int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
341 ( *sipCpp )[idx] = *a1;
350 class const_iterator;
356 typedef std::random_access_iterator_tag iterator_category;
357 typedef qptrdiff difference_type;
368 inline QgsField &operator[]( difference_type j )
const {
return d[j].
field; }
369 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
370 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.d; }
371 inline bool operator<(
const iterator &other )
const noexcept {
return d < other.d; }
372 inline bool operator<=(
const iterator &other )
const noexcept {
return d <= other.d; }
373 inline bool operator>(
const iterator &other )
const noexcept {
return d > other.d; }
374 inline bool operator>=(
const iterator &other )
const noexcept {
return d >= other.d; }
376 inline iterator &operator++() { ++d;
return *
this; }
377 inline iterator operator++(
int ) {
QgsFields::Field *n = d; ++d;
return n; }
378 inline iterator &operator--() { d--;
return *
this; }
379 inline iterator operator--(
int ) {
QgsFields::Field *n = d; d--;
return n; }
380 inline iterator &operator+=( difference_type j ) { d += j;
return *
this; }
381 inline iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
382 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
383 inline iterator
operator-( difference_type j )
const {
return iterator( d - j ); }
384 inline int operator-( iterator j )
const {
return int( d - j.d ); }
386 friend class iterator;
393 typedef std::random_access_iterator_tag iterator_category;
394 typedef qptrdiff difference_type;
396 inline const_iterator()
401 inline const_iterator(
const const_iterator &o )
403 inline explicit const_iterator(
const iterator &o )
406 inline const QgsField *operator->()
const {
return &d->
field; }
407 inline const QgsField &operator[]( difference_type j )
const noexcept {
return d[j].
field; }
408 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
409 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.d; }
410 inline bool operator<(
const const_iterator &other )
const noexcept {
return d < other.d; }
411 inline bool operator<=(
const const_iterator &other )
const noexcept {
return d <= other.d; }
412 inline bool operator>(
const const_iterator &other )
const noexcept {
return d > other.d; }
413 inline bool operator>=(
const const_iterator &other )
const noexcept {
return d >= other.d; }
414 inline const_iterator &operator++() { ++d;
return *
this; }
415 inline const_iterator operator++(
int ) {
const QgsFields::Field *n = d; ++d;
return n; }
416 inline const_iterator &operator--() { d--;
return *
this; }
417 inline const_iterator operator--(
int ) {
const QgsFields::Field *n = d; --d;
return n; }
418 inline const_iterator &operator+=( difference_type j ) { d += j;
return *
this; }
419 inline const_iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
420 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
421 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d - j ); }
422 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
424 friend class const_iterator;
434 const_iterator constBegin()
const noexcept;
442 const_iterator constEnd()
const noexcept;
450 const_iterator begin()
const noexcept;
458 const_iterator end()
const noexcept;
481 QSharedDataPointer<QgsFieldsPrivate> d;
492 #endif // QGSFIELDS_H
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Container of fields for a vector layer.
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
Q_DECLARE_METATYPE(QModelIndex)
bool operator!=(const Field &other) const
It has not been specified where the field comes from.
bool operator==(const Field &other) const
Field(const QgsField &f, FieldOrigin o, int oi)
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsFields &fields)
Writes the fields to stream out. QGIS version compatibility is not guaranteed.
QDateTime operator+(const QDateTime &start, QgsInterval interval)
Encapsulate a field in an attribute table or data source.
QgsInterval operator-(const QDateTime &dt1, const QDateTime &dt2)
Returns the interval between two datetimes.
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsFields &fields)
Reads fields from stream in into fields. QGIS version compatibility is not guaranteed.
bool operator!=(const QgsFields &other) const
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
QList< int > QgsAttributeList
int originIndex
Index specific to the origin.
FieldOrigin origin
Origin of the field.