QGIS API Documentation
2.18.21-Las Palmas (9fba24a)
|
A container class for data source field mapping or expression. More...
#include <qgsdatadefined.h>
Public Member Functions | |
QgsDataDefined (bool active=false, bool useexpr=false, const QString &expr=QString(), const QString &field=QString()) | |
Construct a new data defined object. More... | |
QgsDataDefined (const QgsExpression *expression) | |
Construct a new data defined object, analysing the expression to determine if it's a simple field reference or an expression. More... | |
QgsDataDefined (const QString &string) | |
Construct a new data defined object, analysing the string to determine if it's a simple field reference or an expression. More... | |
QgsDataDefined (const QgsDataDefined &other) | |
Copy constructor. More... | |
virtual | ~QgsDataDefined () |
QgsExpression * | expression () |
bool | expressionIsPrepared () const |
Returns whether the data defined object's expression is prepared. More... | |
QString | expressionOrField () const |
Returns an expression which represents a single field if useExpression returns false, otherwise returns the current expression string. More... | |
QMap< QString, QVariant > | expressionParams () const |
QString | expressionString () const |
Returns the expression string of this QgsDataDefined. More... | |
QString | field () const |
Get the field which this QgsDataDefined represents. More... | |
bool | hasDefaultValues () const |
Returns whether the data defined container is set to all the default values, ie, disabled, with empty expression and no assigned field. More... | |
void | insertExpressionParam (const QString &key, const QVariant ¶m) |
bool | isActive () const |
bool | operator!= (const QgsDataDefined &other) const |
QgsDataDefined & | operator= (QgsDataDefined const &rhs) |
Assignment operator. More... | |
bool | operator== (const QgsDataDefined &other) const |
Q_DECL_DEPRECATED bool | prepareExpression (QgsVectorLayer *layer) |
Prepares the expression using a vector layer. More... | |
Q_DECL_DEPRECATED bool | prepareExpression (const QgsFields &fields) |
Prepares the expression using a fields collection. More... | |
bool | prepareExpression (const QgsExpressionContext &context=QgsExpressionContext()) |
Prepares the expression using an expression context. More... | |
Q_DECL_DEPRECATED QStringList | referencedColumns (QgsVectorLayer *layer) |
Returns the columns referenced by the QgsDataDefined. More... | |
Q_DECL_DEPRECATED QStringList | referencedColumns (const QgsFields &fields) |
Returns the columns referenced by the QgsDataDefined. More... | |
QStringList | referencedColumns (const QgsExpressionContext &context=QgsExpressionContext()) |
Returns the columns referenced by the QgsDataDefined. More... | |
void | setActive (bool active) |
void | setExpressionParams (const QMap< QString, QVariant > ¶ms) |
void | setExpressionString (const QString &expr) |
Sets the expression for this QgsDataDefined. More... | |
void | setField (const QString &field) |
Set the field name which this QgsDataDefined represents. More... | |
bool | setFromXmlElement (const QDomElement &element) |
Sets the properties of the data defined container from an XML element. More... | |
void | setUseExpression (bool use) |
Controls if the field or the expression part is active. More... | |
QgsStringMap | toMap (const QString &baseName=QString()) const |
Encodes the QgsDataDefined into a string map. More... | |
QDomElement | toXmlElement (QDomDocument &document, const QString &elementName) const |
Returns a DOM element containing the properties of the data defined container. More... | |
bool | useExpression () const |
Returns if the field or the expression part is active. More... | |
Static Public Member Functions | |
static QgsDataDefined * | fromMap (const QgsStringMap &map, const QString &baseName=QString()) |
Creates a QgsDataDefined from a decoded QgsStringMap. More... | |
A container class for data source field mapping or expression.
Definition at line 37 of file qgsdatadefined.h.
QgsDataDefined::QgsDataDefined | ( | bool | active = false , |
bool | useexpr = false , |
||
const QString & | expr = QString() , |
||
const QString & | field = QString() |
||
) |
Construct a new data defined object.
active | Whether the current data defined is active |
useexpr | Whether to use expression instead of field |
expr | Expression string |
field | Field name string |
Definition at line 24 of file qgsdatadefined.cpp.
|
explicit |
Construct a new data defined object, analysing the expression to determine if it's a simple field reference or an expression.
expression | can be null |
Definition at line 32 of file qgsdatadefined.cpp.
QgsDataDefined::QgsDataDefined | ( | const QString & | string | ) |
Construct a new data defined object, analysing the string to determine if it's a simple field reference or an expression.
string | field reference or an expression, can be empty |
Definition at line 70 of file qgsdatadefined.cpp.
QgsDataDefined::QgsDataDefined | ( | const QgsDataDefined & | other | ) |
Copy constructor.
Note that copies of data defined objects with expressions will not be prepared.
Definition at line 42 of file qgsdatadefined.cpp.
|
virtual |
Definition at line 82 of file qgsdatadefined.cpp.
QgsExpression * QgsDataDefined::expression | ( | ) |
Definition at line 223 of file qgsdatadefined.cpp.
bool QgsDataDefined::expressionIsPrepared | ( | ) | const |
Returns whether the data defined object's expression is prepared.
Definition at line 218 of file qgsdatadefined.cpp.
QString QgsDataDefined::expressionOrField | ( | ) | const |
Returns an expression which represents a single field if useExpression returns false, otherwise returns the current expression string.
Definition at line 140 of file qgsdatadefined.cpp.
Definition at line 145 of file qgsdatadefined.cpp.
QString QgsDataDefined::expressionString | ( | ) | const |
Returns the expression string of this QgsDataDefined.
Definition at line 122 of file qgsdatadefined.cpp.
QString QgsDataDefined::field | ( | ) | const |
Get the field which this QgsDataDefined represents.
Be aware that this may return a field name which may not be active if useExpression is true.
Definition at line 273 of file qgsdatadefined.cpp.
|
static |
Creates a QgsDataDefined from a decoded QgsStringMap.
map | string map encoding of QgsDataDefined |
baseName | base name for values in the string map |
Definition at line 48 of file qgsdatadefined.cpp.
bool QgsDataDefined::hasDefaultValues | ( | ) | const |
Returns whether the data defined container is set to all the default values, ie, disabled, with empty expression and no assigned field.
Definition at line 87 of file qgsdatadefined.cpp.
Definition at line 289 of file qgsdatadefined.cpp.
bool QgsDataDefined::isActive | ( | ) | const |
Definition at line 92 of file qgsdatadefined.cpp.
bool QgsDataDefined::operator!= | ( | const QgsDataDefined & | other | ) | const |
Definition at line 344 of file qgsdatadefined.cpp.
QgsDataDefined & QgsDataDefined::operator= | ( | QgsDataDefined const & | rhs | ) |
Assignment operator.
Note that after assignment the data defined object's expression will not be prepared.
Definition at line 349 of file qgsdatadefined.cpp.
bool QgsDataDefined::operator== | ( | const QgsDataDefined & | other | ) | const |
Definition at line 339 of file qgsdatadefined.cpp.
bool QgsDataDefined::prepareExpression | ( | QgsVectorLayer * | layer | ) |
Prepares the expression using a vector layer.
layer | vector layer |
Definition at line 156 of file qgsdatadefined.cpp.
bool QgsDataDefined::prepareExpression | ( | const QgsFields & | fields | ) |
Prepares the expression using a fields collection.
fields |
Definition at line 170 of file qgsdatadefined.cpp.
bool QgsDataDefined::prepareExpression | ( | const QgsExpressionContext & | context = QgsExpressionContext() | ) |
Prepares the expression using an expression context.
context | expression context |
Definition at line 175 of file qgsdatadefined.cpp.
QStringList QgsDataDefined::referencedColumns | ( | QgsVectorLayer * | layer | ) |
Returns the columns referenced by the QgsDataDefined.
layer | vector layer, used for preparing the expression if required |
Definition at line 232 of file qgsdatadefined.cpp.
QStringList QgsDataDefined::referencedColumns | ( | const QgsFields & | fields | ) |
Returns the columns referenced by the QgsDataDefined.
fields | vector layer, used for preparing the expression if required |
Definition at line 245 of file qgsdatadefined.cpp.
QStringList QgsDataDefined::referencedColumns | ( | const QgsExpressionContext & | context = QgsExpressionContext() | ) |
Returns the columns referenced by the QgsDataDefined.
context | expression context, used for preparing the expression if required |
Definition at line 250 of file qgsdatadefined.cpp.
void QgsDataDefined::setActive | ( | bool | active | ) |
Definition at line 97 of file qgsdatadefined.cpp.
Definition at line 150 of file qgsdatadefined.cpp.
void QgsDataDefined::setExpressionString | ( | const QString & | expr | ) |
Sets the expression for this QgsDataDefined.
Will also set useExpression to true.
expr | The expression to set |
Definition at line 127 of file qgsdatadefined.cpp.
void QgsDataDefined::setField | ( | const QString & | field | ) |
Set the field name which this QgsDataDefined represents.
Will set useExpression to false.
field |
Definition at line 278 of file qgsdatadefined.cpp.
bool QgsDataDefined::setFromXmlElement | ( | const QDomElement & | element | ) |
Sets the properties of the data defined container from an XML element.
Calling this will overwrite all the current properties of the container.
element | DOM element |
Definition at line 322 of file qgsdatadefined.cpp.
void QgsDataDefined::setUseExpression | ( | bool | use | ) |
Controls if the field or the expression part is active.
For QGIS<=2.10 it is mandatory to call this after setExpressionString or setField.
use | True if it should be set to expression mode. |
Definition at line 111 of file qgsdatadefined.cpp.
QgsStringMap QgsDataDefined::toMap | ( | const QString & | baseName = QString() | ) | const |
Encodes the QgsDataDefined into a string map.
baseName | optional base name for values in the string map. Can be used to differentiate multiple QgsDataDefineds encoded in the same string map. |
Definition at line 295 of file qgsdatadefined.cpp.
QDomElement QgsDataDefined::toXmlElement | ( | QDomDocument & | document, |
const QString & | elementName | ||
) | const |
Returns a DOM element containing the properties of the data defined container.
document | DOM document |
elementName | name for DOM element |
Definition at line 312 of file qgsdatadefined.cpp.
bool QgsDataDefined::useExpression | ( | ) | const |
Returns if the field or the expression part is active.
Definition at line 106 of file qgsdatadefined.cpp.