QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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 
31 class CORE_EXPORT QgsDataDefined
32 {
33  public:
42  QgsDataDefined( bool active = false,
43  bool useexpr = false,
44  const QString& expr = QString(),
45  const QString& field = QString() );
46 
47  ~QgsDataDefined();
48 
49  bool isActive() const { return mActive; }
50  void setActive( bool active ) { mActive = active; }
51 
52  bool useExpression() const { return mUseExpression; }
53  void setUseExpression( bool use ) { mUseExpression = use; }
54 
55  QString expressionString() const { return mExpressionString; }
56  void setExpressionString( const QString& expr );
57 
58  // @note not available in python bindings
59  QMap<QString, QVariant> expressionParams() const { return mExpressionParams; }
60  // @note not available in python bindings
61  void setExpressionParams( QMap<QString, QVariant> params ) { mExpressionParams = params; }
62  void insertExpressionParam( QString key, QVariant param );
63 
64  bool prepareExpression( QgsVectorLayer* layer );
65  bool expressionIsPrepared() const { return mExpressionPrepared; }
66 
67  QgsExpression* expression() { return mExpression; }
68  QStringList referencedColumns( QgsVectorLayer* layer );
69 
70  QString field() const { return mField; }
71  void setField( const QString& field ) { mField = field; }
72 
73  // @note not available in python bindings
74  QMap< QString, QString > toMap();
75 
76  private:
77  QgsExpression* mExpression;
78 
79  bool mActive;
80  bool mUseExpression;
81  QString mExpressionString;
82  QString mField;
83 
84  QMap<QString, QVariant> mExpressionParams;
85  bool mExpressionPrepared;
86  QStringList mExprRefColmuns;
87 };
88 
89 #endif // QGSDATADEFINED_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:87
void setActive(bool active)
Definition: qgsdatadefined.h:50
A container class for data source field mapping or expression.
Definition: qgsdatadefined.h:31
QgsExpression * expression()
Definition: qgsdatadefined.h:67
QString field() const
Definition: qgsdatadefined.h:70
QString expressionString() const
Definition: qgsdatadefined.h:55
void setUseExpression(bool use)
Definition: qgsdatadefined.h:53
void setField(const QString &field)
Definition: qgsdatadefined.h:71
void setExpressionParams(QMap< QString, QVariant > params)
Definition: qgsdatadefined.h:61
QMap< QString, QVariant > expressionParams() const
Definition: qgsdatadefined.h:59
bool useExpression() const
Definition: qgsdatadefined.h:52
bool expressionIsPrepared() const
Definition: qgsdatadefined.h:65
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:468
bool isActive() const
Definition: qgsdatadefined.h:49