QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsdatadefined.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdatadefined.h - Data defined container class
3  --------------------------------------
4  Date : 9-May-2013
5  Copyright : (C) 2013 by Larry Shaffer
6  Email : larrys at dakcarto dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSDATADEFINED_H
16 #define QGSDATADEFINED_H
17 
18 #include "qgsfield.h"
19 #include "qgsvectorlayer.h"
20 
21 #include <QStringList>
22 
23 class QgsExpression;
24 
25 
32 class CORE_EXPORT QgsDataDefined
33 {
34  public:
43  QgsDataDefined( bool active = false,
44  bool useexpr = false,
45  const QString& expr = QString(),
46  const QString& field = QString() );
47 
48  ~QgsDataDefined();
49 
50  bool isActive() const { return mActive; }
51  void setActive( bool active ) { mActive = active; }
52 
53  bool useExpression() const { return mUseExpression; }
54  void setUseExpression( bool use ) { mUseExpression = use; }
55 
56  QString expressionString() const { return mExpressionString; }
57  void setExpressionString( const QString& expr );
58 
59  // @note not available in python bindings
60  QMap<QString, QVariant> expressionParams() const { return mExpressionParams; }
61  // @note not available in python bindings
62  void setExpressionParams( QMap<QString, QVariant> params ) { mExpressionParams = params; }
63  void insertExpressionParam( QString key, QVariant param );
64 
65  bool prepareExpression( QgsVectorLayer* layer );
66  bool expressionIsPrepared() const { return mExpressionPrepared; }
67 
68  QgsExpression* expression() { return mExpression; }
69  QStringList referencedColumns( QgsVectorLayer* layer );
70 
71  QString field() const { return mField; }
72  void setField( const QString& field ) { mField = field; }
73 
74  // @note not available in python bindings
75  QMap< QString, QString > toMap();
76 
77  private:
78  QgsExpression* mExpression;
79 
80  bool mActive;
81  bool mUseExpression;
82  QString mExpressionString;
83  QString mField;
84 
85  QMap<QString, QVariant> mExpressionParams;
86  bool mExpressionPrepared;
87  QStringList mExprRefColmuns;
88 };
89 
90 #endif // QGSDATADEFINED_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:89
void setActive(bool active)
Definition: qgsdatadefined.h:51
A container class for data source field mapping or expression.
Definition: qgsdatadefined.h:32
QgsExpression * expression()
Definition: qgsdatadefined.h:68
QString field() const
Definition: qgsdatadefined.h:71
QString expressionString() const
Definition: qgsdatadefined.h:56
void setUseExpression(bool use)
Definition: qgsdatadefined.h:54
void setField(const QString &field)
Definition: qgsdatadefined.h:72
void setExpressionParams(QMap< QString, QVariant > params)
Definition: qgsdatadefined.h:62
QMap< QString, QVariant > expressionParams() const
Definition: qgsdatadefined.h:60
bool useExpression() const
Definition: qgsdatadefined.h:53
bool expressionIsPrepared() const
Definition: qgsdatadefined.h:66
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:470
bool isActive() const
Definition: qgsdatadefined.h:50