22 #include <QSharedDataPointer> 24 #include "qgis_core.h" 52 Q_PROPERTY(
bool isNumeric READ isNumeric )
53 Q_PROPERTY(
int length READ length WRITE setLength )
55 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
56 Q_PROPERTY( QString comment READ comment WRITE setComment )
57 Q_PROPERTY( QString name READ name WRITE setName )
58 Q_PROPERTY( QString alias READ alias WRITE setAlias )
59 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
79 QgsField( const QString &name = QString(),
80 QVariant::Type type = QVariant::Invalid,
84 const QString &comment = QString(),
85 QVariant::Type subType = QVariant::Invalid );
99 bool operator==( const
QgsField &other ) const;
100 bool operator!=( const
QgsField &other ) const;
107 QString name() const;
116 QString displayName() const;
119 QVariant::Type type() const;
127 QVariant::Type subType() const;
152 QString comment() const;
160 bool isNumeric() const;
166 void setName( const QString &name );
171 void setType( QVariant::Type type );
179 void setSubType( QVariant::Type subType );
185 void setTypeName( const QString &
typeName );
191 void setLength(
int len );
202 void setComment( const QString &comment );
220 void setDefaultValueDefinition( const
QgsDefaultValue &defaultValueDefinition );
242 QString alias() const;
250 void setAlias( const QString &alias );
253 QString displayString( const QVariant &v ) const;
262 bool convertCompatible( QVariant &v ) const;
265 PyObject *sipParseErr = NULL;
272 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
276 Py_BEGIN_ALLOW_THREADS
287 sipReleaseType( a0, sipType_QVariant, a0State );
288 sipRaiseUnknownException();
294 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
295 sipReleaseType( a0, sipType_QVariant, a0State );
299 PyErr_SetString( PyExc_ValueError,
300 QString(
"Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->
type() ).toUtf8().constData() );
301 sipError = sipErrorFail;
309 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
316 operator QVariant()
const 318 return QVariant::fromValue( *
this );
339 SIP_PYOBJECT __repr__();
341 QString str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->typeName() );
342 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
348 QSharedDataPointer<QgsFieldPrivate> d;
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.
Q_DECLARE_METATYPE(QModelIndex)
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsField &field)
Writes the field to stream out. QGIS version compatibility is not guaranteed.
Encapsulate a field in an attribute table or data source.
bool convertCompatible(QVariant &v) const
Converts the provided variant to a compatible format.
QList< int > QgsAttributeList
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsField &field)
Reads a field from stream in into field. QGIS version compatibility is not guaranteed.