QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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  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 
151  Q_DECL_DEPRECATED bool prepareExpression( QgsVectorLayer* layer );
152 
159  Q_DECL_DEPRECATED bool prepareExpression( const QgsFields &fields );
160 
166  bool prepareExpression( const QgsExpressionContext &context = QgsExpressionContext() );
167 
171  bool expressionIsPrepared() const;
172 
173  QgsExpression* expression();
174 
179  Q_DECL_DEPRECATED QStringList referencedColumns( QgsVectorLayer* layer );
180 
186  Q_DECL_DEPRECATED QStringList referencedColumns( const QgsFields& fields );
187 
192  QStringList referencedColumns( const QgsExpressionContext& context = QgsExpressionContext() );
193 
202  QString field() const;
203 
210  void setField( const QString& field );
211 
217  QgsStringMap toMap( const QString& baseName = QString() ) const;
218 
226  QDomElement toXmlElement( QDomDocument &document, const QString &elementName ) const;
227 
235  bool setFromXmlElement( const QDomElement& element );
236 
237  bool operator==( const QgsDataDefined &other ) const;
238  bool operator!=( const QgsDataDefined &other ) const;
239 
243  QgsDataDefined& operator=( QgsDataDefined const & rhs );
244 
245  private:
246 
248 
249 };
250 
251 #endif // QGSDATADEFINED_H
Class for parsing and evaluation of expressions (formerly called "search strings").
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:252
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.