mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-08 00:05:09 -04:00
641 lines
18 KiB
Plaintext
641 lines
18 KiB
Plaintext
/************************************************************************
|
|
* 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
|
|
{
|
|
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
|
|
{
|
|
|
|
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 *
|
|
************************************************************************/
|