QGIS API Documentation  2.0.1-Dufour
 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 ) { mExpressionString = 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:
79 
80  bool mActive;
83  QString mField;
84 
85  QMap<QString, QVariant> mExpressionParams;
87  QStringList mExprRefColmuns;
88 };
89 
90 #endif // QGSDATADEFINED_H