QGIS API Documentation  2.9.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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, analyse the expression to determine if it's a simple field. More...
 
 QgsDataDefined (const QgsDataDefined &other)
 Copy constructor. More...
 
 ~QgsDataDefined ()
 
QgsExpressionexpression ()
 
bool expressionIsPrepared () const
 Returns whether the data defined object's expression is prepared. More...
 
QMap< QString, QVariant > expressionParams () 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)
 Prepares the expression using a fields collection. More...
 
QStringList referencedColumns (QgsVectorLayer *layer)
 
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)
 
QMap< QString, QString > toMap ()
 
QDomElement toXmlElement (QDomDocument &document, const QString &elementName) const
 Returns a DOM element containing the properties of the data defined container. More...
 
bool useExpression () const
 

Detailed Description

A container class for data source field mapping or expression.

Definition at line 31 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 23 of file qgsdatadefined.cpp.

QgsDataDefined::QgsDataDefined ( const QgsExpression expression)
explicit

Construct a new data defined object, analyse the expression to determine if it's a simple field.

Parameters
expressioncan be null

Definition at line 36 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 46 of file qgsdatadefined.cpp.

QgsDataDefined::~QgsDataDefined ( )

Definition at line 58 of file qgsdatadefined.cpp.

Member Function Documentation

QgsExpression* QgsDataDefined::expression ( )
inline

Definition at line 103 of file qgsdatadefined.h.

bool QgsDataDefined::expressionIsPrepared ( ) const
inline

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

Returns
true if expression is prepared

Definition at line 101 of file qgsdatadefined.h.

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

Definition at line 80 of file qgsdatadefined.h.

QString QgsDataDefined::expressionString ( ) const
inline

Definition at line 76 of file qgsdatadefined.h.

QString QgsDataDefined::field ( ) const
inline

Definition at line 106 of file qgsdatadefined.h.

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 63 of file qgsdatadefined.cpp.

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

Definition at line 150 of file qgsdatadefined.cpp.

bool QgsDataDefined::isActive ( ) const
inline

Definition at line 70 of file qgsdatadefined.h.

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

Definition at line 196 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 201 of file qgsdatadefined.cpp.

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

Definition at line 190 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 74 of file qgsdatadefined.cpp.

bool QgsDataDefined::prepareExpression ( const QgsFields fields)

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 88 of file qgsdatadefined.cpp.

QStringList QgsDataDefined::referencedColumns ( QgsVectorLayer layer)

Definition at line 128 of file qgsdatadefined.cpp.

void QgsDataDefined::setActive ( bool  active)
inline

Definition at line 71 of file qgsdatadefined.h.

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

Definition at line 82 of file qgsdatadefined.h.

void QgsDataDefined::setExpressionString ( const QString &  expr)

Definition at line 68 of file qgsdatadefined.cpp.

void QgsDataDefined::setField ( const QString &  field)
inline

Definition at line 107 of file qgsdatadefined.h.

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 176 of file qgsdatadefined.cpp.

void QgsDataDefined::setUseExpression ( bool  use)
inline

Definition at line 74 of file qgsdatadefined.h.

QMap< QString, QString > QgsDataDefined::toMap ( )

Definition at line 155 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 166 of file qgsdatadefined.cpp.

bool QgsDataDefined::useExpression ( ) const
inline

Definition at line 73 of file qgsdatadefined.h.


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