QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 <QStringList>
19 #include <QDomElement>
20 #include <QMap>
21 #include <QExplicitlySharedDataPointer>
22 #include "qgis.h"
23 #include "qgsfield.h"
24 
25 class QgsExpression;
26 class QgsVectorLayer;
27 class QgsDataDefinedPrivate;
28 
29 
36 class CORE_EXPORT QgsDataDefined
37 {
38  public:
47  QgsDataDefined( bool active = false,
48  bool useexpr = false,
49  const QString& expr = QString(),
50  const QString& field = QString() );
51 
57  explicit QgsDataDefined( const QgsExpression * expression );
58 
65  explicit QgsDataDefined( const QString& string );
66 
71  QgsDataDefined( const QgsDataDefined& other );
72 
80  static QgsDataDefined* fromMap( const QgsStringMap& map, const QString& baseName = QString() );
81 
82  virtual ~QgsDataDefined();
83 
89  bool hasDefaultValues() const;
90 
91  bool isActive() const;
92  void setActive( bool active );
93 
94  bool useExpression() const;
95  void setUseExpression( bool use );
96 
97  QString expressionString() const;
98  void setExpressionString( const QString& expr );
99 
100  // @note not available in python bindings
101  QMap<QString, QVariant> expressionParams() const;
102  // @note not available in python bindings
103  void setExpressionParams( QMap<QString, QVariant> params );
104  void insertExpressionParam( QString key, QVariant param );
105 
110  bool prepareExpression( QgsVectorLayer* layer );
111 
117  bool prepareExpression( const QgsFields &fields = QgsFields() );
118 
122  bool expressionIsPrepared() const;
123 
124  QgsExpression* expression();
125 
129  QStringList referencedColumns( QgsVectorLayer* layer );
130 
135  QStringList referencedColumns( const QgsFields& fields = QgsFields() );
136 
137  QString field() const;
138  void setField( const QString& field );
139 
145  QgsStringMap toMap( const QString& baseName = QString() ) const;
146 
154  QDomElement toXmlElement( QDomDocument &document, const QString &elementName ) const;
155 
163  bool setFromXmlElement( const QDomElement& element );
164 
165  bool operator==( const QgsDataDefined &other ) const;
166  bool operator!=( const QgsDataDefined &other ) const;
167 
171  QgsDataDefined& operator=( QgsDataDefined const & rhs );
172 
173  private:
174 
176 
177 };
178 
179 #endif // QGSDATADEFINED_H
Class for parsing and evaluation of expressions (formerly called "search strings").
Definition: qgsexpression.h:86
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:173
Represents a vector layer which manages a vector based data sets.