22 #include <QSharedDataPointer>
23 #include "qgis_core.h"
38 class QgsFieldPrivate;
53 Q_PROPERTY(
bool isNumeric READ isNumeric )
54 Q_PROPERTY(
bool isDateOrTime READ isDateOrTime )
55 Q_PROPERTY(
int length READ length WRITE setLength )
57 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
58 Q_PROPERTY( QString comment READ comment WRITE setComment )
59 Q_PROPERTY( QString name READ name WRITE setName )
60 Q_PROPERTY( QString alias READ alias WRITE setAlias )
61 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
81 QgsField( const QString &name = QString(),
82 QVariant::Type type = QVariant::Invalid,
86 const QString &comment = QString(),
87 QVariant::Type subType = QVariant::Invalid );
101 bool operator==( const
QgsField &other ) const;
102 bool operator!=( const
QgsField &other ) const;
109 QString name() const;
118 QString displayName() const;
131 QString displayNameWithAlias() const;
142 QString displayType(
bool showConstraints = false ) const;
145 QVariant::Type type() const;
153 QVariant::Type subType() const;
178 QString comment() const;
186 bool isNumeric() const;
193 bool isDateOrTime() const;
199 void setName( const QString &name );
204 void setType( QVariant::Type type );
212 void setSubType( QVariant::Type subType );
218 void setTypeName( const QString &
typeName );
224 void setLength(
int len );
235 void setComment( const QString &comment );
253 void setDefaultValueDefinition( const
QgsDefaultValue &defaultValueDefinition );
275 QString alias() const;
283 void setAlias( const QString &alias );
286 QString displayString( const QVariant &v ) const;
295 bool convertCompatible( QVariant &v ) const;
298 PyObject *sipParseErr = NULL;
305 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
309 Py_BEGIN_ALLOW_THREADS
318 sipReleaseType( a0, sipType_QVariant, a0State );
319 sipRaiseUnknownException();
325 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
326 sipReleaseType( a0, sipType_QVariant, a0State );
330 PyErr_SetString( PyExc_ValueError,
331 QString(
"Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->
type() ).toUtf8().constData() );
332 sipError = sipErrorFail;
340 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
347 operator QVariant()
const
349 return QVariant::fromValue( *
this );
370 SIP_PYOBJECT __repr__();
372 QString str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->typeName() );
373 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
379 QSharedDataPointer<QgsFieldPrivate> d;