mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-09 00:04:30 -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
|
:param config: The configuration which should be represented by this widget
|
||||||
%End
|
%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
|
:param config: The configuration which should be represented by this widget
|
||||||
%End
|
%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 "qgsmessagebar.h"
|
||||||
#include "qgsmessagebaritem.h"
|
#include "qgsmessagebaritem.h"
|
||||||
#include "qgsactionmenu.h"
|
#include "qgsactionmenu.h"
|
||||||
|
#include "qgsexpressionbuilderdialog.h"
|
||||||
|
#include "qgsexpressioncontextutils.h"
|
||||||
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
@ -950,6 +952,32 @@ QgsRelationEditorConfigWidget::QgsRelationEditorConfigWidget( const QgsRelation
|
|||||||
: QgsAbstractRelationEditorConfigWidget( relation, parent )
|
: QgsAbstractRelationEditorConfigWidget( relation, parent )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
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()
|
QVariantMap QgsRelationEditorConfigWidget::config()
|
||||||
|
|||||||
@ -305,6 +305,10 @@ class GUI_EXPORT QgsRelationEditorConfigWidget : public QgsAbstractRelationEdito
|
|||||||
*/
|
*/
|
||||||
void setConfig( const QVariantMap &config ) override;
|
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