QGIS API Documentation  2.7.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 
54  bool hasDefaultValues() const;
55 
56  bool isActive() const { return mActive; }
57  void setActive( bool active ) { mActive = active; }
58 
59  bool useExpression() const { return mUseExpression; }
60  void setUseExpression( bool use ) { mUseExpression = use; }
61 
62  QString expressionString() const { return mExpressionString; }
63  void setExpressionString( const QString& expr );
64 
65  // @note not available in python bindings
66  QMap<QString, QVariant> expressionParams() const { return mExpressionParams; }
67  // @note not available in python bindings
68  void setExpressionParams( QMap<QString, QVariant> params ) { mExpressionParams = params; }
69  void insertExpressionParam( QString key, QVariant param );
70 
71  bool prepareExpression( QgsVectorLayer* layer );
72  bool expressionIsPrepared() const { return mExpressionPrepared; }
73 
74  QgsExpression* expression() { return mExpression; }
75  QStringList referencedColumns( QgsVectorLayer* layer );
76 
77  QString field() const { return mField; }
78  void setField( const QString& field ) { mField = field; }
79 
80  // @note not available in python bindings
81  QMap< QString, QString > toMap();
82 
90  QDomElement toXmlElement( QDomDocument &document, const QString &elementName ) const;
91 
99  bool setFromXmlElement( const QDomElement& element );
100 
101  bool operator==( const QgsDataDefined &other ) const;
102  bool operator!=( const QgsDataDefined &other ) const;
103 
104  private:
105  QgsExpression* mExpression;
106 
107  bool mActive;
108  bool mUseExpression;
109  QString mExpressionString;
110  QString mField;
111 
112  QMap<QString, QVariant> mExpressionParams;
113  bool mExpressionPrepared;
114  QStringList mExprRefColmuns;
115 };
116 
117 #endif // QGSDATADEFINED_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:87
void setActive(bool active)
A container class for data source field mapping or expression.
QgsExpression * expression()
QString field() const
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QString expressionString() const
void setUseExpression(bool use)
void setField(const QString &field)
void setExpressionParams(QMap< QString, QVariant > params)
QMap< QString, QVariant > expressionParams() const
bool useExpression() const
bool expressionIsPrepared() const
Represents a vector layer which manages a vector based data sets.
bool isActive() const