22#include <QSharedDataPointer>
56 Q_PROPERTY(
bool isNumeric READ isNumeric )
57 Q_PROPERTY(
bool isDateOrTime READ isDateOrTime )
58 Q_PROPERTY(
int length READ length WRITE setLength )
60 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
61 Q_PROPERTY( QString comment READ comment WRITE setComment )
62 Q_PROPERTY( QString name READ name WRITE setName )
63 Q_PROPERTY( QString alias READ alias WRITE setAlias )
64 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
66 Q_PROPERTY( ConfigurationFlags configurationFlags READ configurationFlags WRITE setConfigurationFlags )
67 Q_PROPERTY(
bool isReadOnly READ isReadOnly WRITE setReadOnly )
84 NotSearchable = 1 << 1,
88 Q_ENUM( ConfigurationFlag )
89 Q_DECLARE_FLAGS( ConfigurationFlags, ConfigurationFlag )
90 Q_FLAG( ConfigurationFlags )
108 QgsField(
const QString &name = QString(),
109 QVariant::Type type = QVariant::Invalid,
110 const QString &
typeName = QString(),
113 const QString &comment = QString(),
114 QVariant::Type subType = QVariant::Invalid );
136 QString name()
const;
145 QString displayName()
const;
158 QString displayNameWithAlias()
const;
170 QString displayType(
bool showConstraints =
false )
const;
182 QString friendlyTypeString()
const;
185 QVariant::Type type()
const;
193 QVariant::Type subType()
const;
218 QString comment()
const;
228 QMap< int, QVariant > metadata()
const;
244 QVariant metadata(
int property )
const;
254 void setMetadata(
const QMap< int, QVariant > metadata );
270 void setMetadata(
int property,
const QVariant &value );
278 bool isNumeric()
const;
285 bool isDateOrTime()
const;
291 void setName(
const QString &name );
296 void setType( QVariant::Type type );
304 void setSubType( QVariant::Type subType );
310 void setTypeName(
const QString &
typeName );
316 void setLength(
int len );
327 void setComment(
const QString &comment );
345 void setDefaultValueDefinition(
const QgsDefaultValue &defaultValueDefinition );
367 QString alias()
const;
375 void setAlias(
const QString &alias );
381 QgsField::ConfigurationFlags configurationFlags() const
SIP_SKIP;
387 void setConfigurationFlags(
QgsField::ConfigurationFlags configurationFlags )
SIP_SKIP;
390 QString displayString( const QVariant &v ) const;
408 bool convertCompatible( QVariant &v, QString *errorMessage =
nullptr )
const;
418 bool convertCompatible( QVariant &v )
const;
420 PyObject *sipParseErr = NULL;
427 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
430 QString errorMessage;
432 Py_BEGIN_ALLOW_THREADS
441 sipReleaseType( a0, sipType_QVariant, a0State );
442 sipRaiseUnknownException();
450 PyErr_SetString( PyExc_ValueError,
451 QString(
"Value could not be converted to field type %1: %2" ).arg(
QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
456 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
457 sipReleaseType( a0, sipType_QVariant, a0State );
464 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
474 operator QVariant()
const
476 return QVariant::fromValue( *
this );
501 void setReadOnly(
bool readOnly );
508 bool isReadOnly()
const;
531 SIP_PYOBJECT __repr__();
533 QString
str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
534 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
539 static constexpr int MAX_WKT_LENGTH = 999;
544 QSharedDataPointer<QgsFieldPrivate> d;
554CORE_EXPORT QDataStream &operator<<( QDataStream &out, const
QgsField &
field );
556CORE_EXPORT QDataStream &operator>>( QDataStream &in,
QgsField &
field );
FieldDomainSplitPolicy
Split policy for field domains.
FieldMetadataProperty
Standard field metadata values.
The QgsDefaultValue class provides a container for managing client side default values for fields.
Stores information about constraints which may be present on a field.
Encapsulate a field in an attribute table or data source.
QString typeName() const
Gets the field type.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
ConfigurationFlag
Configuration flags for fields These flags are meant to be user-configurable and are not describing a...
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QList< int > QgsAttributeList
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.