QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
qgsfield.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfield.cpp - Describes a field in a layer or table
3  --------------------------------------
4  Date : 01-Jan-2004
5  Copyright : (C) 2004 by Gary E.Sherman
6  email : sherman at mrcc.com
7 
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsfields.h"
18 #include "qgsfield_p.h"
19 #include "qgis.h"
20 #include "qgsapplication.h"
21 #include "qgssettings.h"
22 
23 #include <QDataStream>
24 #include <QIcon>
25 #include <QLocale>
26 #include <QJsonDocument>
27 
28 /***************************************************************************
29  * This class is considered CRITICAL and any change MUST be accompanied with
30  * full unit tests in testqgsfield.cpp.
31  * See details in QEP #17
32  ****************************************************************************/
33 
34 #if 0
35 QgsField::QgsField( QString nam, QString typ, int len, int prec, bool num,
36  QString comment )
37  : mName( nam ), mType( typ ), mLength( len ), mPrecision( prec ), mNumeric( num )
38  , mComment( comment )
39 {
40  // This function used to lower case the field name since some stores
41  // use upper case (e.g., shapefiles), but that caused problems with
42  // attribute actions getting confused between uppercase and
43  // lowercase versions of the attribute names, so just leave the
44  // names how they are now.
45 }
46 #endif
47 QgsField::QgsField( const QString &name, QVariant::Type type,
48  const QString &typeName, int len, int prec, const QString &comment, QVariant::Type subType )
49 {
50  d = new QgsFieldPrivate( name, type, subType, typeName, len, prec, comment );
51 }
52 
53 QgsField::QgsField( const QgsField &other ) //NOLINT
54  : d( other.d )
55 {
56 
57 }
58 
59 QgsField::~QgsField() = default;
60 
61 /***************************************************************************
62  * This class is considered CRITICAL and any change MUST be accompanied with
63  * full unit tests in testqgsfield.cpp.
64  * See details in QEP #17
65  ****************************************************************************/
66 
67 QgsField &QgsField::operator =( const QgsField &other ) //NOLINT
68 {
69  d = other.d;
70  return *this;
71 }
72 
73 bool QgsField::operator==( const QgsField &other ) const
74 {
75  return *( other.d ) == *d;
76 }
77 
78 bool QgsField::operator!=( const QgsField &other ) const
79 {
80  return !( *this == other );
81 }
82 
83 QString QgsField::name() const
84 {
85  return d->name;
86 }
87 
88 QString QgsField::displayName() const
89 {
90  if ( !d->alias.isEmpty() )
91  return d->alias;
92  else
93  return d->name;
94 }
95 
97 {
98  if ( alias().isEmpty() )
99  {
100  return name();
101  }
102  return QStringLiteral( "%1 (%2)" ).arg( name() ).arg( alias() );
103 }
104 
105 QString QgsField::displayType( const bool showConstraints ) const
106 {
107  QString typeStr = typeName();
108 
109  if ( length() > 0 && precision() > 0 )
110  typeStr += QStringLiteral( "(%1, %2)" ).arg( length() ).arg( precision() );
111  else if ( length() > 0 )
112  typeStr += QStringLiteral( "(%1)" ).arg( length() );
113 
114  if ( showConstraints )
115  {
117  ? QStringLiteral( " NOT NULL" )
118  : QStringLiteral( " NULL" );
119 
121  ? QStringLiteral( " UNIQUE" )
122  : QString();
123  }
124 
125  return typeStr;
126 }
127 
128 QVariant::Type QgsField::type() const
129 {
130  return d->type;
131 }
132 
133 QVariant::Type QgsField::subType() const
134 {
135  return d->subType;
136 }
137 
138 QString QgsField::typeName() const
139 {
140  return d->typeName;
141 }
142 
143 int QgsField::length() const
144 {
145  return d->length;
146 }
147 
149 {
150  return d->precision;
151 }
152 
153 QString QgsField::comment() const
154 {
155  return d->comment;
156 }
157 
159 {
160  return d->type == QVariant::Double || d->type == QVariant::Int || d->type == QVariant::UInt || d->type == QVariant::LongLong || d->type == QVariant::ULongLong;
161 }
162 
164 {
165  return d->type == QVariant::Date || d->type == QVariant::Time || d->type == QVariant::DateTime;
166 }
167 
168 /***************************************************************************
169  * This class is considered CRITICAL and any change MUST be accompanied with
170  * full unit tests in testqgsfield.cpp.
171  * See details in QEP #17
172  ****************************************************************************/
173 
174 void QgsField::setName( const QString &name )
175 {
176  d->name = name;
177 }
178 
179 void QgsField::setType( QVariant::Type type )
180 {
181  d->type = type;
182 }
183 
184 void QgsField::setSubType( QVariant::Type subType )
185 {
186  d->subType = subType;
187 }
188 
189 void QgsField::setTypeName( const QString &typeName )
190 {
191  d->typeName = typeName;
192 }
193 
194 void QgsField::setLength( int len )
195 {
196  d->length = len;
197 }
199 {
200  d->precision = precision;
201 }
202 
203 void QgsField::setComment( const QString &comment )
204 {
205  d->comment = comment;
206 }
207 
209 {
210  return d->defaultValueDefinition;
211 }
212 
213 void QgsField::setDefaultValueDefinition( const QgsDefaultValue &defaultValueDefinition )
214 {
215  d->defaultValueDefinition = defaultValueDefinition;
216 }
217 
219 {
220  d->constraints = constraints;
221 }
222 
224 {
225  return d->constraints;
226 }
227 
228 QString QgsField::alias() const
229 {
230  return d->alias;
231 }
232 
233 void QgsField::setAlias( const QString &alias )
234 {
235  d->alias = alias;
236 }
237 
238 QgsField::ConfigurationFlags QgsField::configurationFlags() const
239 {
240  return d->flags;
241 }
242 
243 void QgsField::setConfigurationFlags( QgsField::ConfigurationFlags flags )
244 {
245  d->flags = flags;
246 }
247 
248 /***************************************************************************
249  * This class is considered CRITICAL and any change MUST be accompanied with
250  * full unit tests in testqgsfield.cpp.
251  * See details in QEP #17
252  ****************************************************************************/
253 
254 QString QgsField::displayString( const QVariant &v ) const
255 {
256  if ( v.isNull() )
257  {
259  }
260 
261  // Special treatment for numeric types if group separator is set or decimalPoint is not a dot
262  if ( d->type == QVariant::Double )
263  {
264  // if value doesn't contain a double (a default value expression for instance),
265  // apply no transformation
266  bool ok;
267  v.toDouble( &ok );
268  if ( !ok )
269  return v.toString();
270 
271  // Locales with decimal point != '.' or that require group separator: use QLocale
272  if ( QLocale().decimalPoint() != '.' ||
273  !( QLocale().numberOptions() & QLocale::NumberOption::OmitGroupSeparator ) )
274  {
275  if ( d->precision > 0 )
276  {
277  if ( -1 < v.toDouble() && v.toDouble() < 1 )
278  {
279  return QLocale().toString( v.toDouble(), 'g', d->precision );
280  }
281  else
282  {
283  return QLocale().toString( v.toDouble(), 'f', d->precision );
284  }
285  }
286  else
287  {
288  // Precision is not set, let's guess it from the
289  // standard conversion to string
290  QString s( v.toString() );
291  int dotPosition( s.indexOf( '.' ) );
292  int precision;
293  if ( dotPosition < 0 && s.indexOf( 'e' ) < 0 )
294  {
295  precision = 0;
296  return QLocale().toString( v.toDouble(), 'f', precision );
297  }
298  else
299  {
300  if ( dotPosition < 0 ) precision = 0;
301  else precision = s.length() - dotPosition - 1;
302 
303  if ( -1 < v.toDouble() && v.toDouble() < 1 )
304  {
305  return QLocale().toString( v.toDouble(), 'g', precision );
306  }
307  else
308  {
309  return QLocale().toString( v.toDouble(), 'f', precision );
310  }
311  }
312  }
313  }
314  // Default for doubles with precision
315  else if ( d->type == QVariant::Double && d->precision > 0 )
316  {
317  if ( -1 < v.toDouble() && v.toDouble() < 1 )
318  {
319  return QString::number( v.toDouble(), 'g', d->precision );
320  }
321  else
322  {
323  return QString::number( v.toDouble(), 'f', d->precision );
324  }
325  }
326  }
327  // Other numeric types than doubles
328  else if ( isNumeric() &&
329  !( QLocale().numberOptions() & QLocale::NumberOption::OmitGroupSeparator ) )
330  {
331  bool ok;
332  qlonglong converted( v.toLongLong( &ok ) );
333  if ( ok )
334  return QLocale().toString( converted );
335  }
336  else if ( d->typeName.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 || d->typeName == QLatin1String( "jsonb" ) )
337  {
338  QJsonDocument doc = QJsonDocument::fromVariant( v );
339  return QString::fromUtf8( doc.toJson().data() );
340  }
341  else if ( d->type == QVariant::ByteArray )
342  {
343  return QObject::tr( "BLOB" );
344  }
345  // Fallback if special rules do not apply
346  return v.toString();
347 }
348 
350 {
351  switch ( flag )
352  {
354  return QObject::tr( "None" );
356  return QObject::tr( "Not searchable" );
358  return QStringLiteral( "Do not expose via WMS" );
360  return QStringLiteral( "Do not expose via WFS" );
361  }
362  return QString();
363 }
364 
365 /***************************************************************************
366  * This class is considered CRITICAL and any change MUST be accompanied with
367  * full unit tests in testqgsfield.cpp.
368  * See details in QEP #17
369  ****************************************************************************/
370 
371 bool QgsField::convertCompatible( QVariant &v, QString *errorMessage ) const
372 {
373  const QVariant original = v;
374  if ( errorMessage )
375  errorMessage->clear();
376 
377  if ( v.isNull() )
378  {
379  v.convert( d->type );
380  return true;
381  }
382 
383  if ( d->type == QVariant::Int && v.toInt() != v.toLongLong() )
384  {
385  v = QVariant( d->type );
386  if ( errorMessage )
387  *errorMessage = QObject::tr( "Value \"%1\" is too large for integer field" ).arg( original.toLongLong() );
388  return false;
389  }
390 
391  // Give it a chance to convert to double since for not '.' locales
392  // we accept both comma and dot as decimal point
393  if ( d->type == QVariant::Double && v.type() == QVariant::String )
394  {
395  QVariant tmp( v );
396  if ( !tmp.convert( d->type ) )
397  {
398  // This might be a string with thousand separator: use locale to convert
399  bool ok = false;
400  double d = qgsPermissiveToDouble( v.toString(), ok );
401  if ( ok )
402  {
403  v = QVariant( d );
404  return true;
405  }
406  // For not 'dot' locales, we also want to accept '.'
407  if ( QLocale().decimalPoint() != '.' )
408  {
409  d = QLocale( QLocale::C ).toDouble( v.toString(), &ok );
410  if ( ok )
411  {
412  v = QVariant( d );
413  return true;
414  }
415  }
416  }
417  }
418 
419  // For string representation of an int we also might have thousand separator
420  if ( d->type == QVariant::Int && v.type() == QVariant::String )
421  {
422  QVariant tmp( v );
423  if ( !tmp.convert( d->type ) )
424  {
425  // This might be a string with thousand separator: use locale to convert
426  bool ok;
427  int i = qgsPermissiveToInt( v.toString(), ok );
428  if ( ok )
429  {
430  v = QVariant( i );
431  return true;
432  }
433  }
434  }
435 
436  // For string representation of a long we also might have thousand separator
437  if ( d->type == QVariant::LongLong && v.type() == QVariant::String )
438  {
439  QVariant tmp( v );
440  if ( !tmp.convert( d->type ) )
441  {
442  // This might be a string with thousand separator: use locale to convert
443  bool ok;
444  qlonglong l = qgsPermissiveToLongLong( v.toString(), ok );
445  if ( ok )
446  {
447  v = QVariant( l );
448  return true;
449  }
450  }
451  }
452 
453  //String representations of doubles in QVariant will return false to convert( QVariant::Int )
454  //work around this by first converting to double, and then checking whether the double is convertible to int
455  if ( d->type == QVariant::Int && v.canConvert( QVariant::Double ) )
456  {
457  bool ok = false;
458  double dbl = v.toDouble( &ok );
459  if ( !ok )
460  {
461  //couldn't convert to number
462  v = QVariant( d->type );
463 
464  if ( errorMessage )
465  *errorMessage = QObject::tr( "Value \"%1\" is not a number" ).arg( original.toString() );
466 
467  return false;
468  }
469 
470  double round = std::round( dbl );
471  if ( round > std::numeric_limits<int>::max() || round < -std::numeric_limits<int>::max() )
472  {
473  //double too large to fit in int
474  v = QVariant( d->type );
475 
476  if ( errorMessage )
477  *errorMessage = QObject::tr( "Value \"%1\" is too large for integer field" ).arg( original.toDouble() );
478 
479  return false;
480  }
481  v = QVariant( static_cast< int >( std::round( dbl ) ) );
482  return true;
483  }
484 
485  //String representations of doubles in QVariant will return false to convert( QVariant::LongLong )
486  //work around this by first converting to double, and then checking whether the double is convertible to longlong
487  if ( d->type == QVariant::LongLong && v.canConvert( QVariant::Double ) )
488  {
489  //firstly test the conversion to longlong because conversion to double will rounded the value
490  QVariant tmp( v );
491  if ( !tmp.convert( d->type ) )
492  {
493  bool ok = false;
494  double dbl = v.toDouble( &ok );
495  if ( !ok )
496  {
497  //couldn't convert to number
498  v = QVariant( d->type );
499 
500  if ( errorMessage )
501  *errorMessage = QObject::tr( "Value \"%1\" is not a number" ).arg( original.toString() );
502 
503  return false;
504  }
505 
506  double round = std::round( dbl );
507  if ( round > static_cast<double>( std::numeric_limits<long long>::max() ) || round < static_cast<double>( -std::numeric_limits<long long>::max() ) )
508  {
509  //double too large to fit in longlong
510  v = QVariant( d->type );
511 
512  if ( errorMessage )
513  *errorMessage = QObject::tr( "Value \"%1\" is too large for long long field" ).arg( original.toDouble() );
514 
515  return false;
516  }
517  v = QVariant( static_cast< long long >( std::round( dbl ) ) );
518  return true;
519  }
520  }
521 
522  if ( !v.convert( d->type ) )
523  {
524  v = QVariant( d->type );
525 
526  if ( errorMessage )
527  *errorMessage = QObject::tr( "Could not convert value \"%1\" to target type" ).arg( original.toString() );
528 
529  return false;
530  }
531 
532  if ( d->type == QVariant::Double && d->precision > 0 )
533  {
534  double s = std::pow( 10, d->precision );
535  double d = v.toDouble() * s;
536  v = QVariant( ( d < 0 ? std::ceil( d - 0.5 ) : std::floor( d + 0.5 ) ) / s );
537  return true;
538  }
539 
540  if ( d->type == QVariant::String && d->length > 0 && v.toString().length() > d->length )
541  {
542  const int length = v.toString().length();
543  v = v.toString().left( d->length );
544 
545  if ( errorMessage )
546  *errorMessage = QObject::tr( "String of length %1 exceeds maximum field length (%2)" ).arg( length ).arg( d->length );
547 
548  return false;
549  }
550 
551  return true;
552 }
553 
555 {
556  d->editorWidgetSetup = v;
557 }
558 
560 {
561  return d->editorWidgetSetup;
562 }
563 
564 void QgsField::setReadOnly( bool readOnly )
565 {
566  d->isReadOnly = readOnly;
567 }
568 
570 {
571  return d->isReadOnly;
572 }
573 
574 
575 /***************************************************************************
576  * This class is considered CRITICAL and any change MUST be accompanied with
577  * full unit tests in testqgsfield.cpp.
578  * See details in QEP #17
579  ****************************************************************************/
580 
581 QDataStream &operator<<( QDataStream &out, const QgsField &field )
582 {
583  out << field.name();
584  out << static_cast< quint32 >( field.type() );
585  out << field.typeName();
586  out << field.length();
587  out << field.precision();
588  out << field.comment();
589  out << field.alias();
592  out << field.constraints().constraints();
593  out << static_cast< quint32 >( field.constraints().constraintOrigin( QgsFieldConstraints::ConstraintNotNull ) );
594  out << static_cast< quint32 >( field.constraints().constraintOrigin( QgsFieldConstraints::ConstraintUnique ) );
595  out << static_cast< quint32 >( field.constraints().constraintOrigin( QgsFieldConstraints::ConstraintExpression ) );
596  out << static_cast< quint32 >( field.constraints().constraintStrength( QgsFieldConstraints::ConstraintNotNull ) );
597  out << static_cast< quint32 >( field.constraints().constraintStrength( QgsFieldConstraints::ConstraintUnique ) );
601  out << static_cast< quint32 >( field.subType() );
602  return out;
603 }
604 
605 QDataStream &operator>>( QDataStream &in, QgsField &field )
606 {
607  quint32 type;
608  quint32 subType;
609  quint32 length;
610  quint32 precision;
611  quint32 constraints;
612  quint32 originNotNull;
613  quint32 originUnique;
614  quint32 originExpression;
615  quint32 strengthNotNull;
616  quint32 strengthUnique;
617  quint32 strengthExpression;
618 
619  bool applyOnUpdate;
620 
621  QString name;
622  QString typeName;
623  QString comment;
624  QString alias;
625  QString defaultValueExpression;
626  QString constraintExpression;
627  QString constraintDescription;
628 
629  in >> name >> type >> typeName >> length >> precision >> comment >> alias
630  >> defaultValueExpression >> applyOnUpdate >> constraints >> originNotNull >> originUnique >> originExpression >> strengthNotNull >> strengthUnique >> strengthExpression >>
631  constraintExpression >> constraintDescription >> subType;
632  field.setName( name );
633  field.setType( static_cast< QVariant::Type >( type ) );
635  field.setLength( static_cast< int >( length ) );
636  field.setPrecision( static_cast< int >( precision ) );
637  field.setComment( comment );
638  field.setAlias( alias );
639  field.setDefaultValueDefinition( QgsDefaultValue( defaultValueExpression, applyOnUpdate ) );
640  QgsFieldConstraints fieldConstraints;
641  if ( constraints & QgsFieldConstraints::ConstraintNotNull )
642  {
643  fieldConstraints.setConstraint( QgsFieldConstraints::ConstraintNotNull, static_cast< QgsFieldConstraints::ConstraintOrigin>( originNotNull ) );
645  }
646  else
648  if ( constraints & QgsFieldConstraints::ConstraintUnique )
649  {
650  fieldConstraints.setConstraint( QgsFieldConstraints::ConstraintUnique, static_cast< QgsFieldConstraints::ConstraintOrigin>( originUnique ) );
652  }
653  else
655  if ( constraints & QgsFieldConstraints::ConstraintExpression )
656  {
657  fieldConstraints.setConstraint( QgsFieldConstraints::ConstraintExpression, static_cast< QgsFieldConstraints::ConstraintOrigin>( originExpression ) );
659  }
660  else
662  fieldConstraints.setConstraintExpression( constraintExpression, constraintDescription );
663  field.setConstraints( fieldConstraints );
664  field.setSubType( static_cast< QVariant::Type >( subType ) );
665  return in;
666 }
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
The QgsDefaultValue class provides a container for managing client side default values for fields.
Q_GADGET QString expression
Holder for the widget type and its configuration for a field.
Stores information about constraints which may be present on a field.
ConstraintStrength
Strength of constraints.
void setConstraintStrength(Constraint constraint, ConstraintStrength strength)
Sets the strength of a constraint.
void setConstraintExpression(const QString &expression, const QString &description=QString())
Set the constraint expression for the field.
ConstraintOrigin
Origin of constraints.
ConstraintStrength constraintStrength(Constraint constraint) const
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not pres...
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
QString constraintExpression() const
Returns the constraint expression for the field, if set.
@ ConstraintNotNull
Field may not be null.
@ ConstraintUnique
Field must have a unique value.
@ ConstraintExpression
Field has an expression constraint set. See constraintExpression().
void removeConstraint(Constraint constraint)
Removes a constraint from the field.
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
Q_GADGET Constraints constraints
void setConstraint(Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer)
Sets a constraint on the field.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:51
bool isDateOrTime
Definition: qgsfield.h:55
void setEditorWidgetSetup(const QgsEditorWidgetSetup &v)
Set the editor widget setup for the field.
Definition: qgsfield.cpp:554
QString typeName() const
Gets the field type.
Definition: qgsfield.cpp:138
void setConstraints(const QgsFieldConstraints &constraints)
Sets constraints which are present for the field.
Definition: qgsfield.cpp:218
void setAlias(const QString &alias)
Sets the alias for the field (the friendly displayed name of the field ).
Definition: qgsfield.cpp:233
QString name
Definition: qgsfield.h:60
bool operator!=(const QgsField &other) const
Definition: qgsfield.cpp:78
bool operator==(const QgsField &other) const
Definition: qgsfield.cpp:73
int precision
Definition: qgsfield.h:57
static QString readableConfigurationFlag(QgsField::ConfigurationFlag flag)
Returns the reabable and translated value of the configuration flag.
Definition: qgsfield.cpp:349
int length
Definition: qgsfield.h:56
QgsField & operator=(const QgsField &other)
Assignment operator.
Definition: qgsfield.cpp:67
QString displayString(const QVariant &v) const
Formats string for display.
Definition: qgsfield.cpp:254
void setPrecision(int precision)
Set the field precision.
Definition: qgsfield.cpp:198
QString displayNameWithAlias() const
Returns the name to use when displaying this field and adds the alias in parenthesis if it is defined...
Definition: qgsfield.cpp:96
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
Definition: qgsfield.cpp:371
void setName(const QString &name)
Set the field name.
Definition: qgsfield.cpp:174
void setComment(const QString &comment)
Set the field comment.
Definition: qgsfield.cpp:203
QString displayType(bool showConstraints=false) const
Returns the type to use when displaying this field, including the length and precision of the datatyp...
Definition: qgsfield.cpp:105
void setLength(int len)
Set the field length.
Definition: qgsfield.cpp:194
void setConfigurationFlags(QgsField::ConfigurationFlags configurationFlags)
Sets the Flags for the field (searchable, …)
Definition: qgsfield.cpp:243
QString displayName() const
Returns the name to use when displaying this field.
Definition: qgsfield.cpp:88
void setDefaultValueDefinition(const QgsDefaultValue &defaultValueDefinition)
Sets an expression to use when calculating the default value for the field.
Definition: qgsfield.cpp:213
Q_GADGET bool isNumeric
Definition: qgsfield.h:54
ConfigurationFlags configurationFlags
Definition: qgsfield.h:64
void setReadOnly(bool readOnly)
Make field read-only if readOnly is set to true.
Definition: qgsfield.cpp:564
QVariant::Type type
Definition: qgsfield.h:58
QVariant::Type subType() const
If the field is a collection, gets its element's type.
Definition: qgsfield.cpp:133
QString alias
Definition: qgsfield.h:61
QgsField(const QString &name=QString(), QVariant::Type type=QVariant::Invalid, const QString &typeName=QString(), int len=0, int prec=0, const QString &comment=QString(), QVariant::Type subType=QVariant::Invalid)
Constructor.
Definition: qgsfield.cpp:47
QgsDefaultValue defaultValueDefinition
Definition: qgsfield.h:62
void setSubType(QVariant::Type subType)
If the field is a collection, set its element's type.
Definition: qgsfield.cpp:184
void setType(QVariant::Type type)
Set variant type.
Definition: qgsfield.cpp:179
QString comment
Definition: qgsfield.h:59
virtual ~QgsField()
QgsFieldConstraints constraints
Definition: qgsfield.h:63
ConfigurationFlag
Configuration flags for fields These flags are meant to be user-configurable and are not describing a...
Definition: qgsfield.h:84
@ HideFromWfs
Fields is available if layer is served as WFS from QGIS server.
@ NotSearchable
Defines if the field is searchable (used in the locator search for instance)
@ None
No flag is defined.
@ HideFromWms
Fields is available if layer is served as WMS from QGIS server.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Definition: qgsfield.cpp:559
bool isReadOnly
Definition: qgsfield.h:65
void setTypeName(const QString &typeName)
Set the field type.
Definition: qgsfield.cpp:189
qlonglong qgsPermissiveToLongLong(QString string, bool &ok)
Converts a string to an qlonglong in a permissive way, e.g., allowing for incorrect numbers of digits...
Definition: qgis.cpp:79
double qgsPermissiveToDouble(QString string, bool &ok)
Converts a string to a double in a permissive way, e.g., allowing for incorrect numbers of digits bet...
Definition: qgis.cpp:65
int qgsPermissiveToInt(QString string, bool &ok)
Converts a string to an integer in a permissive way, e.g., allowing for incorrect numbers of digits b...
Definition: qgis.cpp:72
QDataStream & operator>>(QDataStream &in, QgsField &field)
Reads a field from stream in into field. QGIS version compatibility is not guaranteed.
Definition: qgsfield.cpp:605
QDataStream & operator<<(QDataStream &out, const QgsField &field)
Definition: qgsfield.cpp:581
const QgsField & field
Definition: qgsfield.h:472
const QString & typeName
int precision