22 #include <QSharedDataPointer>
23 #include "qgis_core.h"
38 class QgsFieldPrivate;
54 Q_PROPERTY(
bool isNumeric READ isNumeric )
55 Q_PROPERTY(
bool isDateOrTime READ isDateOrTime )
56 Q_PROPERTY(
int length READ length WRITE setLength )
58 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
59 Q_PROPERTY( QString comment READ comment WRITE setComment )
60 Q_PROPERTY( QString name READ name WRITE setName )
61 Q_PROPERTY( QString alias READ alias WRITE setAlias )
62 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
64 Q_PROPERTY( ConfigurationFlags configurationFlags READ configurationFlags WRITE setConfigurationFlags )
65 Q_PROPERTY(
bool isReadOnly READ isReadOnly WRITE setReadOnly )
79 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
86 NotSearchable = 1 << 1,
90 Q_ENUM( ConfigurationFlag )
91 Q_DECLARE_FLAGS( ConfigurationFlags, ConfigurationFlag )
92 #if QT_VERSION < QT_VERSION_CHECK(5, 12, 0)
94 Q_ENUM( ConfigurationFlags )
96 Q_FLAG( ConfigurationFlags )
115 QgsField(
const QString &name = QString(),
116 QVariant::Type type = QVariant::Invalid,
117 const QString &
typeName = QString(),
120 const QString &comment = QString(),
121 QVariant::Type subType = QVariant::Invalid );
143 QString name()
const;
152 QString displayName()
const;
165 QString displayNameWithAlias()
const;
176 QString displayType(
bool showConstraints =
false )
const;
179 QVariant::Type type()
const;
187 QVariant::Type subType()
const;
212 QString comment()
const;
220 bool isNumeric()
const;
227 bool isDateOrTime()
const;
233 void setName(
const QString &name );
238 void setType( QVariant::Type type );
246 void setSubType( QVariant::Type subType );
252 void setTypeName(
const QString &
typeName );
258 void setLength(
int len );
269 void setComment(
const QString &comment );
287 void setDefaultValueDefinition(
const QgsDefaultValue &defaultValueDefinition );
309 QString alias()
const;
317 void setAlias(
const QString &alias );
323 QgsField::ConfigurationFlags configurationFlags() const
SIP_SKIP;
329 void setConfigurationFlags(
QgsField::ConfigurationFlags configurationFlags )
SIP_SKIP;
332 QString displayString( const QVariant &v ) const;
350 bool convertCompatible( QVariant &v, QString *errorMessage =
nullptr )
const;
360 bool convertCompatible( QVariant &v )
const;
362 PyObject *sipParseErr = NULL;
369 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
372 QString errorMessage;
374 Py_BEGIN_ALLOW_THREADS
383 sipReleaseType( a0, sipType_QVariant, a0State );
384 sipRaiseUnknownException();
392 PyErr_SetString( PyExc_ValueError,
393 QString(
"Value could not be converted to field type %1: %2" ).arg(
QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
398 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
399 sipReleaseType( a0, sipType_QVariant, a0State );
406 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
416 operator QVariant()
const
418 return QVariant::fromValue( *
this );
443 void setReadOnly(
bool readOnly );
450 bool isReadOnly()
const;
453 SIP_PYOBJECT __repr__();
455 QString str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
456 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
462 QSharedDataPointer<QgsFieldPrivate> d;
472 CORE_EXPORT QDataStream &operator<<( QDataStream &out, const
QgsField &
field );
474 CORE_EXPORT QDataStream &operator>>( QDataStream &in,
QgsField &
field );
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...
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.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)