22 #include <QSharedDataPointer> 24 #include "qgis_core.h" 52 Q_PROPERTY(
bool isNumeric READ isNumeric )
53 Q_PROPERTY(
bool isDateOrTime READ isDateOrTime )
54 Q_PROPERTY(
int length READ length WRITE setLength )
56 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
57 Q_PROPERTY( QString comment READ comment WRITE setComment )
58 Q_PROPERTY( QString name READ name WRITE setName )
59 Q_PROPERTY( QString alias READ alias WRITE setAlias )
60 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
80 QgsField( const QString &name = QString(),
81 QVariant::Type type = QVariant::Invalid,
85 const QString &comment = QString(),
86 QVariant::Type subType = QVariant::Invalid );
100 bool operator==( const
QgsField &other ) const;
101 bool operator!=( const
QgsField &other ) const;
108 QString name() const;
117 QString displayName() const;
120 QVariant::Type type() const;
128 QVariant::Type subType() const;
153 QString comment() const;
161 bool isNumeric() const;
168 bool isDateOrTime() const;
174 void setName( const QString &name );
179 void setType( QVariant::Type type );
187 void setSubType( QVariant::Type subType );
193 void setTypeName( const QString &
typeName );
199 void setLength(
int len );
210 void setComment( const QString &comment );
228 void setDefaultValueDefinition( const
QgsDefaultValue &defaultValueDefinition );
250 QString alias() const;
258 void setAlias( const QString &alias );
261 QString displayString( const QVariant &v ) const;
270 bool convertCompatible( QVariant &v ) const;
273 PyObject *sipParseErr = NULL;
280 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
284 Py_BEGIN_ALLOW_THREADS
295 sipReleaseType( a0, sipType_QVariant, a0State );
296 sipRaiseUnknownException();
302 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
303 sipReleaseType( a0, sipType_QVariant, a0State );
307 PyErr_SetString( PyExc_ValueError,
308 QString(
"Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->
type() ).toUtf8().constData() );
309 sipError = sipErrorFail;
317 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
324 operator QVariant()
const 326 return QVariant::fromValue( *
this );
347 SIP_PYOBJECT __repr__();
349 QString str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->typeName() );
350 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
356 QSharedDataPointer<QgsFieldPrivate> d;
The QgsDefaultValue class provides a container for managing client side default values for fields...
bool convertCompatible(QVariant &v) const
Converts the provided variant to a compatible format.
Stores information about constraints which may be present on a field.
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsField &field)
Writes the field to stream out. QGIS version compatibility is not guaranteed.
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
Encapsulate a field in an attribute table or data source.
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.