Skip to content

Commit 91e39a7

Browse files
committedJul 30, 2017
[needs-docs] Relation Reference Widget: Add option to show/hide the Open Form Button
The option was already available in the API (QgsRelationReferenceWidget->setOpenFormButtonVisible), but couldn't be used from QgsEditorWidgetSetup nor from the config dialog. For the former, a 'ShowOpenFormButton' key is added, whereas for the latter, a new checkbox is available. Being able to hide the Open Form Button is helpful when configuring lookup tables, where a single combo box should be shown in the edit form with no additional buttons.
1 parent 45fc00a commit 91e39a7

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed
 

‎src/gui/editorwidgets/qgsrelationreferenceconfigdlg.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ QgsRelationReferenceConfigDlg::QgsRelationReferenceConfigDlg( QgsVectorLayer *vl
4444
connect( mCbxAllowNull, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
4545
connect( mCbxOrderByValue, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
4646
connect( mCbxShowForm, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
47+
connect( mCbxShowOpenFormButton, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
4748
connect( mCbxMapIdentification, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
4849
connect( mCbxReadOnly, &QAbstractButton::toggled, this, &QgsEditorConfigWidget::changed );
4950
connect( mComboRelation, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsEditorConfigWidget::changed );
@@ -59,6 +60,7 @@ void QgsRelationReferenceConfigDlg::setConfig( const QVariantMap &config )
5960
mCbxAllowNull->setChecked( config.value( QStringLiteral( "AllowNULL" ), false ).toBool() );
6061
mCbxOrderByValue->setChecked( config.value( QStringLiteral( "OrderByValue" ), false ).toBool() );
6162
mCbxShowForm->setChecked( config.value( QStringLiteral( "ShowForm" ), false ).toBool() );
63+
mCbxShowOpenFormButton->setChecked( config.value( QStringLiteral( "ShowOpenFormButton" ), true ).toBool() );
6264

6365
if ( config.contains( QStringLiteral( "Relation" ) ) )
6466
{
@@ -121,6 +123,7 @@ QVariantMap QgsRelationReferenceConfigDlg::config()
121123
myConfig.insert( QStringLiteral( "AllowNULL" ), mCbxAllowNull->isChecked() );
122124
myConfig.insert( QStringLiteral( "OrderByValue" ), mCbxOrderByValue->isChecked() );
123125
myConfig.insert( QStringLiteral( "ShowForm" ), mCbxShowForm->isChecked() );
126+
myConfig.insert( QStringLiteral( "ShowOpenFormButton" ), mCbxShowOpenFormButton->isChecked() );
124127
myConfig.insert( QStringLiteral( "MapIdentification" ), mCbxMapIdentification->isEnabled() && mCbxMapIdentification->isChecked() );
125128
myConfig.insert( QStringLiteral( "ReadOnly" ), mCbxReadOnly->isChecked() );
126129
myConfig.insert( QStringLiteral( "Relation" ), mComboRelation->currentData() );

‎src/gui/editorwidgets/qgsrelationreferencewidgetwrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ void QgsRelationReferenceWidgetWrapper::initWidget( QWidget *editor )
5050
bool mapIdent = config( QStringLiteral( "MapIdentification" ), false ).toBool();
5151
bool readOnlyWidget = config( QStringLiteral( "ReadOnly" ), false ).toBool();
5252
bool orderByValue = config( QStringLiteral( "OrderByValue" ), false ).toBool();
53+
bool showOpenFormButton = config( QStringLiteral( "ShowOpenFormButton" ), true ).toBool();
5354

5455
mWidget->setEmbedForm( showForm );
5556
mWidget->setReadOnlySelector( readOnlyWidget );
5657
mWidget->setAllowMapIdentification( mapIdent );
5758
mWidget->setOrderByValue( orderByValue );
59+
mWidget->setOpenFormButtonVisible( showOpenFormButton );
5860
if ( config( QStringLiteral( "FilterFields" ), QVariant() ).isValid() )
5961
{
6062
mWidget->setFilterFields( config( QStringLiteral( "FilterFields" ) ).toStringList() );

‎src/ui/editorwidgets/qgsrelationreferenceconfigdlgbase.ui

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
</property>
2222
</widget>
2323
</item>
24+
<item row="5" column="0" colspan="2">
25+
<widget class="QCheckBox" name="mCbxShowOpenFormButton">
26+
<property name="text">
27+
<string>Show open form button</string>
28+
</property>
29+
</widget>
30+
</item>
2431
<item row="1" column="1">
2532
<widget class="QComboBox" name="mComboRelation"/>
2633
</item>
@@ -31,7 +38,7 @@
3138
</property>
3239
</widget>
3340
</item>
34-
<item row="6" column="0" colspan="2">
41+
<item row="7" column="0" colspan="2">
3542
<widget class="QCheckBox" name="mCbxReadOnly">
3643
<property name="text">
3744
<string>Use a read-only line edit instead of a combobox</string>
@@ -59,7 +66,7 @@
5966
</property>
6067
</widget>
6168
</item>
62-
<item row="5" column="0" colspan="2">
69+
<item row="6" column="0" colspan="2">
6370
<widget class="QCheckBox" name="mCbxMapIdentification">
6471
<property name="text">
6572
<string>On map identification (for geometric layers only)</string>
@@ -73,7 +80,7 @@
7380
</property>
7481
</widget>
7582
</item>
76-
<item row="8" column="0" colspan="2">
83+
<item row="9" column="0" colspan="2">
7784
<widget class="QgsCollapsibleGroupBox" name="mFilterGroupBox">
7885
<property name="title">
7986
<string>Filters</string>
@@ -152,7 +159,7 @@
152159
</layout>
153160
</widget>
154161
</item>
155-
<item row="7" column="0" colspan="2">
162+
<item row="8" column="0" colspan="2">
156163
<widget class="QCheckBox" name="mCbxAllowAddFeatures">
157164
<property name="text">
158165
<string>Allow adding new features</string>
@@ -181,6 +188,7 @@
181188
<tabstop>mCbxAllowNull</tabstop>
182189
<tabstop>mCbxOrderByValue</tabstop>
183190
<tabstop>mCbxShowForm</tabstop>
191+
<tabstop>mCbxShowOpenFormButton</tabstop>
184192
<tabstop>mCbxMapIdentification</tabstop>
185193
<tabstop>mCbxReadOnly</tabstop>
186194
<tabstop>mCbxAllowAddFeatures</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.