21 #include "qgis_core.h" 24 class QgsFieldsPrivate;
75 int originIndex = -1 ;
101 bool append(
const QgsField &field,
FieldOrigin origin = OriginProvider,
int originIndex = -1 );
107 bool rename(
int fieldIdx,
const QString &name );
110 bool appendExpressionField(
const QgsField &field,
int originIndex );
113 void remove(
int fieldIdx );
116 if ( a0 < 0 || a0 >= sipCpp->count() )
118 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
123 sipCpp->remove( a0 );
132 bool isEmpty()
const;
140 sipRes = sipCpp->count();
144 int __bool__()
const;
157 QStringList names()
const;
164 bool exists(
int i )
const;
175 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
179 sipRes =
new QgsField( sipCpp->operator[]( idx ) );
187 if ( a0 < 0 || a0 >= sipCpp->count() )
189 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
194 sipRes =
new QgsField( sipCpp->at( a0 ) );
203 if ( a0 < 0 || a0 >= sipCpp->count() )
205 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
210 sipRes =
new QgsField( sipCpp->field( a0 ) );
219 int fieldIdx = sipCpp->indexFromName( *a0 );
220 if ( fieldIdx == -1 )
222 PyErr_SetString( PyExc_KeyError, a0->toAscii() );
227 sipRes =
new QgsField( sipCpp->field( *a0 ) );
236 if ( a0 < 0 || a0 >= sipCpp->count() )
238 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
243 sipRes = sipCpp->fieldOrigin( a0 );
249 int fieldOriginIndex(
int fieldIdx )
const;
252 if ( a0 < 0 || a0 >= sipCpp->count() )
254 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
259 sipRes = sipCpp->fieldOriginIndex( a0 );
275 int indexFromName(
const QString &fieldName )
const;
288 int indexOf(
const QString &fieldName )
const;
304 int lookupField(
const QString &fieldName )
const;
313 QList<QgsField> toList()
const;
324 QIcon iconForField(
int fieldIdx )
const SIP_FACTORY;
327 if ( a0 < 0 || a0 >= sipCpp->count() )
329 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
334 sipRes =
new QIcon( sipCpp->iconForField( a0 ) );
340 operator QVariant()
const 342 return QVariant::fromValue( *
this );
347 void __setitem__(
int key,
const QgsField &field );
349 int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
353 ( *sipCpp )[idx] = *a1;
362 class const_iterator;
368 typedef std::random_access_iterator_tag iterator_category;
369 typedef qptrdiff difference_type;
380 inline QgsField &operator[]( difference_type j )
const {
return d[j].
field; }
381 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
382 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.d; }
383 inline bool operator<(
const iterator &other )
const noexcept {
return d < other.d; }
384 inline bool operator<=(
const iterator &other )
const noexcept {
return d <= other.d; }
385 inline bool operator>(
const iterator &other )
const noexcept {
return d > other.d; }
386 inline bool operator>=(
const iterator &other )
const noexcept {
return d >= other.d; }
388 inline iterator &operator++() { ++d;
return *
this; }
389 inline iterator operator++(
int ) {
QgsFields::Field *n = d; ++d;
return n; }
390 inline iterator &operator--() { d--;
return *
this; }
391 inline iterator operator--(
int ) {
QgsFields::Field *n = d; d--;
return n; }
392 inline iterator &operator+=( difference_type j ) { d += j;
return *
this; }
393 inline iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
394 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
395 inline iterator
operator-( difference_type j )
const {
return iterator( d - j ); }
396 inline int operator-( iterator j )
const {
return int( d - j.d ); }
398 friend class iterator;
405 typedef std::random_access_iterator_tag iterator_category;
406 typedef qptrdiff difference_type;
408 inline const_iterator()
413 inline const_iterator(
const const_iterator &o )
415 inline explicit const_iterator(
const iterator &o )
418 inline const QgsField *operator->()
const {
return &d->
field; }
419 inline const QgsField &operator[]( difference_type j )
const noexcept {
return d[j].
field; }
420 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
421 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.d; }
422 inline bool operator<(
const const_iterator &other )
const noexcept {
return d < other.d; }
423 inline bool operator<=(
const const_iterator &other )
const noexcept {
return d <= other.d; }
424 inline bool operator>(
const const_iterator &other )
const noexcept {
return d > other.d; }
425 inline bool operator>=(
const const_iterator &other )
const noexcept {
return d >= other.d; }
426 inline const_iterator &operator++() { ++d;
return *
this; }
427 inline const_iterator operator++(
int ) {
const QgsFields::Field *n = d; ++d;
return n; }
428 inline const_iterator &operator--() { d--;
return *
this; }
429 inline const_iterator operator--(
int ) {
const QgsFields::Field *n = d; --d;
return n; }
430 inline const_iterator &operator+=( difference_type j ) { d += j;
return *
this; }
431 inline const_iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
432 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
433 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d - j ); }
434 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
436 friend class const_iterator;
446 const_iterator constBegin()
const noexcept;
454 const_iterator constEnd()
const noexcept;
462 const_iterator begin()
const noexcept;
470 const_iterator end()
const noexcept;
493 QSharedDataPointer<QgsFieldsPrivate> d;
504 #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 ...
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.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
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.