Skip to content
Permalink
Browse files

expressions on qml widget

  • Loading branch information
signedav committed Sep 5, 2018
1 parent abbe5c5 commit ccdd4df5ce08fc123e40755470c512289783cf50
@@ -7,7 +7,6 @@
************************************************************************/



class QgsQmlWidgetWrapper : QgsWidgetWrapper
{
%Docstring
@@ -55,6 +54,19 @@ the Free Software Foundation; either version 2 of the License, or *
};


class QmlExpression : QObject
{

%TypeHeaderCode
#include "qgsqmlwidgetwrapper.h"
%End
public:
void setExpressionContext( const QgsExpressionContext &context );

QVariant evaluate( const QString &expression ) const;

};

/************************************************************************
* This file has been generated automatically from *
* *
@@ -1170,7 +1170,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )

connect( addExpressionButton, &QAbstractButton::clicked, this, [ = ]
{
qmlCode->insertPlainText( QStringLiteral( "expression.evaluate(\"(%1)\")" ).arg( expressionWidget->currentText()) );
qmlCode->insertPlainText( QStringLiteral( "expression.evaluate(\"(%1)\")" ).arg( expressionWidget->currentText() ) );
} );


@@ -1181,7 +1181,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
qmlWrapper->reinitWidget();
QgsFeature f;
mLayer->getFeatures().nextFeature(f);
mLayer->getFeatures().nextFeature( f );
qmlWrapper->setFeature( f );
} );

@@ -108,9 +108,9 @@ void QmlExpression::setExpressionContext( const QgsExpressionContext &context )
mExpressionContext = context;
}

QVariant QmlExpression::evaluate( const QString& expression ) const
QVariant QmlExpression::evaluate( const QString &expression ) const
{
QgsExpression exp = QgsExpression( expression );
exp.prepare( &mExpressionContext );
return exp.evaluate(&mExpressionContext);
return exp.evaluate( &mExpressionContext );
}
@@ -53,15 +53,15 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper

class GUI_EXPORT QmlExpression : public QObject
{
Q_OBJECT
Q_OBJECT

public:
void setExpressionContext( const QgsExpressionContext &context );
void setExpressionContext( const QgsExpressionContext &context );

Q_INVOKABLE QVariant evaluate( const QString &expression) const;
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;

private:
QgsExpressionContext mExpressionContext;
QgsExpressionContext mExpressionContext;
};

#endif // QGSQMLWIDGETWRAPPER_H

0 comments on commit ccdd4df

Please sign in to comment.
You can’t perform that action at this time.