From 995335a9b5eea019207f5591cbb4591370719057 Mon Sep 17 00:00:00 2001 From: David Signer Date: Mon, 16 Dec 2019 13:01:53 +0100 Subject: [PATCH] checkbox on relation reference fields to display all values --- src/gui/qgsexpressionbuilderwidget.cpp | 12 ++++++- src/ui/qgsexpressionbuilder.ui | 45 ++++++++++++++------------ 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/gui/qgsexpressionbuilderwidget.cpp b/src/gui/qgsexpressionbuilderwidget.cpp index 6f5f81246656..38dfa8115076 100644 --- a/src/gui/qgsexpressionbuilderwidget.cpp +++ b/src/gui/qgsexpressionbuilderwidget.cpp @@ -242,8 +242,18 @@ void QgsExpressionBuilderWidget::currentChanged( const QModelIndex &index, const if ( isField ) { loadFieldValues( mFieldValues.value( item->text() ) ); + + const QgsFields fields = mLayer->fields(); + int fieldIndex = fields.lookupField( item->text() ); + if ( fieldIndex != -1 ) + { + const QgsEditorWidgetSetup setup = fields.at( fieldIndex ).editorWidgetSetup(); + cbxRelatedLayerValues->setVisible( setup.config().contains( QStringLiteral( "Relation" ) ) ); + cbxRelatedLayerValues->setChecked( true ); + } } mValueGroupBox->setVisible( isField ); + mShowHelpButton->setText( isField ? tr( "Show Values" ) : tr( "Show Help" ) ); // Show the help for the current item. @@ -472,7 +482,7 @@ void QgsExpressionBuilderWidget::fillFieldValues( const QString &fieldName, int int layerFieldIndex = fieldIndex; // if it's a request for the values of the referenced layer - if ( setup.config().contains( QStringLiteral( "Relation" ) ) ) + if ( cbxRelatedLayerValues->isChecked() && setup.config().contains( QStringLiteral( "Relation" ) ) ) { layer = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedLayer(); layerFieldIndex = mProject->relationManager()->relation( setup.config()[QStringLiteral( "Relation" )].toString() ).referencedFields().first(); diff --git a/src/ui/qgsexpressionbuilder.ui b/src/ui/qgsexpressionbuilder.ui index 2853727f3174..7e7ce361422a 100644 --- a/src/ui/qgsexpressionbuilder.ui +++ b/src/ui/qgsexpressionbuilder.ui @@ -543,21 +543,7 @@ - - - - true - - - - - - - QAbstractItemView::NoEditTriggers - - - - + 0 @@ -578,6 +564,27 @@ + + + + true + + + + + + + QAbstractItemView::NoEditTriggers + + + + + + + Show all values of referenced layer + + + @@ -677,7 +684,7 @@ Change the name of the script and save to allow QGIS to auto load on startup. - + :/images/themes/default/console/iconNewTabEditorConsole.svg:/images/themes/default/console/iconNewTabEditorConsole.svg @@ -769,7 +776,7 @@ Saved scripts are auto loaded on QGIS startup. Save and Load Functions - + :/images/themes/default/mActionStart.svg:/images/themes/default/mActionStart.svg @@ -835,8 +842,6 @@ Saved scripts are auto loaded on QGIS startup. 1 - - - +