Skip to content

Commit 512acca

Browse files
committed
Update constraints when foreign key is manually updated with empty string
1 parent 10b34b9 commit 512acca

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/gui/editorwidgets/qgsrelationreferencewidget.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
164164
connect( mMapIdentificationButton, SIGNAL( clicked() ), this, SLOT( mapIdentification() ) );
165165
connect( mRemoveFKButton, SIGNAL( clicked() ), this, SLOT( deleteForeignKey() ) );
166166
connect( mAddEntryButton, SIGNAL( clicked( bool ) ), this, SLOT( addEntry() ) );
167-
connect( mComboBox, SIGNAL( editTextChanged( QString ) ), this, SLOT( updateAddEntryButton() ) );
167+
connect( mComboBox, SIGNAL( editTextChanged( QString ) ), this, SLOT( editTextUpdated( const QString & ) ) );
168168
}
169169

170170
QgsRelationReferenceWidget::~QgsRelationReferenceWidget()
@@ -990,3 +990,13 @@ void QgsRelationReferenceWidget::disableChainedComboBoxes( const QComboBox *scb
990990
ccb = cb;
991991
}
992992
}
993+
994+
void QgsRelationReferenceWidget::editTextUpdated( const QString &text )
995+
{
996+
updateAddEntryButton();
997+
998+
// allow to raise an invalid constraint on NULL values if necessary
999+
// and when the combobox is updated manually from the keyboard
1000+
if ( text.isEmpty() && mAllowNull )
1001+
mComboBox->setCurrentIndex( 0 );
1002+
}

src/gui/editorwidgets/qgsrelationreferencewidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,13 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
157157
void mapToolDeactivated();
158158
void filterChanged();
159159
void addEntry();
160-
void updateAddEntryButton();
160+
void editTextUpdated( const QString &text );
161161

162162
private:
163163
void highlightFeature( QgsFeature f = QgsFeature(), CanvasExtent canvasExtent = Fixed );
164164
void updateAttributeEditorFrame( const QgsFeature& feature );
165165
void disableChainedComboBoxes( const QComboBox *scb );
166+
void updateAddEntryButton();
166167

167168
// initialized
168169
QgsAttributeEditorContext mEditorContext;

0 commit comments

Comments
 (0)