QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
20  : QgsOptional<QgsExpression>( expression )
21 {
22 
23 }
24 
26  : QgsOptional<QgsExpression>( expression, enabled )
27 {
28 
29 }
30 
31 void QgsOptionalExpression::writeXml( QDomElement &element ) const
32 {
33  const QDomText exp = element.ownerDocument().createTextNode( data().expression() );
34  element.setAttribute( QStringLiteral( "enabled" ), enabled() );
35  element.appendChild( exp );
36 }
37 
38 void QgsOptionalExpression::readXml( const QDomElement &element )
39 {
40  setEnabled( element.attribute( QStringLiteral( "enabled" ) ).toInt() );
41  setData( element.text() );
42 }
QgsOptional
QgsOptional is a container for other classes and adds an additional enabled/disabled flag.
Definition: qgsoptional.h:36
QgsOptional< QgsExpression >::enabled
bool enabled() const
Check if this optional is enabled.
Definition: qgsoptional.h:103
qgsoptionalexpression.h
QgsOptionalExpression::QgsOptionalExpression
QgsOptionalExpression()=default
Construct a default optional expression.
QgsOptionalExpression::readXml
void readXml(const QDomElement &element)
Read the optional expression from the provided QDomElement.
Definition: qgsoptionalexpression.cpp:38
QgsOptional< QgsExpression >::setData
void setData(const QgsExpression &data)
Set the payload data.
Definition: qgsoptional.h:143
QgsOptional< QgsExpression >::setEnabled
void setEnabled(bool enabled)
Set if this optional is enabled.
Definition: qgsoptional.h:113
QgsOptional< QgsExpression >::data
QgsExpression data() const
Access the payload data.
Definition: qgsoptional.h:133
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
QgsOptionalExpression::writeXml
void writeXml(QDomElement &element) const
Save the optional expression to the provided QDomElement.
Definition: qgsoptionalexpression.cpp:31