Skip to content
Permalink
Browse files

checkbox on relation reference fields to display all values

  • Loading branch information
signedav committed Dec 16, 2019
1 parent e73fe50 commit 995335a9b5eea019207f5591cbb4591370719057
Showing with 36 additions and 21 deletions.
  1. +11 −1 src/gui/qgsexpressionbuilderwidget.cpp
  2. +25 −20 src/ui/qgsexpressionbuilder.ui
@@ -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();
@@ -543,21 +543,7 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsFilterLineEdit" name="txtSearchEditValues">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QListView" name="mValuesListView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="1" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<property name="topMargin">
<number>0</number>
@@ -578,6 +564,27 @@
</item>
</layout>
</item>
<item row="0" column="1">
<widget class="QgsFilterLineEdit" name="txtSearchEditValues">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QListView" name="mValuesListView">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="cbxRelatedLayerValues">
<property name="text">
<string>Show all values of referenced layer</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@@ -677,7 +684,7 @@ Change the name of the script and save to allow QGIS to auto load on startup.</s
<string/>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<iconset>
<normaloff>:/images/themes/default/console/iconNewTabEditorConsole.svg</normaloff>:/images/themes/default/console/iconNewTabEditorConsole.svg</iconset>
</property>
<property name="iconSize">
@@ -769,7 +776,7 @@ Saved scripts are auto loaded on QGIS startup.</string>
<string>Save and Load Functions</string>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<iconset>
<normaloff>:/images/themes/default/mActionStart.svg</normaloff>:/images/themes/default/mActionStart.svg</iconset>
</property>
</widget>
@@ -835,8 +842,6 @@ Saved scripts are auto loaded on QGIS startup.</string>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

0 comments on commit 995335a

Please sign in to comment.
You can’t perform that action at this time.