mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-07 00:03:52 -05:00
Integrate expression builder in configuration
This commit is contained in:
parent
0184eb1c77
commit
66fac268c8
@ -191,6 +191,10 @@ Update the configuration widget to represent the given configuration.
|
||||
:param config: The configuration which should be represented by this widget
|
||||
%End
|
||||
|
||||
void mEditExpression_clicked();
|
||||
%Docstring
|
||||
Opens an expression dialog and sets its value as filter expression for the linking dialog
|
||||
%End
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -191,6 +191,10 @@ Update the configuration widget to represent the given configuration.
|
||||
:param config: The configuration which should be represented by this widget
|
||||
%End
|
||||
|
||||
void mEditExpression_clicked();
|
||||
%Docstring
|
||||
Opens an expression dialog and sets its value as filter expression for the linking dialog
|
||||
%End
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
#include "qgsmessagebar.h"
|
||||
#include "qgsmessagebaritem.h"
|
||||
#include "qgsactionmenu.h"
|
||||
#include "qgsexpressionbuilderdialog.h"
|
||||
#include "qgsexpressioncontextutils.h"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
@ -950,6 +952,32 @@ QgsRelationEditorConfigWidget::QgsRelationEditorConfigWidget( const QgsRelation
|
||||
: QgsAbstractRelationEditorConfigWidget( relation, parent )
|
||||
{
|
||||
setupUi( this );
|
||||
connect( mEditExpression, &QAbstractButton::clicked, this, &QgsRelationEditorConfigWidget::mEditExpression_clicked );
|
||||
|
||||
}
|
||||
|
||||
void QgsRelationEditorConfigWidget::mEditExpression_clicked()
|
||||
{
|
||||
QgsVectorLayer *vl = nullptr;
|
||||
|
||||
if ( nmRelation().isValid() )
|
||||
{
|
||||
vl = nmRelation().referencedLayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
vl = relation().referencingLayer();
|
||||
}
|
||||
|
||||
// Show expression builder
|
||||
QgsExpressionContext context( QgsExpressionContextUtils::globalProjectLayerScopes( vl ) );
|
||||
QgsExpressionBuilderDialog dlg( vl, mFilterExpression->toPlainText(), this, QStringLiteral( "generic" ), context );
|
||||
dlg.setWindowTitle( tr( "Edit Filter Expression of Target Layer" ) );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
mFilterExpression->setPlainText( dlg.expressionBuilder()->expressionText() );
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap QgsRelationEditorConfigWidget::config()
|
||||
|
||||
@ -305,6 +305,10 @@ class GUI_EXPORT QgsRelationEditorConfigWidget : public QgsAbstractRelationEdito
|
||||
*/
|
||||
void setConfig( const QVariantMap &config ) override;
|
||||
|
||||
/**
|
||||
* Opens an expression dialog and sets its value as filter expression for the linking dialog
|
||||
*/
|
||||
void mEditExpression_clicked();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user