QGIS API Documentation  2.12.0-Lyon
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 <QStringList>
19 #include <QDomElement>
20 #include <QMap>
21 #include <QExplicitlySharedDataPointer>
22 #include "qgis.h"
23 #include "qgsfield.h"
24 #include "qgsexpressioncontext.h"
25 
26 class QgsExpression;
27 class QgsVectorLayer;
28 class QgsDataDefinedPrivate;
29 
30 
37 class CORE_EXPORT QgsDataDefined
38 {
39  public:
48  QgsDataDefined( bool active = false,
49  bool useexpr = false,
50  const QString& expr = QString(),
51  const QString& field = QString() );
52 
58  explicit QgsDataDefined( const QgsExpression * expression );
59 
66  explicit QgsDataDefined( const QString& string );
67 
72  QgsDataDefined( const QgsDataDefined& other );
73 
81  static QgsDataDefined* fromMap( const QgsStringMap& map, const QString& baseName = QString() );
82 
83  virtual ~QgsDataDefined();
84 
90  bool hasDefaultValues() const;
91 
92  bool isActive() const;
93  void setActive( bool active );
94 
100  bool useExpression() const;
101 
109  void setUseExpression( bool use );
110 
119  QString expressionString() const;
120 
129  void setExpressionString( const QString& expr );
130 
138  QString expressionOrField() const;
139 
141  QMap<QString, QVariant> expressionParams() const;
143  void setExpressionParams( const QMap<QString, QVariant>& params );
144  void insertExpressionParam( const QString& key, const QVariant& param );
145 
150  Q_DECL_DEPRECATED bool prepareExpression( QgsVectorLayer* layer );
151 
157  Q_DECL_DEPRECATED bool prepareExpression( const QgsFields &fields );
158 
164  bool prepareExpression( const QgsExpressionContext &context = QgsExpressionContext() );
165 
169  bool expressionIsPrepared() const;
170 
171  QgsExpression* expression();
172 
176  Q_DECL_DEPRECATED QStringList referencedColumns( QgsVectorLayer* layer );
177 
182  Q_DECL_DEPRECATED QStringList referencedColumns( const QgsFields& fields );
183 
188  QStringList referencedColumns( const QgsExpressionContext& context = QgsExpressionContext() );
189 
198  QString field() const;
199 
206  void setField( const QString& field );
207 
213  QgsStringMap toMap( const QString& baseName = QString() ) const;
214 
222  QDomElement toXmlElement( QDomDocument &document, const QString &elementName ) const;
223 
231  bool setFromXmlElement( const QDomElement& element );
232 
233  bool operator==( const QgsDataDefined &other ) const;
234  bool operator!=( const QgsDataDefined &other ) const;
235 
239  QgsDataDefined& operator=( QgsDataDefined const & rhs );
240 
241  private:
242 
244 
245 };
246 
247 #endif // QGSDATADEFINED_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:92
A container class for data source field mapping or expression.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool operator!=(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Container of fields for a vector layer.
Definition: qgsfield.h:177
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Represents a vector layer which manages a vector based data sets.