Skip to content

Commit

Permalink
Export QgsOptional<QgsExpression> to dll/so
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Sep 14, 2016
1 parent 8ac1460 commit 632da63
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 20 deletions.
17 changes: 17 additions & 0 deletions python/core/qgsoptionalexpression.sip
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,21 @@ class QgsOptionalExpression
* @note Added in QGIS 3.0
*/
void setData( const QgsExpression& data );

/**
* Save the optional expression to the provided QDomElement.
*
* The caller is responsible to pass an empty QDomElement and to append it to
* a parent element.
*
* @note Added in QGIS 2.18
*/
void writeXml(QDomElement& parent );

/**
* Read the optional expression from the provided QDomElement.
*
* @note Added in QGIS 2.18
*/
void readXml(const QDomElement& parent );
};
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ SET(QGIS_CORE_SRCS
qgsofflineediting.cpp
qgsogcutils.cpp
qgsogrutils.cpp
qgsoptional.cpp
qgsoptionalexpression.cpp
qgsowsconnection.cpp
qgspaintenginehack.cpp
qgspainting.cpp
Expand Down
16 changes: 0 additions & 16 deletions src/core/qgsoptional.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/core/qgsoptional.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ class CORE_EXPORT QgsOptional
}

private:
T mData;
bool mEnabled;
T mData;
};

#endif // QGSOPTIONAL_H
48 changes: 48 additions & 0 deletions src/core/qgsoptionalexpression.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/***************************************************************************
qgsoptionalexpression - QgsOptionalExpression
---------------------
begin : 14.9.2016
copyright : (C) 2016 by Matthias Kuhn
email : matthias@opengis.ch
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgsoptionalexpression.h"

QgsOptionalExpression::QgsOptionalExpression()
: QgsOptional<QgsExpression>()
{

}

QgsOptionalExpression::QgsOptionalExpression( const QgsExpression& expression )
: QgsOptional<QgsExpression>( expression )
{

}

QgsOptionalExpression::QgsOptionalExpression( const QgsExpression& expression, bool enabled )
: QgsOptional<QgsExpression>( expression, enabled )
{

}

void QgsOptionalExpression::writeXml( QDomElement& element )
{
QDomText exp = element.ownerDocument().createTextNode( data().expression() );
element.setAttribute( "enabled", enabled() );
element.appendChild( exp );
}

void QgsOptionalExpression::readXml( const QDomElement& element )
{
setEnabled( element.attribute( "enabled" ).toInt() );
setData( element.text() );
}
43 changes: 41 additions & 2 deletions src/core/qgsoptionalexpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,53 @@
#include "qgsexpression.h"

/**
* \ingroup core
*
* An expression with an additional enabled flag.
*
* This can be used for configuration options where an expression can be enabled
* or diabled but when disabled it shouldn't lose it's information for the case
* it gets re-enabled later on and a user shoulnd't be force to redo the configuration.
*
* Added in QGIS 3.0
* @note Added in QGIS 2.18
*/
typedef QgsOptional<QgsExpression> QgsOptionalExpression;

class CORE_EXPORT QgsOptionalExpression : public QgsOptional<QgsExpression>
{
public:
/**
* Construct a default optional expression.
* It will be disabled and with an empty expression.
*/
QgsOptionalExpression();

/**
* Construct an optional expression with the provided expression.
* It will be enabled.
*/
QgsOptionalExpression( const QgsExpression& expression );

/**
* Construct an optional expression with the provided expression and enabled state.
*/
QgsOptionalExpression( const QgsExpression& expression, bool enabled );

/**
* Save the optional expression to the provided QDomElement.
*
* The caller is responsible to pass an empty QDomElement and to append it to
* a parent element.
*
* @note Added in QGIS 2.18
*/
void writeXml( QDomElement& element );

/**
* Read the optional expression from the provided QDomElement.
*
* @note Added in QGIS 2.18
*/
void readXml( const QDomElement& element );
};

#endif // QGSOPTIONALEXPRESSION_H

1 comment on commit 632da63

@ahuarte47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @m-kuhn for this commit!

Please sign in to comment.