Skip to content

Commit

Permalink
checkbox on relation reference fields to display all values
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Dec 16, 2019
1 parent e73fe50 commit 995335a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
12 changes: 11 additions & 1 deletion src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
45 changes: 25 additions & 20 deletions src/ui/qgsexpressionbuilder.ui
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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.