Quantum GIS API Documentation  1.8
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
QgsAttributeAction Class Reference

Storage and management of actions associated with Qgis layer attributes. More...

#include <qgsattributeaction.h>

Collaboration diagram for QgsAttributeAction:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 QgsAttributeAction (QgsVectorLayer *layer)
 Constructor.
virtual ~QgsAttributeAction ()
 Destructor.
void addAction (QgsAction::ActionType type, QString name, QString action, bool capture=false)
 Add an action with the given name and action details.
Q_DECL_DEPRECATED void doAction (int index, const QgsAttributeMap &attributes, int defaultValueIndex=0, void(*executePython)(const QString &)=0)
void doAction (int index, QgsFeature &feat, int defaultValueIndex=0)
void doAction (int index, QgsFeature &feat, const QMap< QString, QVariant > *substitutionMap=0)
void clearActions ()
 Removes all actions.
QgsVectorLayerlayer ()
 Return the layer.
QString expandAction (QString action, const QgsAttributeMap &attributes, uint defaultValueIndex)
QString expandAction (QString action, QgsFeature &feat, const QMap< QString, QVariant > *substitutionMap=0)
bool writeXML (QDomNode &layer_node, QDomDocument &doc) const
 Writes the actions out in XML format.
bool readXML (const QDomNode &layer_node)
 Reads the actions in in XML format.
int size () const
QgsActionat (int idx)
QgsActionoperator[] (int idx)
int defaultAction () const
 Whether the action is the default action.
void setDefaultAction (int actionNumber)

Static Public Member Functions

static void setPythonExecute (void(*)(const QString &))

Private Member Functions

void runAction (const QgsAction &action, void(*executePython)(const QString &)=0)

Private Attributes

QList< QgsActionmActions
QgsVectorLayermLayer
int mDefaultAction

Static Private Attributes

static void(* smPythonExecute )(const QString &)

Detailed Description

Storage and management of actions associated with Qgis layer attributes.

Definition at line 96 of file qgsattributeaction.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 100 of file qgsattributeaction.h.

virtual QgsAttributeAction::~QgsAttributeAction ( ) [inline, virtual]

Destructor.

Definition at line 103 of file qgsattributeaction.h.


Member Function Documentation

void QgsAttributeAction::addAction ( QgsAction::ActionType  type,
QString  name,
QString  action,
bool  capture = false 
)

Add an action with the given name and action details.

Definition at line 43 of file qgsattributeaction.cpp.

References mActions.

Referenced by readXML().

QgsAction& QgsAttributeAction::at ( int  idx) [inline]

Definition at line 174 of file qgsattributeaction.h.

Referenced by doAction().

Removes all actions.

Definition at line 142 of file qgsattributeaction.h.

int QgsAttributeAction::defaultAction ( ) const [inline]

Whether the action is the default action.

Definition at line 181 of file qgsattributeaction.h.

References size.

void QgsAttributeAction::doAction ( int  index,
const QgsAttributeMap attributes,
int  defaultValueIndex = 0,
void(*)(const QString &)  executePython = 0 
)

Does the action using the given values. defaultValueIndex is an index into values which indicates which value in the values vector is to be used if the action has a default placeholder.

Note:
parameter executePython deprecated (and missing in python binding)
Deprecated:

Definition at line 48 of file qgsattributeaction.cpp.

References QgsAction::action(), at(), QgsAction::capture(), expandAction(), QgsAction::name(), QgsAction::runable(), runAction(), size(), and QgsAction::type().

Referenced by doAction().

void QgsAttributeAction::doAction ( int  index,
QgsFeature feat,
int  defaultValueIndex = 0 
)

Does the given values. defaultValueIndex is the index of the field to be used if the action has a $currfield placeholder.

Note:
added in 1.9

Definition at line 76 of file qgsattributeaction.cpp.

References QgsFeature::attributeMap(), and doAction().

void QgsAttributeAction::doAction ( int  index,
QgsFeature feat,
const QMap< QString, QVariant > *  substitutionMap = 0 
)

Does the action using the expression builder to expand it and getting values from the passed feature attribute map. substitutionMap is used to pass custom substitutions, to replace each key in the map with the associated value

Note:
added in 1.9

Definition at line 88 of file qgsattributeaction.cpp.

References QgsAction::action(), at(), QgsAction::capture(), expandAction(), QgsAction::name(), QgsAction::runable(), runAction(), size(), and QgsAction::type().

QString QgsAttributeAction::expandAction ( QString  action,
const QgsAttributeMap attributes,
uint  defaultValueIndex 
)

Expands the given action, replacing all 's with the value as given.

Definition at line 143 of file qgsattributeaction.cpp.

References QgsVectorLayer::attributeDisplayName(), mLayer, and QgsVectorLayer::pendingFields().

Referenced by doAction().

QString QgsAttributeAction::expandAction ( QString  action,
QgsFeature feat,
const QMap< QString, QVariant > *  substitutionMap = 0 
)

Expands the given action using the expression builder This function currently replaces each expression between [% and %] placeholders in the action with the result of its evaluation on the feature passed as argument.

Additional substitutions can be passed through the substitutionMap parameter

Note:
added in 1.9

Definition at line 193 of file qgsattributeaction.cpp.

References QgsExpression::evalErrorString(), QgsExpression::evaluate(), QgsExpression::hasEvalError(), QgsExpression::hasParserError(), mLayer, QgsExpression::parserErrorString(), QgsVectorLayer::pendingFields(), and QgsDebugMsg.

Return the layer.

Definition at line 145 of file qgsattributeaction.h.

QgsAction& QgsAttributeAction::operator[] ( int  idx) [inline]

Definition at line 175 of file qgsattributeaction.h.

bool QgsAttributeAction::readXML ( const QDomNode &  layer_node)

Reads the actions in in XML format.

Definition at line 268 of file qgsattributeaction.cpp.

References addAction(), and mActions.

Referenced by QgsVectorLayer::readSymbology().

void QgsAttributeAction::runAction ( const QgsAction action,
void(*)(const QString &)  executePython = 0 
) [private]
void QgsAttributeAction::setDefaultAction ( int  actionNumber) [inline]

Definition at line 182 of file qgsattributeaction.h.

void QgsAttributeAction::setPythonExecute ( void(*)(const QString &)  runPython) [static]
Deprecated:
Initialize QgsPythonRunner instead

Definition at line 291 of file qgsattributeaction.cpp.

References smPythonExecute.

int QgsAttributeAction::size ( ) const [inline]

Definition at line 173 of file qgsattributeaction.h.

Referenced by doAction().

bool QgsAttributeAction::writeXML ( QDomNode &  layer_node,
QDomDocument &  doc 
) const

Writes the actions out in XML format.

Definition at line 250 of file qgsattributeaction.cpp.

References mActions.

Referenced by QgsVectorLayer::writeSymbology().


Member Data Documentation

Definition at line 185 of file qgsattributeaction.h.

Referenced by addAction(), readXML(), and writeXML().

Definition at line 192 of file qgsattributeaction.h.

Definition at line 186 of file qgsattributeaction.h.

Referenced by expandAction().

void(* QgsAttributeAction::smPythonExecute)(const QString &)=0 [static, private]

Definition at line 187 of file qgsattributeaction.h.

Referenced by runAction(), and setPythonExecute().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines