Skip to content

Commit ccdd4df

Browse files
committed
expressions on qml widget
1 parent abbe5c5 commit ccdd4df

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

python/gui/auto_generated/editorwidgets/qgsqmlwidgetwrapper.sip.in

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
************************************************************************/
88

99

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

5756

57+
class QmlExpression : QObject
58+
{
59+
60+
%TypeHeaderCode
61+
#include "qgsqmlwidgetwrapper.h"
62+
%End
63+
public:
64+
void setExpressionContext( const QgsExpressionContext &context );
65+
66+
QVariant evaluate( const QString &expression ) const;
67+
68+
};
69+
5870
/************************************************************************
5971
* This file has been generated automatically from *
6072
* *

src/app/qgsattributesformproperties.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
11701170

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

11761176

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

src/gui/editorwidgets/qgsqmlwidgetwrapper.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ void QmlExpression::setExpressionContext( const QgsExpressionContext &context )
108108
mExpressionContext = context;
109109
}
110110

111-
QVariant QmlExpression::evaluate( const QString& expression ) const
111+
QVariant QmlExpression::evaluate( const QString &expression ) const
112112
{
113113
QgsExpression exp = QgsExpression( expression );
114114
exp.prepare( &mExpressionContext );
115-
return exp.evaluate(&mExpressionContext);
115+
return exp.evaluate( &mExpressionContext );
116116
}

src/gui/editorwidgets/qgsqmlwidgetwrapper.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
5353

5454
class GUI_EXPORT QmlExpression : public QObject
5555
{
56-
Q_OBJECT
56+
Q_OBJECT
5757

5858
public:
59-
void setExpressionContext( const QgsExpressionContext &context );
59+
void setExpressionContext( const QgsExpressionContext &context );
6060

61-
Q_INVOKABLE QVariant evaluate( const QString &expression) const;
61+
Q_INVOKABLE QVariant evaluate( const QString &expression ) const;
6262

6363
private:
64-
QgsExpressionContext mExpressionContext;
64+
QgsExpressionContext mExpressionContext;
6565
};
6666

6767
#endif // QGSQMLWIDGETWRAPPER_H

0 commit comments

Comments
 (0)