mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-17 00:04:02 -04:00
Sipify QgsField
This commit is contained in:
parent
5d5bb34383
commit
8376a30f7a
@ -13,7 +13,6 @@ core/qgsexpressioncontextgenerator.sip
|
|||||||
core/qgsfeaturefilterprovider.sip
|
core/qgsfeaturefilterprovider.sip
|
||||||
core/qgsfeatureiterator.sip
|
core/qgsfeatureiterator.sip
|
||||||
core/qgsfeaturerequest.sip
|
core/qgsfeaturerequest.sip
|
||||||
core/qgsfield.sip
|
|
||||||
core/qgsfieldconstraints.sip
|
core/qgsfieldconstraints.sip
|
||||||
core/qgsfields.sip
|
core/qgsfields.sip
|
||||||
core/qgsfieldformatterregistry.sip
|
core/qgsfieldformatterregistry.sip
|
||||||
|
@ -1,216 +1,261 @@
|
|||||||
/** \class QgsField
|
/************************************************************************
|
||||||
* \ingroup core
|
* This file has been generated automatically from *
|
||||||
* Encapsulate a field in an attribute table or data source.
|
* *
|
||||||
* QgsField stores metadata about an attribute field, including name, type
|
* src/core/qgsfield.h *
|
||||||
* length, and if applicable, precision.
|
* *
|
||||||
* \note QgsField objects are implicitly shared.
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
*/
|
************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class QgsField
|
class QgsField
|
||||||
{
|
{
|
||||||
|
%Docstring
|
||||||
|
Encapsulate a field in an attribute table or data source.
|
||||||
|
QgsField stores metadata about an attribute field, including name, type
|
||||||
|
length, and if applicable, precision.
|
||||||
|
.. note::
|
||||||
|
|
||||||
%TypeHeaderCode
|
QgsField objects are implicitly shared.
|
||||||
#include <qgsfield.h>
|
|
||||||
%End
|
%End
|
||||||
|
|
||||||
|
%TypeHeaderCode
|
||||||
|
#include "qgsfield.h"
|
||||||
|
%End
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Constructor. Constructs a new QgsField object.
|
QgsField( const QString &name = QString(),
|
||||||
* @param name Field name
|
|
||||||
* @param type Field variant type, currently supported: String / Int / Double
|
|
||||||
* @param typeName Field type (e.g., char, varchar, text, int, serial, double).
|
|
||||||
* Field types are usually unique to the source and are stored exactly
|
|
||||||
* as returned from the data store.
|
|
||||||
* @param len Field length
|
|
||||||
* @param prec Field precision. Usually decimal places but may also be
|
|
||||||
* used in conjunction with other fields types (e.g., variable character fields)
|
|
||||||
* @param comment Comment for the field
|
|
||||||
* @param subType If the field is a collection, its element's type. When
|
|
||||||
* all the elements don't need to have the same type, leave
|
|
||||||
* this to QVariant::Invalid.
|
|
||||||
*/
|
|
||||||
QgsField( const QString& name = QString(),
|
|
||||||
QVariant::Type type = QVariant::Invalid,
|
QVariant::Type type = QVariant::Invalid,
|
||||||
const QString& typeName = QString(),
|
const QString &typeName = QString(),
|
||||||
int len = 0,
|
int len = 0,
|
||||||
int prec = 0,
|
int prec = 0,
|
||||||
const QString& comment = QString(),
|
const QString &comment = QString(),
|
||||||
QVariant::Type subType = QVariant::Invalid );
|
QVariant::Type subType = QVariant::Invalid );
|
||||||
|
%Docstring
|
||||||
|
Constructor. Constructs a new QgsField object.
|
||||||
|
\param name Field name
|
||||||
|
\param type Field variant type, currently supported: String / Int / Double
|
||||||
|
\param typeName Field type (e.g., char, varchar, text, int, serial, double).
|
||||||
|
Field types are usually unique to the source and are stored exactly
|
||||||
|
as returned from the data store.
|
||||||
|
\param len Field length
|
||||||
|
\param prec Field precision. Usually decimal places but may also be
|
||||||
|
used in conjunction with other fields types (e.g., variable character fields)
|
||||||
|
\param comment Comment for the field
|
||||||
|
\param subType If the field is a collection, its element's type. When
|
||||||
|
all the elements don't need to have the same type, leave
|
||||||
|
this to QVariant.Invalid.
|
||||||
|
%End
|
||||||
|
|
||||||
|
QgsField( const QgsField &other );
|
||||||
|
%Docstring
|
||||||
|
Copy constructor
|
||||||
|
%End
|
||||||
|
|
||||||
/** Copy constructor
|
|
||||||
*/
|
|
||||||
QgsField( const QgsField& other );
|
|
||||||
|
|
||||||
//! Destructor
|
|
||||||
virtual ~QgsField();
|
virtual ~QgsField();
|
||||||
|
|
||||||
bool operator==( const QgsField& other ) const;
|
bool operator==( const QgsField &other ) const;
|
||||||
bool operator!=( const QgsField& other ) const;
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
bool operator!=( const QgsField &other ) const;
|
||||||
|
%Docstring
|
||||||
|
:rtype: bool
|
||||||
|
%End
|
||||||
|
|
||||||
/** Returns the name of the field.
|
|
||||||
* @see setName()
|
|
||||||
* @see displayName()
|
|
||||||
*/
|
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the name of the field.
|
||||||
|
.. seealso:: setName()
|
||||||
|
.. seealso:: displayName()
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
/** Returns the name to use when displaying this field. This will be the
|
|
||||||
* field alias if set, otherwise the field name.
|
|
||||||
* @see name()
|
|
||||||
* @see alias()
|
|
||||||
* @note added in QGIS 3.0
|
|
||||||
*/
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the name to use when displaying this field. This will be the
|
||||||
|
field alias if set, otherwise the field name.
|
||||||
|
.. seealso:: name()
|
||||||
|
.. seealso:: alias()
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
//! Gets variant type of the field as it will be retrieved from data source
|
|
||||||
QVariant::Type type() const;
|
QVariant::Type type() const;
|
||||||
|
%Docstring
|
||||||
|
Gets variant type of the field as it will be retrieved from data source
|
||||||
|
:rtype: QVariant.Type
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* If the field is a collection, gets its element's type.
|
|
||||||
* When all the elements don't need to have the same type, this returns
|
|
||||||
* QVariant::Invalid.
|
|
||||||
* @note added in QGIS 3.0
|
|
||||||
*/
|
|
||||||
QVariant::Type subType() const;
|
QVariant::Type subType() const;
|
||||||
|
%Docstring
|
||||||
|
If the field is a collection, gets its element's type.
|
||||||
|
When all the elements don't need to have the same type, this returns
|
||||||
|
QVariant.Invalid.
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: QVariant.Type
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the field type. Field types vary depending on the data source. Examples
|
|
||||||
* are char, int, double, blob, geometry, etc. The type is stored exactly as
|
|
||||||
* the data store reports it, with no attempt to standardize the value.
|
|
||||||
* @return QString containing the field type
|
|
||||||
*/
|
|
||||||
QString typeName() const;
|
QString typeName() const;
|
||||||
|
%Docstring
|
||||||
|
Gets the field type. Field types vary depending on the data source. Examples
|
||||||
|
are char, int, double, blob, geometry, etc. The type is stored exactly as
|
||||||
|
the data store reports it, with no attempt to standardize the value.
|
||||||
|
:return: QString containing the field type
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the length of the field.
|
|
||||||
* @return int containing the length of the field
|
|
||||||
*/
|
|
||||||
int length() const;
|
int length() const;
|
||||||
|
%Docstring
|
||||||
|
Gets the length of the field.
|
||||||
|
:return: int containing the length of the field
|
||||||
|
:rtype: int
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the precision of the field. Not all field types have a related precision.
|
|
||||||
* @return int containing the precision or zero if not applicable to the field type.
|
|
||||||
*/
|
|
||||||
int precision() const;
|
int precision() const;
|
||||||
|
%Docstring
|
||||||
|
Gets the precision of the field. Not all field types have a related precision.
|
||||||
|
:return: int containing the precision or zero if not applicable to the field type.
|
||||||
|
:rtype: int
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the field comment
|
|
||||||
*/
|
|
||||||
QString comment() const;
|
QString comment() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the field comment
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns if this field is numeric. Any integer or floating point type
|
|
||||||
* will return true for this.
|
|
||||||
*
|
|
||||||
* @note added in QGIS 2.18
|
|
||||||
*/
|
|
||||||
bool isNumeric() const;
|
bool isNumeric() const;
|
||||||
|
%Docstring
|
||||||
|
Returns if this field is numeric. Any integer or floating point type
|
||||||
|
will return true for this.
|
||||||
|
|
||||||
/**
|
.. versionadded:: 2.18
|
||||||
* Set the field name.
|
:rtype: bool
|
||||||
* @param name Name of the field
|
%End
|
||||||
*/
|
|
||||||
void setName( const QString& name );
|
void setName( const QString &name );
|
||||||
|
%Docstring
|
||||||
|
Set the field name.
|
||||||
|
\param name Name of the field
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Set variant type.
|
|
||||||
*/
|
|
||||||
void setType( QVariant::Type type );
|
void setType( QVariant::Type type );
|
||||||
|
%Docstring
|
||||||
|
Set variant type.
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* If the field is a collection, set its element's type.
|
|
||||||
* When all the elements don't need to have the same type, set this to
|
|
||||||
* QVariant::Invalid.
|
|
||||||
* @note added in QGIS 3.0
|
|
||||||
*/
|
|
||||||
void setSubType( QVariant::Type subType );
|
void setSubType( QVariant::Type subType );
|
||||||
|
%Docstring
|
||||||
|
If the field is a collection, set its element's type.
|
||||||
|
When all the elements don't need to have the same type, set this to
|
||||||
|
QVariant.Invalid.
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
void setTypeName( const QString &typeName );
|
||||||
* Set the field type.
|
%Docstring
|
||||||
* @param typeName Field type
|
Set the field type.
|
||||||
*/
|
\param typeName Field type
|
||||||
void setTypeName( const QString& typeName );
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the field length.
|
|
||||||
* @param len Length of the field
|
|
||||||
*/
|
|
||||||
void setLength( int len );
|
void setLength( int len );
|
||||||
|
%Docstring
|
||||||
|
Set the field length.
|
||||||
|
\param len Length of the field
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the field precision.
|
|
||||||
* @param precision Precision of the field
|
|
||||||
*/
|
|
||||||
void setPrecision( int precision );
|
void setPrecision( int precision );
|
||||||
|
%Docstring
|
||||||
|
Set the field precision.
|
||||||
|
\param precision Precision of the field
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
void setComment( const QString &comment );
|
||||||
* Set the field comment
|
%Docstring
|
||||||
*/
|
Set the field comment
|
||||||
void setComment( const QString& comment );
|
%End
|
||||||
|
|
||||||
/** Returns the expression used when calculating the default value for the field.
|
|
||||||
* @returns expression evaluated when calculating default values for field, or an
|
|
||||||
* empty string if no default is set
|
|
||||||
* @note added in QGIS 3.0
|
|
||||||
* @see setDefaultValueExpression()
|
|
||||||
*/
|
|
||||||
QString defaultValueExpression() const;
|
QString defaultValueExpression() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the expression used when calculating the default value for the field.
|
||||||
|
:return: expression evaluated when calculating default values for field, or an
|
||||||
|
empty string if no default is set
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
.. seealso:: setDefaultValueExpression()
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
/** Sets an expression to use when calculating the default value for the field.
|
void setDefaultValueExpression( const QString &expression );
|
||||||
* @param expression expression to evaluate when calculating default values for field. Pass
|
%Docstring
|
||||||
* an empty expression to clear the default.
|
Sets an expression to use when calculating the default value for the field.
|
||||||
* @note added in QGIS 3.0
|
\param expression expression to evaluate when calculating default values for field. Pass
|
||||||
* @see defaultValueExpression()
|
an empty expression to clear the default.
|
||||||
*/
|
.. versionadded:: 3.0
|
||||||
void setDefaultValueExpression( const QString& expression );
|
.. seealso:: defaultValueExpression()
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
const QgsFieldConstraints &constraints() const;
|
||||||
* Returns constraints which are present for the field.
|
%Docstring
|
||||||
* @note added in QGIS 3.0
|
Returns constraints which are present for the field.
|
||||||
* @see setConstraints()
|
.. versionadded:: 3.0
|
||||||
*/
|
.. seealso:: setConstraints()
|
||||||
const QgsFieldConstraints& constraints() const;
|
:rtype: QgsFieldConstraints
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
void setConstraints( const QgsFieldConstraints &constraints );
|
||||||
* Sets constraints which are present for the field.
|
%Docstring
|
||||||
* @note added in QGIS 3.0
|
Sets constraints which are present for the field.
|
||||||
* @see constraints()
|
.. versionadded:: 3.0
|
||||||
*/
|
.. seealso:: constraints()
|
||||||
void setConstraints( const QgsFieldConstraints& constraints );
|
%End
|
||||||
|
|
||||||
/** Returns the alias for the field (the friendly displayed name of the field ),
|
|
||||||
* or an empty string if there is no alias.
|
|
||||||
* @see setAlias()
|
|
||||||
* @note added in QGIS 3.0
|
|
||||||
*/
|
|
||||||
QString alias() const;
|
QString alias() const;
|
||||||
|
%Docstring
|
||||||
|
Returns the alias for the field (the friendly displayed name of the field ),
|
||||||
|
or an empty string if there is no alias.
|
||||||
|
.. seealso:: setAlias()
|
||||||
|
.. versionadded:: 3.0
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
/** Sets the alias for the field (the friendly displayed name of the field ).
|
void setAlias( const QString &alias );
|
||||||
* @param alias field alias, or empty string to remove an existing alias
|
%Docstring
|
||||||
* @see alias()
|
Sets the alias for the field (the friendly displayed name of the field ).
|
||||||
* @note added in QGIS 3.0
|
\param alias field alias, or empty string to remove an existing alias
|
||||||
*/
|
.. seealso:: alias()
|
||||||
void setAlias( const QString& alias );
|
.. versionadded:: 3.0
|
||||||
|
%End
|
||||||
|
|
||||||
/** Formats string for display*/
|
QString displayString( const QVariant &v ) const;
|
||||||
QString displayString( const QVariant& v ) const;
|
%Docstring
|
||||||
|
Formats string for display
|
||||||
|
:rtype: str
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
bool convertCompatible( QVariant &v ) const;
|
||||||
* Converts the provided variant to a compatible format
|
%Docstring
|
||||||
*
|
Converts the provided variant to a compatible format
|
||||||
* @param v The value to convert
|
|
||||||
*
|
\param v The value to convert
|
||||||
* @return True if the conversion was successful
|
|
||||||
*/
|
:return: True if the conversion was successful
|
||||||
QVariant convertCompatible( QVariant& v ) const;
|
:rtype: bool
|
||||||
|
%End
|
||||||
%MethodCode
|
%MethodCode
|
||||||
PyObject *sipParseErr = NULL;
|
PyObject *sipParseErr = NULL;
|
||||||
|
|
||||||
{
|
{
|
||||||
QVariant * a0;
|
QVariant *a0;
|
||||||
int a0State = 0;
|
int a0State = 0;
|
||||||
const QgsField *sipCpp;
|
const QgsField *sipCpp;
|
||||||
|
|
||||||
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant,&a0, &a0State))
|
if ( sipParseArgs( &sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
|
||||||
{
|
{
|
||||||
bool sipRes;
|
bool sipRes;
|
||||||
|
|
||||||
@ -218,55 +263,72 @@ class QgsField
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
QgsDebugMsg( a0->toString() );
|
QgsDebugMsg( a0->toString() );
|
||||||
sipRes = sipCpp->convertCompatible(*a0);
|
sipRes = sipCpp->convertCompatible( *a0 );
|
||||||
QgsDebugMsg( a0->toString() );
|
QgsDebugMsg( a0->toString() );
|
||||||
}
|
}
|
||||||
catch (...)
|
catch ( ... )
|
||||||
{
|
{
|
||||||
Py_BLOCK_THREADS
|
Py_BLOCK_THREADS
|
||||||
|
|
||||||
sipReleaseType(a0,sipType_QVariant,a0State);
|
sipReleaseType( a0, sipType_QVariant, a0State );
|
||||||
sipRaiseUnknownException();
|
sipRaiseUnknownException();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
PyObject* res = sipConvertFromType( a0, sipType_QVariant, NULL );
|
PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
|
||||||
sipReleaseType(a0,sipType_QVariant,a0State);
|
sipReleaseType( a0, sipType_QVariant, a0State );
|
||||||
|
|
||||||
if ( !sipRes )
|
if ( !sipRes )
|
||||||
{
|
{
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString( PyExc_ValueError,
|
||||||
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
|
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
|
||||||
sipError = sipErrorFail;
|
sipError = sipErrorFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Raise an exception if the arguments couldn't be parsed. */
|
// Raise an exception if the arguments couldn't be parsed.
|
||||||
sipNoMethod(sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible);
|
sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
|
||||||
|
|
||||||
return nullptr;
|
return 0;
|
||||||
%End
|
%End
|
||||||
|
|
||||||
//! Allows direct construction of QVariants from fields.
|
|
||||||
operator QVariant() const;
|
operator QVariant() const;
|
||||||
|
%Docstring
|
||||||
|
Allows direct construction of QVariants from fields.
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
void setEditorWidgetSetup( const QgsEditorWidgetSetup &v );
|
||||||
* Set the editor widget setup for the field.
|
%Docstring
|
||||||
*
|
Set the editor widget setup for the field.
|
||||||
* @param v The value to set
|
|
||||||
*/
|
\param v The value to set
|
||||||
void setEditorWidgetSetup( const QgsEditorWidgetSetup& v );
|
%End
|
||||||
|
|
||||||
|
QgsEditorWidgetSetup editorWidgetSetup() const;
|
||||||
|
%Docstring
|
||||||
|
Get the editor widget setup for the field.
|
||||||
|
|
||||||
|
Defaults may be set by the provider and can be overridden
|
||||||
|
by manual field configuration.
|
||||||
|
|
||||||
|
:return: the value
|
||||||
|
:rtype: QgsEditorWidgetSetup
|
||||||
|
%End
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the editor widget setup for the field.
|
|
||||||
*
|
|
||||||
* @return the value
|
|
||||||
*/
|
|
||||||
const QgsEditorWidgetSetup& editorWidgetSetup() const;
|
|
||||||
}; // class QgsField
|
}; // class QgsField
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* This file has been generated automatically from *
|
||||||
|
* *
|
||||||
|
* src/core/qgsfield.h *
|
||||||
|
* *
|
||||||
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||||
|
************************************************************************/
|
||||||
|
@ -22,8 +22,11 @@
|
|||||||
#include <QSharedDataPointer>
|
#include <QSharedDataPointer>
|
||||||
#include "qgsfield_p.h"
|
#include "qgsfield_p.h"
|
||||||
#include "qgis_core.h"
|
#include "qgis_core.h"
|
||||||
|
#include "qgis.h"
|
||||||
|
|
||||||
|
#ifndef SIP_RUN
|
||||||
typedef QList<int> QgsAttributeList;
|
typedef QList<int> QgsAttributeList;
|
||||||
|
#endif
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* This class is considered CRITICAL and any change MUST be accompanied with
|
* This class is considered CRITICAL and any change MUST be accompanied with
|
||||||
@ -85,7 +88,7 @@ class CORE_EXPORT QgsField
|
|||||||
|
|
||||||
/** Assignment operator
|
/** Assignment operator
|
||||||
*/
|
*/
|
||||||
QgsField &operator =( const QgsField &other );
|
QgsField &operator =( const QgsField &other ) SIP_SKIP;
|
||||||
|
|
||||||
virtual ~QgsField() = default;
|
virtual ~QgsField() = default;
|
||||||
|
|
||||||
@ -247,6 +250,57 @@ class CORE_EXPORT QgsField
|
|||||||
* \returns True if the conversion was successful
|
* \returns True if the conversion was successful
|
||||||
*/
|
*/
|
||||||
bool convertCompatible( QVariant &v ) const;
|
bool convertCompatible( QVariant &v ) const;
|
||||||
|
#ifdef SIP_RUN
|
||||||
|
% MethodCode
|
||||||
|
PyObject *sipParseErr = NULL;
|
||||||
|
|
||||||
|
{
|
||||||
|
QVariant *a0;
|
||||||
|
int a0State = 0;
|
||||||
|
const QgsField *sipCpp;
|
||||||
|
|
||||||
|
if ( sipParseArgs( &sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
|
||||||
|
{
|
||||||
|
bool sipRes;
|
||||||
|
|
||||||
|
Py_BEGIN_ALLOW_THREADS
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QgsDebugMsg( a0->toString() );
|
||||||
|
sipRes = sipCpp->convertCompatible( *a0 );
|
||||||
|
QgsDebugMsg( a0->toString() );
|
||||||
|
}
|
||||||
|
catch ( ... )
|
||||||
|
{
|
||||||
|
Py_BLOCK_THREADS
|
||||||
|
|
||||||
|
sipReleaseType( a0, sipType_QVariant, a0State );
|
||||||
|
sipRaiseUnknownException();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
|
PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
|
||||||
|
sipReleaseType( a0, sipType_QVariant, a0State );
|
||||||
|
|
||||||
|
if ( !sipRes )
|
||||||
|
{
|
||||||
|
PyErr_SetString( PyExc_ValueError,
|
||||||
|
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString(), a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
|
||||||
|
sipError = sipErrorFail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Raise an exception if the arguments couldn't be parsed.
|
||||||
|
sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
% End
|
||||||
|
#endif
|
||||||
|
|
||||||
//! Allows direct construction of QVariants from fields.
|
//! Allows direct construction of QVariants from fields.
|
||||||
operator QVariant() const
|
operator QVariant() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user