QGIS API Documentation  2.99.0-Master (0a63d1f)
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 "qgis_core.h"
19 #include <QStringList>
20 #include <QDomElement>
21 #include <QMap>
22 #include <QExplicitlySharedDataPointer>
23 #include "qgis.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:
40 
49  QgsDataDefined( bool active = false,
50  bool useexpr = false,
51  const QString& expr = QString(),
52  const QString& field = QString() );
53 
59  explicit QgsDataDefined( const QgsExpression * expression );
60 
67  QgsDataDefined( const QString& string );
68 
73  QgsDataDefined( const QgsDataDefined& other );
74 
82  static QgsDataDefined* fromMap( const QgsStringMap& map, const QString& baseName = QString() );
83 
84  virtual ~QgsDataDefined();
85 
91  bool hasDefaultValues() const;
92 
93  bool isActive() const;
94  void setActive( bool active );
95 
101  bool useExpression() const;
102 
110  void setUseExpression( bool use );
111 
120  QString expressionString() const;
121 
130  void setExpressionString( const QString& expr );
131 
139  QString expressionOrField() const;
140 
146  bool prepareExpression( const QgsExpressionContext &context = QgsExpressionContext() );
147 
151  bool expressionIsPrepared() const;
152 
153  QgsExpression* expression();
154 
159  QSet<QString> referencedColumns( const QgsExpressionContext& context = QgsExpressionContext() );
160 
169  QString field() const;
170 
177  void setField( const QString& field );
178 
184  QgsStringMap toMap( const QString& baseName = QString() ) const;
185 
193  QDomElement toXmlElement( QDomDocument &document, const QString &elementName ) const;
194 
202  bool setFromXmlElement( const QDomElement& element );
203 
204  bool operator==( const QgsDataDefined &other ) const;
205  bool operator!=( const QgsDataDefined &other ) const;
206 
210  QgsDataDefined& operator=( QgsDataDefined const & rhs );
211 
212  private:
213 
214  QExplicitlySharedDataPointer<QgsDataDefinedPrivate> d;
215 
216 };
217 
218 #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:325
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.