QGIS API Documentation  2.99.0-Master (c558d51)
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 "qgsexpressioncontext.h"
24 
25 class QgsExpression;
26 class QgsVectorLayer;
27 class QgsDataDefinedPrivate;
28 
29 
36 class CORE_EXPORT QgsDataDefined
37 {
38  public:
39 
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 
145  bool prepareExpression( const QgsExpressionContext &context = QgsExpressionContext() );
146 
150  bool expressionIsPrepared() const;
151 
152  QgsExpression* expression();
153 
158  QSet<QString> referencedColumns( const QgsExpressionContext& context = QgsExpressionContext() );
159 
168  QString field() const;
169 
176  void setField( const QString& field );
177 
183  QgsStringMap toMap( const QString& baseName = QString() ) const;
184 
192  QDomElement toXmlElement( QDomDocument &document, const QString &elementName ) const;
193 
201  bool setFromXmlElement( const QDomElement& element );
202 
203  bool operator==( const QgsDataDefined &other ) const;
204  bool operator!=( const QgsDataDefined &other ) const;
205 
209  QgsDataDefined& operator=( QgsDataDefined const & rhs );
210 
211  private:
212 
213  QExplicitlySharedDataPointer<QgsDataDefinedPrivate> d;
214 
215 };
216 
217 #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)
QMap< QString, QString > QgsStringMap
Definition: qgis.h:328
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.