21 #include "qgis_core.h"
24 class QgsFieldsPrivate;
77 int originIndex = -1 ;
103 bool append(
const QgsField &
field, FieldOrigin origin = OriginProvider,
int originIndex = -1 );
109 bool rename(
int fieldIdx,
const QString &name );
112 bool appendExpressionField(
const QgsField &
field,
int originIndex );
119 void remove(
int fieldIdx );
127 void remove(
int fieldIdx );
129 if ( a0 < 0 || a0 >= sipCpp->count() )
131 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
136 sipCpp->remove( a0 );
145 bool isEmpty()
const;
153 sipRes = sipCpp->count();
157 int __bool__()
const;
170 QStringList names()
const;
177 bool exists(
int i )
const;
188 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
192 sipRes =
new QgsField( sipCpp->operator[]( idx ) );
210 if ( a0 < 0 || a0 >= sipCpp->count() )
212 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
217 sipRes =
new QgsField( sipCpp->at( a0 ) );
236 if ( a0 < 0 || a0 >= sipCpp->count() )
238 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
243 sipRes =
new QgsField( sipCpp->field( a0 ) );
262 int fieldIdx = sipCpp->indexFromName( *a0 );
263 if ( fieldIdx == -1 )
265 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
270 sipRes =
new QgsField( sipCpp->field( *a0 ) );
280 FieldOrigin fieldOrigin(
int fieldIdx )
const;
288 FieldOrigin fieldOrigin(
int fieldIdx )
const;
290 if ( a0 < 0 || a0 >= sipCpp->count() )
292 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
297 sipRes = sipCpp->fieldOrigin( a0 );
307 int fieldOriginIndex(
int fieldIdx )
const;
315 int fieldOriginIndex(
int fieldIdx )
const;
317 if ( a0 < 0 || a0 >= sipCpp->count() )
319 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
324 sipRes = sipCpp->fieldOriginIndex( a0 );
342 int indexFromName(
const QString &fieldName )
const;
356 int indexOf(
const QString &fieldName )
const;
372 int lookupField(
const QString &fieldName )
const;
381 QList<QgsField> toList()
const;
396 QIcon iconForField(
int fieldIdx,
bool considerOrigin =
false ) const
SIP_FACTORY;
406 QIcon iconForField(
int fieldIdx,
bool considerOrigin =
false ) const
SIP_FACTORY;
408 if ( a0 < 0 || a0 >= sipCpp->count() )
410 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
415 sipRes =
new QIcon( sipCpp->iconForField( a0 ) );
424 static QIcon iconForFieldType(
const QVariant::Type &type )
SIP_FACTORY;
427 operator QVariant()
const
429 return QVariant::fromValue( *
this );
436 int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
440 ( *sipCpp )[idx] = *a1;
449 class const_iterator;
455 typedef std::random_access_iterator_tag iterator_category;
456 typedef qptrdiff difference_type;
467 inline QgsField &operator[]( difference_type j )
const {
return d[j].
field; }
468 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
469 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.d; }
470 inline bool operator<(
const iterator &other )
const noexcept {
return d < other.d; }
471 inline bool operator<=(
const iterator &other )
const noexcept {
return d <= other.d; }
472 inline bool operator>(
const iterator &other )
const noexcept {
return d > other.d; }
473 inline bool operator>=(
const iterator &other )
const noexcept {
return d >= other.d; }
475 inline iterator &operator++() { ++d;
return *
this; }
476 inline iterator operator++(
int ) {
QgsFields::Field *n = d; ++d;
return n; }
477 inline iterator &operator--() { d--;
return *
this; }
478 inline iterator operator--(
int ) {
QgsFields::Field *n = d; d--;
return n; }
479 inline iterator &operator+=( difference_type j ) { d += j;
return *
this; }
480 inline iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
481 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
482 inline iterator
operator-( difference_type j )
const {
return iterator( d - j ); }
483 inline int operator-( iterator j )
const {
return int( d - j.d ); }
485 friend class iterator;
492 typedef std::random_access_iterator_tag iterator_category;
493 typedef qptrdiff difference_type;
495 inline const_iterator()
500 inline const_iterator(
const const_iterator &o )
502 inline explicit const_iterator(
const iterator &o )
505 inline const QgsField *operator->()
const {
return &d->
field; }
506 inline const QgsField &operator[]( difference_type j )
const noexcept {
return d[j].
field; }
507 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
508 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.d; }
509 inline bool operator<(
const const_iterator &other )
const noexcept {
return d < other.d; }
510 inline bool operator<=(
const const_iterator &other )
const noexcept {
return d <= other.d; }
511 inline bool operator>(
const const_iterator &other )
const noexcept {
return d > other.d; }
512 inline bool operator>=(
const const_iterator &other )
const noexcept {
return d >= other.d; }
513 inline const_iterator &operator++() { ++d;
return *
this; }
514 inline const_iterator operator++(
int ) {
const QgsFields::Field *n = d; ++d;
return n; }
515 inline const_iterator &operator--() { d--;
return *
this; }
516 inline const_iterator operator--(
int ) {
const QgsFields::Field *n = d; --d;
return n; }
517 inline const_iterator &operator+=( difference_type j ) { d += j;
return *
this; }
518 inline const_iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
519 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
520 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d - j ); }
521 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
523 const_iterator &operator= (
const const_iterator & ) =
delete;
525 friend class const_iterator;
535 const_iterator constBegin() const noexcept;
543 const_iterator constEnd() const noexcept;
551 const_iterator begin() const noexcept;
559 const_iterator end() const noexcept;
582 QSharedDataPointer<QgsFieldsPrivate> d;
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
bool operator!=(const QgsFields &other) const
@ OriginEdit
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
@ OriginUnknown
It has not been specified where the field comes from.
@ OriginJoin
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
@ OriginProvider
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
bool operator>(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is greater than the second.
bool operator<(const QVariant &v1, const QVariant &v2)
Compares two QVariant values and returns whether the first is less than the second.
bool operator>=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
bool operator<=(const QgsCoordinateReferenceSystem &c1, const QgsCoordinateReferenceSystem &c2)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QList< int > QgsAttributeList
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsFields &fields)
Writes the fields to stream out. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsFields &fields)
Reads fields from stream in into fields. QGIS version compatibility is not guaranteed.
QgsInterval operator-(const QDateTime &dt1, const QDateTime &dt2)
Returns the interval between two datetimes.
QDateTime operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
QgsMargins operator*(const QgsMargins &margins, double factor)
Returns a QgsMargins object that is formed by multiplying each component of the given margins by fact...
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
int originIndex
Index specific to the origin.
bool operator==(const Field &other) const
bool operator!=(const Field &other) const
Field(const QgsField &f, FieldOrigin o, int oi)
FieldOrigin origin
Origin of the field.