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 )
82 NotSearchable = 1 << 1,
86 Q_ENUM( ConfigurationFlag )
87 Q_DECLARE_FLAGS( ConfigurationFlags, ConfigurationFlag )
88 Q_FLAG( ConfigurationFlags )
106 QgsField(
const QString &name = QString(),
107 QVariant::Type type = QVariant::Invalid,
108 const QString &
typeName = QString(),
111 const QString &comment = QString(),
112 QVariant::Type subType = QVariant::Invalid );
134 QString name()
const;
143 QString displayName()
const;
156 QString displayNameWithAlias()
const;
167 QString displayType(
bool showConstraints =
false )
const;
170 QVariant::Type type()
const;
178 QVariant::Type subType()
const;
203 QString comment()
const;
211 bool isNumeric()
const;
218 bool isDateOrTime()
const;
224 void setName(
const QString &name );
229 void setType( QVariant::Type type );
237 void setSubType( QVariant::Type subType );
243 void setTypeName(
const QString &
typeName );
249 void setLength(
int len );
260 void setComment(
const QString &comment );
278 void setDefaultValueDefinition(
const QgsDefaultValue &defaultValueDefinition );
300 QString alias()
const;
308 void setAlias(
const QString &alias );
314 QgsField::ConfigurationFlags configurationFlags() const
SIP_SKIP;
320 void setConfigurationFlags(
QgsField::ConfigurationFlags configurationFlags )
SIP_SKIP;
323 QString displayString( const QVariant &v ) const;
341 bool convertCompatible( QVariant &v, QString *errorMessage =
nullptr )
const;
351 bool convertCompatible( QVariant &v )
const;
353 PyObject *sipParseErr = NULL;
360 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
363 QString errorMessage;
365 Py_BEGIN_ALLOW_THREADS
374 sipReleaseType( a0, sipType_QVariant, a0State );
375 sipRaiseUnknownException();
383 PyErr_SetString( PyExc_ValueError,
384 QString(
"Value could not be converted to field type %1: %2" ).arg(
QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
389 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
390 sipReleaseType( a0, sipType_QVariant, a0State );
397 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
407 operator QVariant()
const
409 return QVariant::fromValue( *
this );
434 void setReadOnly(
bool readOnly );
441 bool isReadOnly()
const;
444 SIP_PYOBJECT __repr__();
446 QString
str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
447 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
453 QSharedDataPointer<QgsFieldPrivate> d;
463 CORE_EXPORT QDataStream &operator<<( QDataStream &out, const
QgsField &
field );
465 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)