24#include <QDomDocument>
32class QgsPropertyPrivate;
137 QString
name()
const {
return mName; }
149 QString
origin()
const {
return mOrigin; }
198 bool supportsAssistant()
const;
203 QString mDescription;
204 DataType mTypes = DataTypeString;
206 StandardPropertyTemplate mStandardType = Custom;
210 static QString trString();
274 explicit operator bool() const
SIP_SKIP;
338 QString
field() const;
529 operator QVariant()
const
531 return QVariant::fromValue( *
this );
536 SIP_PYOBJECT __repr__();
539 QString definitionString;
540 switch ( sipCpp->propertyType() )
543 typeString = QStringLiteral(
"static" );
544 definitionString = sipCpp->staticValue().toString();
548 typeString = QStringLiteral(
"field" );
549 definitionString = sipCpp->field();
553 typeString = QStringLiteral(
"expression" );
554 definitionString = sipCpp->expressionString();
558 typeString = QStringLiteral(
"invalid" );
562 QString str = QStringLiteral(
"<QgsProperty: %1%2%3>" ).arg( !sipCpp->isActive() && sipCpp->propertyType() !=
Qgis::PropertyType::Invalid ? QStringLiteral(
"INACTIVE " ) : QString(),
564 definitionString.isEmpty() ? QString() : QStringLiteral(
" (%1)" ).arg( definitionString ) );
565 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
571 mutable QExplicitlySharedDataPointer<QgsPropertyPrivate> d;
577 QVariant propertyValue(
const QgsExpressionContext &context,
const QVariant &defaultValue = QVariant(),
bool *ok =
nullptr )
const;
Provides global constants and enumerations for use throughout the application.
@ Invalid
Invalid (not set) property.
@ Field
Field based property.
@ Expression
Expression based property.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
StandardPropertyTemplate standardTemplate() const
Returns the property's standard template, if applicable.
QString helpText() const
Helper text for using the property, including a description of the valid values for the property.
QString comment() const
Returns the comment of the property.
DataType dataType() const
Returns the allowable field/value data type for the property.
void setOrigin(const QString &origin)
Sets the origin of the property.
QString description() const
Descriptive name of the property.
StandardPropertyTemplate
Predefined standard property templates.
@ HorizontalAnchor
Horizontal anchor point.
@ Double
Double value (including negative values).
@ VerticalAnchor
Vertical anchor point.
@ Double0To1
Double value between 0-1 (inclusive).
@ FillStyle
Fill style (eg solid, lines).
@ StrokeWidth
Line stroke width.
@ LineStyle
Line style (eg solid/dashed).
@ Integer
Integer value (including negative values).
@ String
Any string value.
@ DateTime
DateTime value.
@ RenderUnits
Render units (eg mm/pixels/map units).
@ PenJoinStyle
Pen join style.
@ SvgPath
Path to an SVG file.
@ IntegerPositiveGreaterZero
Non-zero positive integer values.
@ IntegerPositive
Positive integer values (including 0).
@ Opacity
Opacity (0-100).
@ CapStyle
Line cap style (eg round).
@ ColorNoAlpha
Color with no alpha channel.
@ Rotation
Rotation (value between 0-360 degrees).
@ Custom
Custom property types.
@ Size
1D size (eg marker radius, or square marker height/width)
@ ColorWithAlpha
Color with alpha channel.
@ DoublePositive
Positive double value (including 0).
@ Size2D
2D size (width/height different)
QString name() const
Returns the name of the property.
QgsPropertyDefinition()=default
Constructs an empty property.
void setDataType(DataType type)
Sets the data type.
void setName(const QString &name)
Sets the name of the property.
QString origin() const
Returns the origin of the property.
void setComment(const QString &comment)
Sets comment of the property.
DataType
Valid data types required by property.
@ DataTypeString
Property requires a string value.
@ DataTypeBoolean
Property requires a boolean value.
@ DataTypeNumeric
Property requires a numeric value.
A store for object properties.
QDateTime valueAsDateTime(const QgsExpressionContext &context, const QDateTime &defaultDateTime=QDateTime(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a datetime.
QColor valueAsColor(const QgsExpressionContext &context, const QColor &defaultColor=QColor(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a color.
bool isProjectColor() const
Returns true if the property is set to a linked project color.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const
Returns the set of any fields referenced by the property for a specified expression context.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
static QVariantMap propertyMapToVariantMap(const QMap< QString, QgsProperty > &propertyMap)
Convert a map of QgsProperty to a map of QVariant This is useful to save a map of properties.
QString expressionString() const
Returns the expression used for the property value.
bool convertToTransformer()
Attempts to convert an existing expression based property to a base expression with corresponding tra...
void setTransformer(QgsPropertyTransformer *transformer)
Sets an optional transformer to use for manipulating the calculated values for the property.
void setStaticValue(const QVariant &value)
Sets the static value for the property.
Qgis::PropertyType propertyType() const
Returns the property type.
QString valueAsString(const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a string.
QString field() const
Returns the current field name the property references.
const QgsPropertyTransformer * transformer() const
Returns the existing transformer used for manipulating the calculated values for the property,...
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
QVariant toVariant() const
Saves this property to a QVariantMap, wrapped in a QVariant.
bool isActive() const
Returns whether the property is currently active.
double valueAsDouble(const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as a double.
static QMap< QString, QgsProperty > variantMapToPropertyMap(const QVariantMap &variantMap)
Convert a map of QVariant to a map of QgsProperty This is useful to restore a map of properties.
void setField(const QString &field)
Sets the field name the property references.
int valueAsInt(const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an integer.
bool valueAsBool(const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property and interprets it as an boolean.
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const
Prepares the property against a specified expression context.
bool loadVariant(const QVariant &property)
Loads this property from a QVariantMap, wrapped in a QVariant.
QVariant staticValue() const
Returns the current static value for the property.
bool isStaticValueInContext(const QgsExpressionContext &context, QVariant &staticValue) const
Returns true if the property is effectively a static value in the specified context.
void setExpressionString(const QString &expression)
Sets the expression to use for the property value.
QgsProperty & operator=(const QgsProperty &other)
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
QgsProperty()
Constructor for a QgsProperty.
static QgsProperty fromValue(const QVariant &value, bool isActive=true)
Returns a new StaticProperty created from the specified value.
void setActive(bool active)
Sets whether the property is currently active.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)