22#include <QSharedDataPointer>
55 Q_PROPERTY(
bool isNumeric READ isNumeric )
56 Q_PROPERTY(
bool isDateOrTime READ isDateOrTime )
57 Q_PROPERTY(
int length READ length WRITE setLength )
59 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
60 Q_PROPERTY( QString comment READ comment WRITE setComment )
61 Q_PROPERTY( QString name READ name WRITE setName )
62 Q_PROPERTY( QString alias READ alias WRITE setAlias )
63 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
65 Q_PROPERTY( ConfigurationFlags configurationFlags READ configurationFlags WRITE setConfigurationFlags )
66 Q_PROPERTY(
bool isReadOnly READ isReadOnly WRITE setReadOnly )
83 NotSearchable = 1 << 1,
87 Q_ENUM( ConfigurationFlag )
88 Q_DECLARE_FLAGS( ConfigurationFlags, ConfigurationFlag )
89 Q_FLAG( ConfigurationFlags )
107 QgsField(
const QString &name = QString(),
108 QVariant::Type type = QVariant::Invalid,
109 const QString &
typeName = QString(),
112 const QString &comment = QString(),
113 QVariant::Type subType = QVariant::Invalid );
135 QString name()
const;
144 QString displayName()
const;
157 QString displayNameWithAlias()
const;
169 QString displayType(
bool showConstraints =
false )
const;
181 QString friendlyTypeString()
const;
184 QVariant::Type type()
const;
192 QVariant::Type subType()
const;
217 QString comment()
const;
225 bool isNumeric()
const;
232 bool isDateOrTime()
const;
238 void setName(
const QString &name );
243 void setType( QVariant::Type type );
251 void setSubType( QVariant::Type subType );
257 void setTypeName(
const QString &
typeName );
263 void setLength(
int len );
274 void setComment(
const QString &comment );
292 void setDefaultValueDefinition(
const QgsDefaultValue &defaultValueDefinition );
314 QString alias()
const;
322 void setAlias(
const QString &alias );
328 QgsField::ConfigurationFlags configurationFlags() const
SIP_SKIP;
334 void setConfigurationFlags(
QgsField::ConfigurationFlags configurationFlags )
SIP_SKIP;
337 QString displayString( const QVariant &v ) const;
355 bool convertCompatible( QVariant &v, QString *errorMessage =
nullptr )
const;
365 bool convertCompatible( QVariant &v )
const;
367 PyObject *sipParseErr = NULL;
374 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
377 QString errorMessage;
379 Py_BEGIN_ALLOW_THREADS
388 sipReleaseType( a0, sipType_QVariant, a0State );
389 sipRaiseUnknownException();
397 PyErr_SetString( PyExc_ValueError,
398 QString(
"Value could not be converted to field type %1: %2" ).arg(
QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
403 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
404 sipReleaseType( a0, sipType_QVariant, a0State );
411 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
421 operator QVariant()
const
423 return QVariant::fromValue( *
this );
448 void setReadOnly(
bool readOnly );
455 bool isReadOnly()
const;
478 SIP_PYOBJECT __repr__();
480 QString
str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
481 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
486 static constexpr int MAX_WKT_LENGTH = 999;
491 QSharedDataPointer<QgsFieldPrivate> d;
501CORE_EXPORT QDataStream &operator<<( QDataStream &out, const
QgsField &
field );
503CORE_EXPORT QDataStream &operator>>( QDataStream &in,
QgsField &
field );
FieldDomainSplitPolicy
Split policy for field domains.
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.