21 #include "qgis_core.h"
24 class QgsFieldsPrivate;
79 int originIndex = -1 ;
111 bool rename(
int fieldIdx,
const QString &name );
114 bool appendExpressionField(
const QgsField &
field,
int originIndex );
121 void remove(
int fieldIdx );
129 void remove(
int fieldIdx );
131 if ( a0 < 0 || a0 >= sipCpp->count() )
133 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
138 sipCpp->remove( a0 );
147 bool isEmpty()
const;
155 sipRes = sipCpp->count();
159 int __bool__()
const;
172 QStringList names()
const;
179 bool exists(
int i )
const;
190 SIP_SSIZE_T idx = sipConvertFromSequenceIndex( a0, sipCpp->count() );
194 sipRes =
new QgsField( sipCpp->operator[]( idx ) );
201 const int fieldIdx = sipCpp->lookupField( *a0 );
202 if ( fieldIdx == -1 )
204 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
209 sipRes = sipConvertFromType(
new QgsField( sipCpp->at( fieldIdx ) ), sipType_QgsField, Py_None );
228 if ( a0 < 0 || a0 >= sipCpp->count() )
230 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
235 sipRes =
new QgsField( sipCpp->at( a0 ) );
254 if ( a0 < 0 || a0 >= sipCpp->count() )
256 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
261 sipRes =
new QgsField( sipCpp->field( a0 ) );
280 int fieldIdx = sipCpp->indexFromName( *a0 );
281 if ( fieldIdx == -1 )
283 PyErr_SetString( PyExc_KeyError, a0->toLatin1() );
288 sipRes =
new QgsField( sipCpp->field( *a0 ) );
298 FieldOrigin fieldOrigin(
int fieldIdx )
const;
306 FieldOrigin fieldOrigin(
int fieldIdx )
const;
308 if ( a0 < 0 || a0 >= sipCpp->count() )
310 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
315 sipRes = sipCpp->fieldOrigin( a0 );
325 int fieldOriginIndex(
int fieldIdx )
const;
333 int fieldOriginIndex(
int fieldIdx )
const;
335 if ( a0 < 0 || a0 >= sipCpp->count() )
337 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
342 sipRes = sipCpp->fieldOriginIndex( a0 );
360 int indexFromName(
const QString &fieldName )
const;
374 int indexOf(
const QString &fieldName )
const;
390 int lookupField(
const QString &fieldName )
const;
399 QList<QgsField> toList()
const;
414 QIcon iconForField(
int fieldIdx,
bool considerOrigin =
false ) const
SIP_FACTORY;
424 QIcon iconForField(
int fieldIdx,
bool considerOrigin =
false ) const
SIP_FACTORY;
426 if ( a0 < 0 || a0 >= sipCpp->count() )
428 PyErr_SetString( PyExc_KeyError, QByteArray::number( a0 ) );
433 sipRes =
new QIcon( sipCpp->iconForField( a0 ) );
445 static QIcon iconForFieldType( QVariant::Type type, QVariant::Type subType = QVariant::Type::Invalid );
448 operator QVariant()
const
450 return QVariant::fromValue( *
this );
457 int idx = ( int )sipConvertFromSequenceIndex( a0, sipCpp->count() );
461 ( *sipCpp )[idx] = *a1;
470 class const_iterator;
476 typedef std::random_access_iterator_tag iterator_category;
477 typedef qptrdiff difference_type;
488 inline QgsField &operator[]( difference_type j )
const {
return d[j].
field; }
489 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
490 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.d; }
491 inline bool operator<(
const iterator &other )
const noexcept {
return d < other.d; }
492 inline bool operator<=(
const iterator &other )
const noexcept {
return d <= other.d; }
493 inline bool operator>(
const iterator &other )
const noexcept {
return d > other.d; }
494 inline bool operator>=(
const iterator &other )
const noexcept {
return d >= other.d; }
496 inline iterator &operator++() { ++d;
return *
this; }
497 inline iterator operator++(
int ) {
QgsFields::Field *n = d; ++d;
return n; }
498 inline iterator &operator--() { d--;
return *
this; }
499 inline iterator operator--(
int ) {
QgsFields::Field *n = d; d--;
return n; }
500 inline iterator &operator+=( difference_type j ) { d += j;
return *
this; }
501 inline iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
502 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
503 inline iterator
operator-( difference_type j )
const {
return iterator( d - j ); }
504 inline int operator-( iterator j )
const {
return int( d - j.d ); }
506 friend class iterator;
513 typedef std::random_access_iterator_tag iterator_category;
514 typedef qptrdiff difference_type;
516 inline const_iterator()
521 inline const_iterator(
const const_iterator &o )
523 inline explicit const_iterator(
const iterator &o )
526 inline const QgsField *operator->()
const {
return &d->
field; }
527 inline const QgsField &operator[]( difference_type j )
const noexcept {
return d[j].
field; }
528 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
529 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.d; }
530 inline bool operator<(
const const_iterator &other )
const noexcept {
return d < other.d; }
531 inline bool operator<=(
const const_iterator &other )
const noexcept {
return d <= other.d; }
532 inline bool operator>(
const const_iterator &other )
const noexcept {
return d > other.d; }
533 inline bool operator>=(
const const_iterator &other )
const noexcept {
return d >= other.d; }
534 inline const_iterator &operator++() { ++d;
return *
this; }
535 inline const_iterator operator++(
int ) {
const QgsFields::Field *n = d; ++d;
return n; }
536 inline const_iterator &operator--() { d--;
return *
this; }
537 inline const_iterator operator--(
int ) {
const QgsFields::Field *n = d; --d;
return n; }
538 inline const_iterator &operator+=( difference_type j ) { d += j;
return *
this; }
539 inline const_iterator &operator-=( difference_type j ) { d -= j;
return *
this; }
540 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
541 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d - j ); }
542 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
544 const_iterator &operator= (
const const_iterator & ) =
delete;
546 friend class const_iterator;
556 const_iterator constBegin() const noexcept;
564 const_iterator constEnd() const noexcept;
572 const_iterator begin() const noexcept;
580 const_iterator end() const noexcept;
603 QSharedDataPointer<QgsFieldsPrivate> d;
614 #endif // QGSFIELDS_H