QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
QgsDataDefined Class Reference

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 ()
 
QgsExpressionexpression ()
 
bool expressionIsPrepared () const
 Returns whether the data defined object's expression is prepared. More...
 
QMap< QString, QVariantexpressionParams () const
 
QString expressionString () const
 
QString field () const
 
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 (QString key, QVariant param)
 
bool isActive () const
 
bool operator!= (const QgsDataDefined &other) const
 
QgsDataDefinedoperator= (QgsDataDefined const &rhs)
 Assignment operator. More...
 
bool operator== (const QgsDataDefined &other) const
 
bool prepareExpression (QgsVectorLayer *layer)
 Prepares the expression using a vector layer. More...
 
bool prepareExpression (const QgsFields &fields=QgsFields())
 Prepares the expression using a fields collection. More...
 
QStringList referencedColumns (QgsVectorLayer *layer)
 Returns the columns referenced by the QgsDataDefined. More...
 
QStringList referencedColumns (const QgsFields &fields=QgsFields())
 Returns the columns referenced by the QgsDataDefined. More...
 
void setActive (bool active)
 
void setExpressionParams (QMap< QString, QVariant > params)
 
void setExpressionString (const QString &expr)
 
void setField (const QString &field)
 
bool setFromXmlElement (const QDomElement &element)
 Sets the properties of the data defined container from an XML element. More...
 
void setUseExpression (bool use)
 
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
 

Static Public Member Functions

static QgsDataDefinedfromMap (const QgsStringMap &map, const QString &baseName=QString())
 Creates a QgsDataDefined from a decoded QgsStringMap. More...
 

Detailed Description

A container class for data source field mapping or expression.

Note
QgsDataDefined objects are implicitly shared.

Definition at line 36 of file qgsdatadefined.h.

Constructor & Destructor Documentation

QgsDataDefined::QgsDataDefined ( bool  active = false,
bool  useexpr = false,
const QString expr = QString(),
const QString field = QString() 
)

Construct a new data defined object.

Parameters
activeWhether the current data defined is active
useexprWhether to use expression instead of field
exprExpression string
fieldField name string

Definition at line 24 of file qgsdatadefined.cpp.

QgsDataDefined::QgsDataDefined ( const QgsExpression expression)
explicit

Construct a new data defined object, analysing the expression to determine if it's a simple field reference or an expression.

Parameters
expressioncan be null

Definition at line 32 of file qgsdatadefined.cpp.

QgsDataDefined::QgsDataDefined ( const QString string)
explicit

Construct a new data defined object, analysing the string to determine if it's a simple field reference or an expression.

Parameters
stringfield reference or an expression, can be empty
Note
added in QGIS 2.9

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.

QgsDataDefined::~QgsDataDefined ( )
virtual

Definition at line 82 of file qgsdatadefined.cpp.

Member Function Documentation

QgsExpression * QgsDataDefined::expression ( )

Definition at line 211 of file qgsdatadefined.cpp.

bool QgsDataDefined::expressionIsPrepared ( ) const

Returns whether the data defined object's expression is prepared.

Returns
true if expression is prepared

Definition at line 206 of file qgsdatadefined.cpp.

QMap< QString, QVariant > QgsDataDefined::expressionParams ( ) const

Definition at line 138 of file qgsdatadefined.cpp.

QString QgsDataDefined::expressionString ( ) const

Definition at line 121 of file qgsdatadefined.cpp.

QString QgsDataDefined::field ( ) const

Definition at line 255 of file qgsdatadefined.cpp.

QgsDataDefined * QgsDataDefined::fromMap ( const QgsStringMap map,
const QString baseName = QString() 
)
static

Creates a QgsDataDefined from a decoded QgsStringMap.

Parameters
mapstring map encoding of QgsDataDefined
baseNamebase name for values in the string map
Returns
new QgsDataDefined if string map was successfully interpreted
See Also
toMap
Note
added in QGIS 2.9

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.

Returns
true if data defined container is set to default values
Note
added in QGIS 2.7

Definition at line 87 of file qgsdatadefined.cpp.

void QgsDataDefined::insertExpressionParam ( QString  key,
QVariant  param 
)

Definition at line 270 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 323 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 328 of file qgsdatadefined.cpp.

bool QgsDataDefined::operator== ( const QgsDataDefined other) const

Definition at line 318 of file qgsdatadefined.cpp.

bool QgsDataDefined::prepareExpression ( QgsVectorLayer layer)

Prepares the expression using a vector layer.

Parameters
layervector layer
Returns
true if expression was successfully prepared

Definition at line 149 of file qgsdatadefined.cpp.

bool QgsDataDefined::prepareExpression ( const QgsFields fields = QgsFields())

Prepares the expression using a fields collection.

Parameters
fields
Returns
true if expression was successfully prepared
Note
added in QGIS 2.9

Definition at line 163 of file qgsdatadefined.cpp.

QStringList QgsDataDefined::referencedColumns ( QgsVectorLayer layer)

Returns the columns referenced by the QgsDataDefined.

Parameters
layervector layer, used for preparing the expression if required

Definition at line 220 of file qgsdatadefined.cpp.

QStringList QgsDataDefined::referencedColumns ( const QgsFields fields = QgsFields())

Returns the columns referenced by the QgsDataDefined.

Parameters
fieldsvector layer, used for preparing the expression if required
Note
added in QGIS 2.9

Definition at line 232 of file qgsdatadefined.cpp.

void QgsDataDefined::setActive ( bool  active)

Definition at line 97 of file qgsdatadefined.cpp.

void QgsDataDefined::setExpressionParams ( QMap< QString, QVariant params)

Definition at line 143 of file qgsdatadefined.cpp.

void QgsDataDefined::setExpressionString ( const QString expr)

Definition at line 126 of file qgsdatadefined.cpp.

void QgsDataDefined::setField ( const QString field)

Definition at line 260 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.

Parameters
elementDOM element
Returns
true if properties were successfully read from element
Note
added in QGIS 2.7
See Also
toXmlElement

Definition at line 303 of file qgsdatadefined.cpp.

void QgsDataDefined::setUseExpression ( bool  use)

Definition at line 111 of file qgsdatadefined.cpp.

QgsStringMap QgsDataDefined::toMap ( const QString baseName = QString()) const

Encodes the QgsDataDefined into a string map.

Parameters
baseNameoptional base name for values in the string map. Can be used to differentiate multiple QgsDataDefineds encoded in the same string map.
See Also
fromMap

Definition at line 276 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.

Parameters
documentDOM document
elementNamename for DOM element
Returns
DOM element corresponding to data defined container
Note
added in QGIS 2.7
See Also
setFromXmlElement

Definition at line 293 of file qgsdatadefined.cpp.

bool QgsDataDefined::useExpression ( ) const

Definition at line 106 of file qgsdatadefined.cpp.


The documentation for this class was generated from the following files: