QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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
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
18
19#include <QString>
20
21using namespace Qt::StringLiterals;
22
24 : QgsOptional<QgsExpression>( expression )
25{
26
27}
28
34
35void QgsOptionalExpression::writeXml( QDomElement &element ) const
36{
37 const QDomText exp = element.ownerDocument().createTextNode( data().expression() );
38 element.setAttribute( u"enabled"_s, enabled() );
39 element.appendChild( exp );
40}
41
42void QgsOptionalExpression::readXml( const QDomElement &element )
43{
44 setEnabled( element.attribute( u"enabled"_s ).toInt() );
45 setData( element.text() );
46}
Handles parsing and evaluation of expressions (formerly called "search strings").
void writeXml(QDomElement &element) const
Save the optional expression to the provided QDomElement.
void readXml(const QDomElement &element)
Read the optional expression from the provided QDomElement.
QgsOptionalExpression()=default
Construct a default optional expression.
void setData(const QgsExpression &data)
void setEnabled(bool enabled)
Definition qgsoptional.h:95
QgsExpression data() const