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 );
115 void remove(
int fieldIdx );
118 if ( a0 < 0 || a0 >= sipCpp->count() )
120 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
125 sipCpp->remove( a0 );
134 bool isEmpty()
const;
142 sipRes = sipCpp->count();
146 int __bool__()
const;
159 QStringList names()
const;
166 bool exists(
int i )
const;
177 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
181 sipRes =
new QgsField( sipCpp->operator[]( idx ) );
189 if ( a0 < 0 || a0 >= sipCpp->count() )
191 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
196 sipRes =
new QgsField( sipCpp->at( a0 ) );
205 if ( a0 < 0 || a0 >= sipCpp->count() )
207 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
212 sipRes =
new QgsField( sipCpp->field( a0 ) );
221 int fieldIdx = sipCpp->indexFromName( *a0 );
222 if ( fieldIdx == -1 )
224 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
229 sipRes =
new QgsField( sipCpp->field( *a0 ) );
235 FieldOrigin fieldOrigin(
int fieldIdx )
const;
238 if ( a0 < 0 || a0 >= sipCpp->count() )
240 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
245 sipRes = sipCpp->fieldOrigin( a0 );
251 int fieldOriginIndex(
int fieldIdx )
const;
254 if ( a0 < 0 || a0 >= sipCpp->count() )
256 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
261 sipRes = sipCpp->fieldOriginIndex( a0 );
277 int indexFromName(
const QString &fieldName )
const;
290 int indexOf(
const QString &fieldName )
const;
306 int lookupField(
const QString &fieldName )
const;
315 QList<QgsField> toList()
const;
328 QIcon iconForField(
int fieldIdx,
bool considerOrigin =
false ) const
SIP_FACTORY;
331 if ( a0 < 0 || a0 >= sipCpp->count() )
333 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
338 sipRes =
new QIcon( sipCpp->iconForField( a0 ) );
348 static QIcon iconForFieldType(
const QVariant::Type &type )
SIP_FACTORY;
351 operator QVariant()
const
353 return QVariant::fromValue( *
this );
360 int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
364 ( *sipCpp )[idx] = *a1;
373 class const_iterator;
379 typedef std::random_access_iterator_tag iterator_category;
380 typedef qptrdiff difference_type;
391 inline QgsField &operator[]( difference_type j )
const {
return d[j].
field; }
392 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
393 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.d; }
394 inline bool operator<(
const iterator &other )
const noexcept {
return d < other.d; }
395 inline bool operator<=(
const iterator &other )
const noexcept {
return d <= other.d; }
396 inline bool operator>(
const iterator &other )
const noexcept {
return d > other.d; }
397 inline bool operator>=(
const iterator &other )
const noexcept {
return d >= other.d; }
399 inline iterator &operator++() { ++d;
return *
this; }
400 inline iterator operator++(
int ) {
QgsFields::Field *n = d; ++d;
return n; }
401 inline iterator &operator--() { d--;
return *
this; }
402 inline iterator operator--(
int ) {
QgsFields::Field *n = d; d--;
return n; }
403 inline iterator &operator+=( difference_type j ) { d += j;
return *
this; }
404 inline iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
405 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
406 inline iterator
operator-( difference_type j )
const {
return iterator( d - j ); }
407 inline int operator-( iterator j )
const {
return int( d - j.d ); }
409 friend class iterator;
416 typedef std::random_access_iterator_tag iterator_category;
417 typedef qptrdiff difference_type;
419 inline const_iterator()
424 inline const_iterator(
const const_iterator &o )
426 inline explicit const_iterator(
const iterator &o )
429 inline const QgsField *operator->()
const {
return &d->
field; }
430 inline const QgsField &operator[]( difference_type j )
const noexcept {
return d[j].
field; }
431 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
432 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.d; }
433 inline bool operator<(
const const_iterator &other )
const noexcept {
return d < other.d; }
434 inline bool operator<=(
const const_iterator &other )
const noexcept {
return d <= other.d; }
435 inline bool operator>(
const const_iterator &other )
const noexcept {
return d > other.d; }
436 inline bool operator>=(
const const_iterator &other )
const noexcept {
return d >= other.d; }
437 inline const_iterator &operator++() { ++d;
return *
this; }
438 inline const_iterator operator++(
int ) {
const QgsFields::Field *n = d; ++d;
return n; }
439 inline const_iterator &operator--() { d--;
return *
this; }
440 inline const_iterator operator--(
int ) {
const QgsFields::Field *n = d; --d;
return n; }
441 inline const_iterator &operator+=( difference_type j ) { d += j;
return *
this; }
442 inline const_iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
443 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
444 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d - j ); }
445 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
447 const_iterator &operator= (
const const_iterator & ) =
delete;
449 friend class const_iterator;
459 const_iterator constBegin() const noexcept;
467 const_iterator constEnd() const noexcept;
475 const_iterator begin() const noexcept;
483 const_iterator end() const noexcept;
506 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 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.