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 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640
|
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsproperty.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsPropertyDefinition
{
%Docstring(signature="appended")
Definition for a property.
:py:class:`QgsPropertyDefinition` defines the type of values allowed for
a property, and handles descriptive names and help text for using the
property. Definitions can use one of the predefined standard templates
to simplify definition of commonly used property types, such as colors
and blend modes.
%End
%TypeHeaderCode
#include "qgsproperty.h"
%End
public:
enum StandardPropertyTemplate /BaseType=IntEnum/
{
Boolean,
Integer,
IntegerPositive,
IntegerPositiveGreaterZero,
Double,
DoublePositive,
Double0To1,
Rotation,
String,
Opacity,
RenderUnits,
ColorWithAlpha,
ColorNoAlpha,
PenJoinStyle,
BlendMode,
Point,
Size,
Size2D,
LineStyle,
StrokeWidth,
FillStyle,
CapStyle,
HorizontalAnchor,
VerticalAnchor,
SvgPath,
Offset,
DateTime,
Custom,
};
enum DataType /BaseType=IntEnum/
{
DataTypeString,
DataTypeNumeric,
DataTypeBoolean,
};
QgsPropertyDefinition();
%Docstring
Constructs an empty property.
%End
QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type, const QString &origin = QString(), const QString &comment = QString() );
%Docstring
Constructor for QgsPropertyDefinition, using a standard property
template.
:param name: is used internally and should be a unique, alphanumeric
string.
:param description: can be any localised string describing what the
property is used for.
:param type: one of the predefined standard property template
:param origin: The origin of the property
:param comment: A free comment for the property
%End
QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, const QString &origin = QString(), const QString &comment = QString() );
%Docstring
Constructor for custom :py:class:`QgsPropertyDefinitions`.
:param name: is used internally and should be a unique, alphanumeric
string.
:param dataType: the data type for the property
:param description: can be any localised string describing what the
property is used for.
:param helpText: parameter should specify a descriptive string for users
outlining the types of value acceptable by the property
(eg 'dashed' or 'solid' for a line style property).
:param origin: The origin of the property
:param comment: A free comment for the property
%End
QString name() const;
%Docstring
Returns the name of the property. This is used internally and should be
a unique, alphanumeric string.
%End
void setName( const QString &name );
%Docstring
Sets the name of the property
%End
QString origin() const;
%Docstring
Returns the origin of the property. For example, a PAL property has an
origin set to "labeling" while a diagram property has an origin set to
"diagram".
%End
void setOrigin( const QString &origin );
%Docstring
Sets the origin of the property. For example, a PAL property has an
origin set to "labeling" while a diagram property has an origin set to
"diagram".
%End
QString description() const;
%Docstring
Descriptive name of the property.
%End
QString comment() const;
%Docstring
Returns the comment of the property
%End
void setComment( const QString &comment );
%Docstring
Sets comment of the property
%End
QString helpText() const;
%Docstring
Helper text for using the property, including a description of the valid
values for the property.
%End
void setDataType( DataType type );
%Docstring
Sets the data type
%End
DataType dataType() const;
%Docstring
Returns the allowable field/value data type for the property.
%End
StandardPropertyTemplate standardTemplate() const;
%Docstring
Returns the property's standard template, if applicable. Non standard
types will return the Custom template.
%End
bool supportsAssistant() const;
%Docstring
Returns ``True`` if the property is of a type which is compatible with
property override assistants.
%End
};
class QgsProperty
{
%Docstring(signature="appended")
A store for object properties.
:py:class:`QgsProperty` objects are used for storing properties for
objects, which can then be transformed to a QVariant value by evaluating
them against a supplied :py:class:`QgsExpressionContext`. Multiple
:py:class:`QgsProperty` objects can be grouped using a
:py:class:`QgsPropertyCollection` for easier bulk storage, retrieval and
evaluation.
:py:class:`QgsProperty` objects are implicitly shared and can be
inexpensively copied.
%End
%TypeHeaderCode
#include "qgsproperty.h"
%End
public:
static QVariantMap propertyMapToVariantMap( const QMap<QString, QgsProperty> &propertyMap );
%Docstring
Convert a map of QgsProperty to a map of QVariant This is useful to save
a map of properties
.. versionadded:: 3.20
%End
static QMap<QString, QgsProperty> variantMapToPropertyMap( const QVariantMap &variantMap );
%Docstring
Convert a map of QVariant to a map of QgsProperty This is useful to
restore a map of properties. The properties are created using
QgsProperty.loadVariant
.. versionadded:: 3.20
%End
QgsProperty();
%Docstring
Constructor for a QgsProperty. The property will be set to an
InvalidProperty type.
%End
~QgsProperty();
static QgsProperty fromExpression( const QString &expression, bool isActive = true );
%Docstring
Returns a new ExpressionBasedProperty created from the specified
expression.
%End
static QgsProperty fromField( const QString &fieldName, bool isActive = true );
%Docstring
Returns a new FieldBasedProperty created from the specified field name.
%End
static QgsProperty fromValue( const QVariant &value, bool isActive = true );
%Docstring
Returns a new StaticProperty created from the specified value.
%End
QgsProperty( const QgsProperty &other );
bool operator==( const QgsProperty &other ) const;
bool operator!=( const QgsProperty &other ) const;
Qgis::PropertyType propertyType() const;
%Docstring
Returns the property type.
%End
bool isActive() const;
%Docstring
Returns whether the property is currently active.
.. seealso:: :py:func:`setActive`
%End
bool isStaticValueInContext( const QgsExpressionContext &context, QVariant &staticValue /Out/ ) const;
%Docstring
Returns ``True`` if the property is effectively a static value in the
specified ``context``.
I.e. if the property type is QgsProperty.ExpressionBasedProperty with a
fixed value expression ('some static value'), this method will return
``True``.
:param context: expression context
:return: - ``True`` if property is a static value
- staticValue: evaluated static value if property is
effectively a static value
.. versionadded:: 3.24
%End
void setActive( bool active );
%Docstring
Sets whether the property is currently active.
.. seealso:: :py:func:`isActive`
%End
void setStaticValue( const QVariant &value );
%Docstring
Sets the static value for the property. Calling this will transform the
property into an StaticProperty.
.. seealso:: :py:func:`staticValue`
%End
QVariant staticValue() const;
%Docstring
Returns the current static value for the property. If the property is
not a StaticProperty this will return an invalid variant.
.. seealso:: :py:func:`setStaticValue`
%End
void setField( const QString &field );
%Docstring
Sets the field name the property references. Calling this will transform
the property into an FieldBasedProperty.
.. seealso:: :py:func:`field`
%End
QString field() const;
%Docstring
Returns the current field name the property references. If the property
is not a FieldBasedProperty this will return an empty string.
.. seealso:: :py:func:`setField`
%End
void setExpressionString( const QString &expression );
%Docstring
Sets the expression to use for the property value. Calling this will
transform the property into an ExpressionBasedProperty.
.. seealso:: :py:func:`expressionString`
%End
QString expressionString() const;
%Docstring
Returns the expression used for the property value. If the property is
not a ExpressionBasedProperty this will return an empty string.
.. seealso:: :py:func:`setExpressionString`
%End
QString asExpression() const;
%Docstring
Returns an expression string representing the state of the property, or
an empty string if the property could not be converted to an expression
%End
bool prepare( const QgsExpressionContext &context = QgsExpressionContext() ) const;
%Docstring
Prepares the property against a specified expression context. Calling
prepare before evaluating the property multiple times allows
precalculation of expensive setup tasks such as parsing expressions.
Returns ``True`` if preparation was successful.
%End
QSet< QString > referencedFields( const QgsExpressionContext &context = QgsExpressionContext(), bool ignoreContext = false ) const;
%Docstring
Returns the set of any fields referenced by the property for a specified
expression context.
.. note::
The optional argument ignoreContext has been added in QGIS 3.14. When set to ``True``,
even fields not set in context's :py:func:`~QgsProperty.fields` will be reported - this is useful e.g. with vector tiles
where the actual available field names may not be known beforehand.
%End
bool isProjectColor() const;
%Docstring
Returns ``True`` if the property is set to a linked project color.
.. versionadded:: 3.6
%End
QVariant value( const QgsExpressionContext &context, const QVariant &defaultValue = QVariant(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property, including any transforms
which are set for the property
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for. The variables and functions contained in
the expression context can be used to alter the
calculated value for the property, so that a property is
able to respond to the current environment, layers and
features within QGIS.
:param defaultValue: default value to return if the property is not
active or cannot be calculated
:return: - calculated value for property
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`valueAsString`
.. seealso:: :py:func:`valueAsColor`
.. seealso:: :py:func:`valueAsDouble`
.. seealso:: :py:func:`valueAsInt`
.. seealso:: :py:func:`valueAsBool`
%End
QDateTime valueAsDateTime( const QgsExpressionContext &context, const QDateTime &defaultDateTime = QDateTime(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property and interprets it as a
datetime.
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for.
:param defaultDateTime: default datetime to return if the property
cannot be calculated as a datetime
:return: - value parsed to datetime
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`value`
.. seealso:: :py:func:`valueAsString`
.. seealso:: :py:func:`valueAsColor`
.. seealso:: :py:func:`valueAsDouble`
.. seealso:: :py:func:`valueAsInt`
.. seealso:: :py:func:`valueAsBool`
.. versionadded:: 3.14
%End
QString valueAsString( const QgsExpressionContext &context, const QString &defaultString = QString(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property and interprets it as a
string.
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for.
:param defaultString: default string to return if the property cannot be
calculated as a string
:return: - value parsed to string
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`value`
.. seealso:: :py:func:`valueAsDateTime`
.. seealso:: :py:func:`valueAsColor`
.. seealso:: :py:func:`valueAsDouble`
.. seealso:: :py:func:`valueAsInt`
.. seealso:: :py:func:`valueAsBool`
%End
QColor valueAsColor( const QgsExpressionContext &context, const QColor &defaultColor = QColor(), bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property and interprets it as a
color.
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for.
:param defaultColor: default color to return if the property cannot be
calculated as a color
:return: - value parsed to color
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`value`
.. seealso:: :py:func:`valueAsDateTime`
.. seealso:: :py:func:`valueAsString`
.. seealso:: :py:func:`valueAsDouble`
.. seealso:: :py:func:`valueAsInt`
.. seealso:: :py:func:`valueAsBool`
%End
double valueAsDouble( const QgsExpressionContext &context, double defaultValue = 0.0, bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property and interprets it as a
double.
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for.
:param defaultValue: default double to return if the property cannot be
calculated as a double
:return: - value parsed to double
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`value`
.. seealso:: :py:func:`valueAsDateTime`
.. seealso:: :py:func:`valueAsString`
.. seealso:: :py:func:`valueAsColor`
.. seealso:: :py:func:`valueAsInt`
.. seealso:: :py:func:`valueAsBool`
%End
int valueAsInt( const QgsExpressionContext &context, int defaultValue = 0, bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property and interprets it as an
integer.
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for.
:param defaultValue: default integer to return if the property cannot be
calculated as an integer
:return: - value parsed to integer
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`value`
.. seealso:: :py:func:`valueAsDateTime`
.. seealso:: :py:func:`valueAsString`
.. seealso:: :py:func:`valueAsColor`
.. seealso:: :py:func:`valueAsDouble`
.. seealso:: :py:func:`valueAsBool`
%End
bool valueAsBool( const QgsExpressionContext &context, bool defaultValue = false, bool *ok /Out/ = 0 ) const;
%Docstring
Calculates the current value of the property and interprets it as an
boolean.
:param context: :py:class:`QgsExpressionContext` to evaluate the
property for.
:param defaultValue: default boolean to return if the property cannot be
calculated as an boolean
:return: - value parsed to boolean
- ok: ``True`` if conversion was successful
.. seealso:: :py:func:`value`
.. seealso:: :py:func:`valueAsDateTime`
.. seealso:: :py:func:`valueAsString`
.. seealso:: :py:func:`valueAsColor`
.. seealso:: :py:func:`valueAsDouble`
.. seealso:: :py:func:`valueAsInt`
%End
QVariant toVariant() const;
%Docstring
Saves this property to a QVariantMap, wrapped in a QVariant. You can use
:py:class:`QgsXmlUtils`.writeVariant to save it to an XML document.
.. seealso:: :py:func:`loadVariant`
%End
bool loadVariant( const QVariant &property );
%Docstring
Loads this property from a QVariantMap, wrapped in a QVariant. You can
use :py:class:`QgsXmlUtils`.readVariant to load it from an XML document.
.. seealso:: :py:func:`toVariant`
%End
void setTransformer( QgsPropertyTransformer *transformer /Transfer/ );
%Docstring
Sets an optional transformer to use for manipulating the calculated
values for the property.
:param transformer: transformer to install. Ownership is transferred to
the property, and any existing transformer will be
deleted. Set to ``None`` to remove an existing
transformer.
.. seealso:: :py:func:`transformer`
%End
const QgsPropertyTransformer *transformer() const;
%Docstring
Returns the existing transformer used for manipulating the calculated
values for the property, if set.
.. seealso:: :py:func:`setTransformer`
%End
bool convertToTransformer();
%Docstring
Attempts to convert an existing expression based property to a base
expression with corresponding transformer. Returns ``True`` if
conversion was successful. Note that calling this method requires
multiple parsing of expressions, so it should only be called in
non-performance critical code.
%End
operator QVariant() const;
SIP_PYOBJECT __repr__();
%MethodCode
QString typeString;
QString definitionString;
switch ( sipCpp->propertyType() )
{
case Qgis::PropertyType::Static:
typeString = QStringLiteral( "static" );
definitionString = sipCpp->staticValue().toString();
break;
case Qgis::PropertyType::Field:
typeString = QStringLiteral( "field" );
definitionString = sipCpp->field();
break;
case Qgis::PropertyType::Expression:
typeString = QStringLiteral( "expression" );
definitionString = sipCpp->expressionString();
break;
case Qgis::PropertyType::Invalid:
typeString = QStringLiteral( "invalid" );
break;
}
QString str = QStringLiteral( "<QgsProperty: %1%2%3>" ).arg( !sipCpp->isActive() && sipCpp->propertyType() != Qgis::PropertyType::Invalid ? QStringLiteral( "INACTIVE " ) : QString(),
typeString,
definitionString.isEmpty() ? QString() : QStringLiteral( " (%1)" ).arg( definitionString ) );
sipRes = PyUnicode_FromString( str.toUtf8().constData() );
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsproperty.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
|