18 #include "qgis_core.h"
26 #include <QStringList>
27 #include <QDomElement>
28 #include <QDomDocument>
33 class QgsPropertyPrivate;
122 QgsPropertyDefinition(
const QString &name,
const QString &description, StandardPropertyTemplate type,
const QString &origin = QString(),
const QString &comment = QString() );
134 QgsPropertyDefinition(
const QString &name, DataType dataType,
const QString &description,
const QString &helpText,
const QString &origin = QString(),
const QString &comment = QString() );
139 QString
name()
const {
return mName; }
144 void setName(
const QString &name ) { mName = name; }
151 QString
origin()
const {
return mOrigin; }
158 void setOrigin(
const QString &origin ) { mOrigin = origin; }
173 void setComment(
const QString &comment ) { mComment = comment; }
200 bool supportsAssistant()
const;
205 QString mDescription;
206 DataType mTypes = DataTypeString;
208 StandardPropertyTemplate mStandardType = Custom;
212 static QString trString();
248 static QVariantMap propertyMapToVariantMap(
const QMap<QString, QgsProperty> &propertyMap );
256 static QMap<QString, QgsProperty> variantMapToPropertyMap(
const QVariantMap &variantMap );
268 static QgsProperty fromExpression(
const QString &expression,
bool isActive =
true );
273 static QgsProperty fromField(
const QString &fieldName,
bool isActive =
true );
278 static QgsProperty fromValue(
const QVariant &value,
bool isActive =
true );
288 operator bool()
const;
296 Type propertyType()
const;
302 bool isActive()
const;
324 void setActive(
bool active );
331 void setStaticValue(
const QVariant &value );
338 QVariant staticValue()
const;
345 void setField(
const QString &
field );
352 QString
field()
const;
359 void setExpressionString(
const QString &expression );
366 QString expressionString()
const;
372 QString asExpression()
const;
395 bool isProjectColor()
const;
411 QVariant value(
const QgsExpressionContext &context,
const QVariant &defaultValue = QVariant(),
bool *ok
SIP_OUT =
nullptr )
const;
427 QDateTime valueAsDateTime(
const QgsExpressionContext &context,
const QDateTime &defaultDateTime = QDateTime(),
bool *ok
SIP_OUT =
nullptr )
const;
442 QString valueAsString(
const QgsExpressionContext &context,
const QString &defaultString = QString(),
bool *ok
SIP_OUT =
nullptr )
const;
457 QColor valueAsColor(
const QgsExpressionContext &context,
const QColor &defaultColor = QColor(),
bool *ok
SIP_OUT =
nullptr )
const;
510 QVariant toVariant()
const;
518 bool loadVariant(
const QVariant &property );
540 bool convertToTransformer();
543 operator QVariant()
const
545 return QVariant::fromValue( *
this );
550 SIP_PYOBJECT __repr__();
553 QString definitionString;
554 switch ( sipCpp->propertyType() )
557 typeString = QStringLiteral(
"static" );
558 definitionString = sipCpp->staticValue().toString();
562 typeString = QStringLiteral(
"field" );
563 definitionString = sipCpp->field();
567 typeString = QStringLiteral(
"expression" );
568 definitionString = sipCpp->expressionString();
572 typeString = QStringLiteral(
"invalid" );
576 QString
str = QStringLiteral(
"<QgsProperty: %1%2%3>" ).arg( !sipCpp->isActive() && sipCpp->propertyType() !=
QgsProperty::InvalidProperty ? QStringLiteral(
"INACTIVE " ) : QString(),
578 definitionString.isEmpty() ? QString() : QStringLiteral(
" (%1)" ).arg( definitionString ) );
579 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
585 mutable QExplicitlySharedDataPointer<QgsPropertyPrivate> d;
591 QVariant propertyValue(
const QgsExpressionContext &context,
const QVariant &defaultValue = QVariant(),
bool *ok =
nullptr )
const;
597 #endif // QGSPROPERTY_H