QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsoptionalexpression.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsoptionalexpression - QgsOptionalExpression
3 
4  ---------------------
5  begin : 14.9.2016
6  copyright : (C) 2016 by Matthias Kuhn
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgsoptionalexpression.h"
18 
21 {
22 
23 }
24 
26  : QgsOptional<QgsExpression>( expression )
27 {
28 
29 }
30 
32  : QgsOptional<QgsExpression>( expression, enabled )
33 {
34 
35 }
36 
38 {
39  QDomText exp = element.ownerDocument().createTextNode( data().expression() );
40  element.setAttribute( "enabled", enabled() );
41  element.appendChild( exp );
42 }
43 
45 {
46  setEnabled( element.attribute( "enabled" ).toInt() );
47  setData( element.text() );
48 }
Class for parsing and evaluation of expressions (formerly called "search strings").
QgsOptionalExpression()
Construct a default optional expression.
QDomNode appendChild(const QDomNode &newChild)
bool enabled() const
Check if this optional is enabled.
Definition: qgsoptional.h:87
QString attribute(const QString &name, const QString &defValue) const
void readXml(const QDomElement &element)
Read the optional expression from the provided QDomElement.
void setData(const QgsExpression &data)
Set the payload data.
Definition: qgsoptional.h:127
QDomDocument ownerDocument() const
QString text() const
void setAttribute(const QString &name, const QString &value)
int toInt(bool *ok, int base) const
QDomText createTextNode(const QString &value)
void writeXml(QDomElement &element)
Save the optional expression to the provided QDomElement.
QgsOptional is a container for other classes and adds an additional enabled/disabled flag...
Definition: qgsoptional.h:32
QgsExpression data() const
Access the payload data.
Definition: qgsoptional.h:117
void setEnabled(bool enabled)
Set if this optional is enabled.
Definition: qgsoptional.h:97