You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: python/core/qgsfield.sip
+59Lines changed: 59 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -110,6 +110,65 @@ public:
110
110
111
111
/**Formats string for display*/
112
112
QString displayString( const QVariant& v ) const;
113
+
114
+
115
+
/**
116
+
* Converts the provided variant to a compatible format
117
+
*
118
+
* @param v The value to convert
119
+
*
120
+
* @return True if the conversion was successful
121
+
*/
122
+
QVariant convertCompatible( QVariant& v ) const;
123
+
%MethodCode
124
+
PyObject *sipParseErr = NULL;
125
+
126
+
{
127
+
QVariant * a0;
128
+
int a0State = 0;
129
+
const QgsField *sipCpp;
130
+
131
+
if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant,&a0, &a0State))
132
+
{
133
+
bool sipRes;
134
+
135
+
Py_BEGIN_ALLOW_THREADS
136
+
try
137
+
{
138
+
QgsDebugMsg( a0->toString() );
139
+
sipRes = sipCpp->convertCompatible(*a0);
140
+
QgsDebugMsg( a0->toString() );
141
+
}
142
+
catch (...)
143
+
{
144
+
Py_BLOCK_THREADS
145
+
146
+
sipReleaseType(a0,sipType_QVariant,a0State);
147
+
sipRaiseUnknownException();
148
+
return NULL;
149
+
}
150
+
151
+
Py_END_ALLOW_THREADS
152
+
153
+
PyObject* res = sipConvertFromType( a0, sipType_QVariant, NULL );
154
+
sipReleaseType(a0,sipType_QVariant,a0State);
155
+
156
+
if ( !sipRes )
157
+
{
158
+
PyErr_SetString(PyExc_ValueError,
159
+
QString( "Value %1 (%2) could not be converted to field type %3." ).arg( a0->toString() ).arg ( a0->typeName() ).arg( sipCpp->type() ).toUtf8().constData() );
160
+
sipError = sipErrorFail;
161
+
}
162
+
163
+
return res;
164
+
}
165
+
}
166
+
167
+
/* Raise an exception if the arguments couldn't be parsed. */
0 commit comments