Skip to content

Commit 3d514db

Browse files
committed
Export QgsOptional<QgsExpression> to dll/so
1 parent 406757d commit 3d514db

6 files changed

+105
-19
lines changed

python/core/qgsoptionalexpression.sip

+17
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,21 @@ class QgsOptionalExpression
8080
* @note Added in QGIS 3.0
8181
*/
8282
void setData( const QgsExpression& data );
83+
84+
/**
85+
* Save the optional expression to the provided QDomElement.
86+
*
87+
* The caller is responsible to pass an empty QDomElement and to append it to
88+
* a parent element.
89+
*
90+
* @note Added in QGIS 2.18
91+
*/
92+
void writeXml(QDomElement& parent );
93+
94+
/**
95+
* Read the optional expression from the provided QDomElement.
96+
*
97+
* @note Added in QGIS 2.18
98+
*/
99+
void readXml(const QDomElement& parent );
83100
};

src/core/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ SET(QGIS_CORE_SRCS
163163
qgsofflineediting.cpp
164164
qgsogcutils.cpp
165165
qgsogrutils.cpp
166-
qgsoptional.cpp
166+
qgsoptionalexpression.cpp
167167
qgsowsconnection.cpp
168168
qgspaintenginehack.cpp
169169
qgspallabeling.cpp

src/core/qgsoptional.cpp

-16
This file was deleted.

src/core/qgsoptional.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class CORE_EXPORT QgsOptional
130130
}
131131

132132
private:
133-
T mData;
134133
bool mEnabled;
134+
T mData;
135135
};
136136

137137
#endif // QGSOPTIONAL_H

src/core/qgsoptionalexpression.cpp

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/***************************************************************************
2+
qgsoptionalexpression - QgsOptionalExpression
3+
4+
---------------------
5+
begin : 14.9.2016
6+
copyright : (C) 2016 by Matthias Kuhn
7+
email : matthias@opengis.ch
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+
19+
QgsOptionalExpression::QgsOptionalExpression()
20+
: QgsOptional<QgsExpression>()
21+
{
22+
23+
}
24+
25+
QgsOptionalExpression::QgsOptionalExpression( const QgsExpression& expression )
26+
: QgsOptional<QgsExpression>( expression )
27+
{
28+
29+
}
30+
31+
QgsOptionalExpression::QgsOptionalExpression( const QgsExpression& expression, bool enabled )
32+
: QgsOptional<QgsExpression>( expression, enabled )
33+
{
34+
35+
}
36+
37+
void QgsOptionalExpression::writeXml( QDomElement& element )
38+
{
39+
QDomText exp = element.ownerDocument().createTextNode( data().expression() );
40+
element.setAttribute( "enabled", enabled() );
41+
element.appendChild( exp );
42+
}
43+
44+
void QgsOptionalExpression::readXml( const QDomElement& element )
45+
{
46+
setEnabled( element.attribute( "enabled" ).toInt() );
47+
setData( element.text() );
48+
}

src/core/qgsoptionalexpression.h

+38-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,43 @@
2828
*
2929
* Added in QGIS 3.0
3030
*/
31-
typedef QgsOptional<QgsExpression> QgsOptionalExpression;
31+
32+
class CORE_EXPORT QgsOptionalExpression : public QgsOptional<QgsExpression>
33+
{
34+
public:
35+
/**
36+
* Construct a default optional expression.
37+
* It will be disabled and with an empty expression.
38+
*/
39+
QgsOptionalExpression();
40+
41+
/**
42+
* Construct an optional expression with the provided expression.
43+
* It will be enabled.
44+
*/
45+
QgsOptionalExpression( const QgsExpression& expression );
46+
47+
/**
48+
* Construct an optional expression with the provided expression and enabled state.
49+
*/
50+
QgsOptionalExpression( const QgsExpression& expression, bool enabled );
51+
52+
/**
53+
* Save the optional expression to the provided QDomElement.
54+
*
55+
* The caller is responsible to pass an empty QDomElement and to append it to
56+
* a parent element.
57+
*
58+
* @note Added in QGIS 2.18
59+
*/
60+
void writeXml( QDomElement& element );
61+
62+
/**
63+
* Read the optional expression from the provided QDomElement.
64+
*
65+
* @note Added in QGIS 2.18
66+
*/
67+
void readXml( const QDomElement& element );
68+
};
3269

3370
#endif // QGSOPTIONALEXPRESSION_H

0 commit comments

Comments
 (0)