1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfield.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsField
{
%Docstring(signature="appended")
Encapsulate a field in an attribute table or data source.
:py:class:`QgsField` stores metadata about an attribute field, including
name, type length, and if applicable, precision.
.. note::
:py:class:`QgsField` objects are implicitly shared.
%End
%TypeHeaderCode
#include "qgsfield.h"
%End
public:
static const QMetaObject staticMetaObject;
public:
QgsField( const QString &name = QString(),
QMetaType::Type type = QMetaType::Type::UnknownType,
const QString &typeName = QString(),
int len = 0,
int prec = 0,
const QString &comment = QString(),
QMetaType::Type subType = QMetaType::Type::UnknownType ) /HoldGIL/;
%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 QString &name,
QVariant::Type type,
const QString &typeName = QString(),
int len = 0,
int prec = 0,
const QString &comment = QString(),
QVariant::Type subType = QVariant::Invalid ) /HoldGIL,Deprecated/;
%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.
.. deprecated:: 3.38
Use the method with a QMetaType.Type argument instead.
%End
QgsField( const QgsField &other ) /HoldGIL/;
virtual ~QgsField();
bool operator==( const QgsField &other ) const /HoldGIL/;
bool operator!=( const QgsField &other ) const /HoldGIL/;
QString name() const /HoldGIL/;
%Docstring
Returns the name of the field.
.. seealso:: :py:func:`setName`
.. seealso:: :py:func:`displayName`
%End
QString displayName() const /HoldGIL/;
%Docstring
Returns the name to use when displaying this field. This will be the
field alias if set, otherwise the field name.
.. seealso:: :py:func:`name`
.. seealso:: :py:func:`alias`
%End
QString displayNameWithAlias() const /HoldGIL/;
%Docstring
Returns the name to use when displaying this field and adds the alias in
parenthesis if it is defined.
This will be used when working close to the data structure (i.e.
building expressions and queries), when the real field name must be
shown but the alias is also useful to understand what the field
represents.
.. seealso:: :py:func:`name`
.. seealso:: :py:func:`alias`
.. versionadded:: 3.12
%End
QString displayType( bool showConstraints = false ) const /HoldGIL/;
%Docstring
Returns the type to use when displaying this field, including the length
and precision of the datatype if applicable.
This will be used when the full datatype with details has to displayed
to the user.
.. seealso:: :py:func:`type`
.. seealso:: :py:func:`friendlyTypeString`
.. versionadded:: 3.14
%End
QString friendlyTypeString() const /HoldGIL/;
%Docstring
Returns a user friendly, translated representation of the field type.
Unlike :py:func:`~QgsField.displayType`, this method only returns
strings representing the field type and does not include length,
precision or constraint information.
.. seealso:: :py:func:`type`
.. seealso:: :py:func:`displayType`
.. versionadded:: 3.14
%End
QMetaType::Type type() const /HoldGIL/;
%Docstring
Gets variant type of the field as it will be retrieved from data source
%End
QMetaType::Type subType() const /HoldGIL/;
%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.
%End
QString typeName() const /HoldGIL/;
%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
%End
int length() const /HoldGIL/;
%Docstring
Gets the length of the field.
:return: int containing the length of the field
%End
int precision() const /HoldGIL/;
%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.
%End
QString comment() const /HoldGIL/;
%Docstring
Returns the field comment
%End
QMap< int, QVariant > metadata() const /HoldGIL/;
%Docstring
Returns the map of field metadata.
Map keys should match values from the
:py:class:`Qgis`.FieldMetadataProperty enum.
.. seealso:: :py:func:`setMetadata`
.. versionadded:: 3.32
%End
QVariant metadata( int property ) const /HoldGIL/;
%Docstring
Returns a specific metadata ``property``.
.. seealso:: :py:func:`setMetadata`
.. versionadded:: 3.32
%End
void setMetadata( const QMap< int, QVariant > metadata ) /HoldGIL/;
%Docstring
Sets the map of field ``metadata``.
Map keys should match values from the
:py:class:`Qgis`.FieldMetadataProperty enum.
.. seealso:: :py:func:`metadata`
.. versionadded:: 3.32
%End
void setMetadata( int property, const QVariant &value ) /HoldGIL/;
%Docstring
Sets a metadata ``property`` to ``value``.
.. seealso:: :py:func:`metadata`
.. versionadded:: 3.32
%End
bool isNumeric() const /HoldGIL/;
%Docstring
Returns if this field is numeric. Any integer or floating point type
will return ``True`` for this.
%End
bool isDateOrTime() const /HoldGIL/;
%Docstring
Returns if this field is a date and/or time type.
.. versionadded:: 3.6
%End
void setName( const QString &name ) /HoldGIL/;
%Docstring
Set the field name.
:param name: Name of the field
%End
void setType( QMetaType::Type type ) /HoldGIL/;
%Docstring
Set variant ``type``.
%End
void setType( QVariant::Type type ) /HoldGIL,Deprecated/;
%Docstring
Set variant ``type``.
.. deprecated:: 3.38
Use the method with a QMetaType.Type argument instead.
%End
void setSubType( QMetaType::Type subType ) /HoldGIL/;
%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.
%End
void setSubType( QVariant::Type subType ) /HoldGIL,Deprecated/;
%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.
.. deprecated:: 3.38
Use the method with a QMetaType.Type argument instead.
%End
void setTypeName( const QString &typeName ) /HoldGIL/;
%Docstring
Set the field type.
:param typeName: Field type
%End
void setLength( int len ) /HoldGIL/;
%Docstring
Set the field length.
:param len: Length of the field
%End
void setPrecision( int precision ) /HoldGIL/;
%Docstring
Set the field precision.
:param precision: Precision of the field
%End
void setComment( const QString &comment ) /HoldGIL/;
%Docstring
Set the field comment
%End
QgsDefaultValue defaultValueDefinition() const /HoldGIL/;
%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
.. seealso:: :py:func:`setDefaultValueDefinition`
%End
void setDefaultValueDefinition( const QgsDefaultValue &defaultValueDefinition ) /HoldGIL/;
%Docstring
Sets an expression to use when calculating the default value for the
field.
:param defaultValueDefinition: expression to evaluate when calculating
default values for field. Pass a default
constructed :py:class:`QgsDefaultValue`
to reset.
.. seealso:: :py:func:`defaultValueDefinition`
%End
const QgsFieldConstraints &constraints() const /HoldGIL/;
%Docstring
Returns constraints which are present for the field.
.. seealso:: :py:func:`setConstraints`
%End
void setConstraints( const QgsFieldConstraints &constraints ) /HoldGIL/;
%Docstring
Sets constraints which are present for the field.
.. seealso:: :py:func:`constraints`
%End
QString alias() const /HoldGIL/;
%Docstring
Returns the alias for the field (the friendly displayed name of the
field ), or an empty string if there is no alias.
.. seealso:: :py:func:`setAlias`
%End
void setAlias( const QString &alias ) /HoldGIL/;
%Docstring
Sets the alias for the field (the friendly displayed name of the field
).
:param alias: field alias, or empty string to remove an existing alias
.. seealso:: :py:func:`alias`
%End
Qgis::FieldConfigurationFlags configurationFlags() const /HoldGIL/;
%Docstring
Returns the Flags for the field (searchable, …).
.. seealso:: :py:func:`setConfigurationFlags`
.. versionadded:: 3.34
%End
void setConfigurationFlags( Qgis::FieldConfigurationFlags flags ) /HoldGIL/;
%Docstring
Sets the Flags for the field (searchable, …).
.. seealso:: :py:func:`configurationFlags`
.. versionadded:: 3.34
%End
QString displayString( const QVariant &v ) const;
%Docstring
Formats string for display
%End
static QString readableConfigurationFlag( Qgis::FieldConfigurationFlag flag ) /HoldGIL/;
%Docstring
Returns the readable and translated value of the configuration flag
.. versionadded:: 3.16
%End
bool convertCompatible( QVariant &v ) const;
%Docstring
Converts the provided variant to a compatible format
:param v: The value to convert
:raises ValueError: if the value could not be converted to a compatible
format
%End
%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;
QString errorMessage;
Py_BEGIN_ALLOW_THREADS
try
{
sipRes = sipCpp->convertCompatible( *a0, &errorMessage );
}
catch ( ... )
{
Py_BLOCK_THREADS
sipReleaseType( a0, sipType_QVariant, a0State );
sipRaiseUnknownException();
return NULL;
}
Py_END_ALLOW_THREADS
if ( !sipRes )
{
PyErr_SetString( PyExc_ValueError,
QString( "Value could not be converted to field type %1: %2" ).arg( QMetaType::typeName( sipCpp->type() ), errorMessage ).toUtf8().constData() );
sipIsErr = 1;
}
else
{
PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
sipReleaseType( a0, sipType_QVariant, a0State );
return res;
}
}
else
{
// Raise an exception if the arguments couldn't be parsed.
sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
return nullptr;
}
}
%End
operator QVariant() const;
void setEditorWidgetSetup( const QgsEditorWidgetSetup &v ) /HoldGIL/;
%Docstring
Set the editor widget setup for the field.
:param v: The value to set
%End
QgsEditorWidgetSetup editorWidgetSetup() const /HoldGIL/;
%Docstring
Gets 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
%End
void setReadOnly( bool readOnly ) /HoldGIL/;
%Docstring
Make field read-only if ``readOnly`` is set to true. This is the case
for providers which support generated fields for instance.
.. versionadded:: 3.18
%End
bool isReadOnly() const /HoldGIL/;
%Docstring
Returns ``True`` if this field is a read-only field. This is the case
for providers which support generated fields for instance.
.. versionadded:: 3.18
%End
Qgis::FieldDomainSplitPolicy splitPolicy() const /HoldGIL/;
%Docstring
Returns the field's split policy, which indicates how field values
should be handled during a split operation.
.. seealso:: :py:func:`setSplitPolicy`
.. versionadded:: 3.30
%End
void setSplitPolicy( Qgis::FieldDomainSplitPolicy policy ) /HoldGIL/;
%Docstring
Sets the field's split ``policy``, which indicates how field values
should be handled during a split operation.
.. seealso:: :py:func:`splitPolicy`
.. versionadded:: 3.30
%End
Qgis::FieldDuplicatePolicy duplicatePolicy() const /HoldGIL/;
%Docstring
Returns the field's duplicate policy, which indicates how field values
should be handled during a duplicate operation.
.. seealso:: :py:func:`setDuplicatePolicy`
.. versionadded:: 3.38
%End
void setDuplicatePolicy( Qgis::FieldDuplicatePolicy policy ) /HoldGIL/;
%Docstring
Sets the field's duplicate ``policy``, which indicates how field values
should be handled during a duplicate operation.
.. seealso:: :py:func:`duplicatePolicy`
.. versionadded:: 3.38
%End
SIP_PYOBJECT __repr__();
%MethodCode
QString str = QStringLiteral( "<QgsField: %1 (%2)>" ).arg( sipCpp->name() ).arg( sipCpp->typeName() );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
}; // class QgsField
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsfield.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|