22 #include <QSharedDataPointer> 27 class QgsFieldPrivate;
28 class QgsFieldsPrivate;
48 Q_PROPERTY(
bool isNumeric READ isNumeric )
49 Q_PROPERTY(
int length READ length WRITE setLength )
50 Q_PROPERTY(
int precision READ precision WRITE setPrecision )
51 Q_PROPERTY(
QString comment READ comment WRITE setComment )
52 Q_PROPERTY(
QString name READ name WRITE setName )
53 Q_PROPERTY(
QString alias READ alias WRITE setAlias )
54 Q_PROPERTY(
QString defaultValueExpression READ defaultValueExpression WRITE setDefaultValueExpression )
70 const QString& typeName = QString(),
73 const QString& comment = QString() );
86 bool operator==( const QgsField& other ) const;
87 bool operator!=( const QgsField& other ) const;
101 QString displayName() const;
112 QString typeName() const;
124 int precision() const;
129 QString comment() const;
137 bool isNumeric() const;
143 void setName( const QString& name );
148 void setType(
QVariant::Type type );
154 void setTypeName( const QString& typeName );
160 void setLength(
int len );
166 void setPrecision(
int precision );
171 void setComment( const QString& comment );
179 QString defaultValueExpression() const;
187 void setDefaultValueExpression( const QString& expression );
194 QString alias() const;
201 void setAlias( const QString& alias );
204 QString displayString( const
QVariant& v ) const;
213 bool convertCompatible(
QVariant& v ) const;
267 Field(): origin( OriginUnknown ), originIndex( -1 ) {}
297 bool append(
const QgsField& field,
FieldOrigin origin = OriginProvider,
int originIndex = -1 );
299 bool appendExpressionField(
const QgsField& field,
int originIndex );
301 void remove(
int fieldIdx );
306 bool isEmpty()
const;
314 bool exists(
int i )
const;
317 const QgsField& operator[](
int i )
const;
323 const QgsField& field(
int fieldIdx )
const;
330 int fieldOriginIndex(
int fieldIdx )
const;
333 int indexFromName(
const QString& name )
const;
338 int fieldNameIndex(
const QString& fieldName )
const;
354 QIcon iconForField(
int fieldIdx )
const;
364 class const_iterator;
370 typedef std::random_access_iterator_tag iterator_category;
371 typedef qptrdiff difference_type;
382 inline QgsField& operator[]( difference_type j )
const {
return d[j].
field; }
383 inline bool operator==(
const iterator &o )
const noexcept {
return d == o.d; }
384 inline bool operator!=(
const iterator &o )
const noexcept {
return d != o.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; }
387 inline bool operator>(
const iterator& other )
const noexcept {
return d > other.d; }
388 inline bool operator>=(
const iterator& other )
const noexcept {
return d >= other.d; }
390 inline iterator& operator++() { ++d;
return *
this; }
391 inline iterator operator++(
int ) {
QgsFields::Field* n = d; ++d;
return n; }
392 inline iterator& operator--() { d--;
return *
this; }
393 inline iterator operator--(
int ) {
QgsFields::Field* n = d; d--;
return n; }
394 inline iterator& operator+=( difference_type j ) { d += j;
return *
this; }
395 inline iterator& operator-=( difference_type j ) { d -= j;
return *
this; }
396 inline iterator
operator+( difference_type j )
const {
return iterator( d + j ); }
397 inline iterator
operator-( difference_type j )
const {
return iterator( d -j ); }
398 inline int operator-( iterator j )
const {
return int( d - j.d ); }
400 friend class iterator;
407 typedef std::random_access_iterator_tag iterator_category;
408 typedef qptrdiff difference_type;
410 inline const_iterator()
414 inline const_iterator(
const const_iterator &o )
416 inline explicit const_iterator(
const iterator &o )
418 inline const QgsField& operator*()
const {
return d->
field; }
419 inline const QgsField* operator->()
const {
return &d->
field; }
420 inline const QgsField& operator[]( difference_type j )
const noexcept {
return d[j].
field; }
421 inline bool operator==(
const const_iterator &o )
const noexcept {
return d == o.d; }
422 inline bool operator!=(
const const_iterator &o )
const noexcept {
return d != o.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 bool operator>=(
const const_iterator& other )
const noexcept {
return d >= other.d; }
427 inline const_iterator& operator++() { ++d;
return *
this; }
428 inline const_iterator operator++(
int ) {
const QgsFields::Field* n = d; ++d;
return n; }
429 inline const_iterator& operator--() { d--;
return *
this; }
430 inline const_iterator operator--(
int ) {
const QgsFields::Field* n = d; --d;
return n; }
431 inline const_iterator& operator+=( difference_type j ) { d += j;
return *
this; }
432 inline const_iterator& operator-=( difference_type j ) { d -= j;
return *
this; }
433 inline const_iterator
operator+( difference_type j )
const {
return const_iterator( d + j ); }
434 inline const_iterator
operator-( difference_type j )
const {
return const_iterator( d -j ); }
435 inline int operator-( const_iterator j )
const {
return int( d - j.d ); }
437 friend class const_iterator;
447 const_iterator constBegin()
const noexcept;
455 const_iterator constEnd()
const noexcept;
463 const_iterator begin()
const noexcept;
471 const_iterator end()
const noexcept;
Class for parsing and evaluation of expressions (formerly called "search strings").
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)
Q_DECLARE_METATYPE(QgsMimeDataUtils::UriList)
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 QgsField &field)
Writes the field to stream out.
Encapsulate a field in an attribute table or data source.
QgsInterval operator-(const QDateTime &dt1, const QDateTime &dt2)
Returns the interval between two datetimes.
QVariant fromValue(const T &value)
QDateTime operator+(const QDateTime &start, const QgsInterval &interval)
Adds an interval to a datetime.
bool operator!=(const QgsFields &other) const
QList< int > QgsAttributeList
int originIndex
index specific to the origin
FieldOrigin origin
origin of the field
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsField &field)
Reads a field from stream in into field.