18 #include "qgis_core.h"
27 #include <QStringList>
28 #include <QDomElement>
29 #include <QDomDocument>
34 class QgsPropertyPrivate;
135 QgsPropertyDefinition(
const QString &name,
DataType dataType,
const QString &description,
const QString &helpText,
const QString &origin = QString(),
const QString &comment = QString() );
140 QString
name()
const {
return mName; }
145 void setName(
const QString &name ) { mName = name; }
152 QString
origin()
const {
return mOrigin; }
159 void setOrigin(
const QString &origin ) { mOrigin = origin; }
174 void setComment(
const QString &comment ) { mComment = comment; }
201 bool supportsAssistant()
const;
206 QString mDescription;
207 DataType mTypes = DataTypeString;
209 StandardPropertyTemplate mStandardType = Custom;
213 static QString trString();
249 static QVariantMap propertyMapToVariantMap(
const QMap<QString, QgsProperty> &propertyMap );
257 static QMap<QString, QgsProperty> variantMapToPropertyMap(
const QVariantMap &variantMap );
269 static QgsProperty fromExpression(
const QString &expression,
bool isActive =
true );
274 static QgsProperty fromField(
const QString &fieldName,
bool isActive =
true );
279 static QgsProperty fromValue(
const QVariant &value,
bool isActive =
true );
289 operator bool()
const;
297 Type propertyType()
const;
303 bool isActive()
const;
309 void setActive(
bool active );
316 void setStaticValue(
const QVariant &value );
323 QVariant staticValue()
const;
330 void setField(
const QString &
field );
337 QString
field()
const;
344 void setExpressionString(
const QString &expression );
351 QString expressionString()
const;
357 QString asExpression()
const;
380 bool isProjectColor()
const;
396 QVariant value(
const QgsExpressionContext &context,
const QVariant &defaultValue = QVariant(),
bool *ok
SIP_OUT =
nullptr )
const;
412 QDateTime valueAsDateTime(
const QgsExpressionContext &context,
const QDateTime &defaultDateTime = QDateTime(),
bool *ok
SIP_OUT =
nullptr )
const;
427 QString valueAsString(
const QgsExpressionContext &context,
const QString &defaultString = QString(),
bool *ok
SIP_OUT =
nullptr )
const;
442 QColor valueAsColor(
const QgsExpressionContext &context,
const QColor &defaultColor = QColor(),
bool *ok
SIP_OUT =
nullptr )
const;
495 QVariant toVariant()
const;
503 bool loadVariant(
const QVariant &property );
525 bool convertToTransformer();
528 operator QVariant()
const
530 return QVariant::fromValue( *
this );
535 SIP_PYOBJECT __repr__();
538 QString definitionString;
539 switch ( sipCpp->propertyType() )
542 typeString = QStringLiteral(
"static" );
543 definitionString = sipCpp->staticValue().toString();
547 typeString = QStringLiteral(
"field" );
548 definitionString = sipCpp->field();
552 typeString = QStringLiteral(
"expression" );
553 definitionString = sipCpp->expressionString();
557 typeString = QStringLiteral(
"invalid" );
561 QString
str = QStringLiteral(
"<QgsProperty: %1%2%3>" ).arg( !sipCpp->isActive() && sipCpp->propertyType() !=
QgsProperty::InvalidProperty ? QStringLiteral(
"INACTIVE " ) : QString(),
563 definitionString.isEmpty() ? QString() : QStringLiteral(
" (%1)" ).arg( definitionString ) );
564 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
570 mutable QExplicitlySharedDataPointer<QgsPropertyPrivate> d;
576 QVariant propertyValue(
const QgsExpressionContext &context,
const QVariant &defaultValue = QVariant(),
bool *ok =
nullptr )
const;
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition for a property.
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)
@ CapStyle
Line cap style (eg round)
@ ColorNoAlpha
Color with no alpha channel.
@ Rotation
Rotation (value between 0-360 degrees)
@ 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.
@ DataTypeBoolean
Property requires a boolean value.
@ DataTypeNumeric
Property requires a numeric value.
A store for object properties.
@ ExpressionBasedProperty
Expression based property (QgsExpressionBasedProperty)
@ StaticProperty
Static property (QgsStaticProperty)
@ FieldBasedProperty
Field based property (QgsFieldBasedProperty)
@ InvalidProperty
Invalid (not set) property.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Q_DECLARE_METATYPE(QgsMeshTimeSettings)