mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
some more fixes
Removed QmlExpression from api On activation of template box, we overwrite the text in the GUI The preview is loaded including expression values on start Takes expression instead of currentText from ExpressionWidget - means it delivers fields in quotes
This commit is contained in:
parent
4504845311
commit
5f4acded15
@ -58,26 +58,7 @@ passes the ``feature`` into the context property of the widget
|
||||
|
||||
};
|
||||
|
||||
class QmlExpression : QObject
|
||||
{
|
||||
%Docstring
|
||||
To pass the QgsExpression functionality and it's context to the context of the QQuickWidget
|
||||
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include "qgsqmlwidgetwrapper.h"
|
||||
%End
|
||||
public:
|
||||
void setExpressionContext( const QgsExpressionContext &context );
|
||||
|
||||
QVariant evaluate( const QString &expression ) const;
|
||||
%Docstring
|
||||
evaluates the value regarding the /a expression and the context
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
|
@ -1124,14 +1124,14 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
||||
qmlCode->setPlaceholderText( tr( "Insert QML code here..." ) );
|
||||
|
||||
QgsQmlWidgetWrapper *qmlWrapper = new QgsQmlWidgetWrapper( mLayer, nullptr, this );
|
||||
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
|
||||
QgsFeature previewFeature;
|
||||
mLayer->getFeatures().nextFeature( previewFeature );
|
||||
|
||||
//update preview on text change
|
||||
connect( qmlCode, &QPlainTextEdit::textChanged, this, [ = ]
|
||||
{
|
||||
qmlWrapper->setQmlCode( qmlCode->toPlainText() );
|
||||
qmlWrapper->reinitWidget();
|
||||
QgsFeature previewFeature;
|
||||
mLayer->getFeatures().nextFeature( previewFeature );
|
||||
qmlWrapper->setFeature( previewFeature );
|
||||
} );
|
||||
|
||||
@ -1141,7 +1141,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
||||
qmlObjectTemplate->addItem( tr( "Rectangle" ) );
|
||||
qmlObjectTemplate->addItem( tr( "Pie chart" ) );
|
||||
qmlObjectTemplate->addItem( tr( "Bar chart" ) );
|
||||
connect( qmlObjectTemplate, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), qmlCode, [ = ]( int index )
|
||||
connect( qmlObjectTemplate, qgis::overload<int>::of( &QComboBox::activated ), qmlCode, [ = ]( int index )
|
||||
{
|
||||
qmlCode->clear();
|
||||
switch ( index )
|
||||
@ -1215,7 +1215,7 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
||||
|
||||
connect( addExpressionButton, &QAbstractButton::clicked, this, [ = ]
|
||||
{
|
||||
qmlCode->insertPlainText( QStringLiteral( "expression.evaluate(\"%1\")" ).arg( expressionWidget->currentText().replace( '"', "\\\"" ) ) );
|
||||
qmlCode->insertPlainText( QStringLiteral( "expression.evaluate(\"%1\")" ).arg( expressionWidget->expression().replace( '"', "\\\"" ) ) );
|
||||
} );
|
||||
|
||||
layout->addRow( tr( "Title" ), title );
|
||||
@ -1233,6 +1233,8 @@ void DnDTree::onItemDoubleClicked( QTreeWidgetItem *item, int column )
|
||||
qmlPreviewBox->setLayout( new QGridLayout );
|
||||
qmlPreviewBox->setMinimumWidth( 400 );
|
||||
qmlPreviewBox->layout()->addWidget( qmlWrapper->widget() );
|
||||
//emit to load preview for the first time
|
||||
emit qmlCode->textChanged();
|
||||
qmlLayout->addWidget( qmlPreviewBox );
|
||||
|
||||
QDialogButtonBox *buttonBox = new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel );
|
||||
|
@ -63,12 +63,16 @@ class GUI_EXPORT QgsQmlWidgetWrapper : public QgsWidgetWrapper
|
||||
QQuickWidget *mWidget = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#ifndef SIP_RUN
|
||||
///@cond PRIVATE
|
||||
|
||||
/**
|
||||
* \ingroup gui
|
||||
* To pass the QgsExpression functionality and it's context to the context of the QQuickWidget
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
class GUI_EXPORT QmlExpression : public QObject
|
||||
class QmlExpression : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -81,5 +85,7 @@ class GUI_EXPORT QmlExpression : public QObject
|
||||
private:
|
||||
QgsExpressionContext mExpressionContext;
|
||||
};
|
||||
///@endcond
|
||||
#endif //SIP_RUN
|
||||
|
||||
#endif // QGSQMLWIDGETWRAPPER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user