Skip to content

Commit

Permalink
Update constraints when foreign key is manually updated with empty st…
Browse files Browse the repository at this point in the history
…ring
  • Loading branch information
pblottiere committed Nov 30, 2017
1 parent 10b34b9 commit 512acca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidget.cpp
Expand Up @@ -164,7 +164,7 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
connect( mMapIdentificationButton, SIGNAL( clicked() ), this, SLOT( mapIdentification() ) );
connect( mRemoveFKButton, SIGNAL( clicked() ), this, SLOT( deleteForeignKey() ) );
connect( mAddEntryButton, SIGNAL( clicked( bool ) ), this, SLOT( addEntry() ) );
connect( mComboBox, SIGNAL( editTextChanged( QString ) ), this, SLOT( updateAddEntryButton() ) );
connect( mComboBox, SIGNAL( editTextChanged( QString ) ), this, SLOT( editTextUpdated( const QString & ) ) );
}

QgsRelationReferenceWidget::~QgsRelationReferenceWidget()
Expand Down Expand Up @@ -990,3 +990,13 @@ void QgsRelationReferenceWidget::disableChainedComboBoxes( const QComboBox *scb
ccb = cb;
}
}

void QgsRelationReferenceWidget::editTextUpdated( const QString &text )
{
updateAddEntryButton();

// allow to raise an invalid constraint on NULL values if necessary
// and when the combobox is updated manually from the keyboard
if ( text.isEmpty() && mAllowNull )
mComboBox->setCurrentIndex( 0 );
}
3 changes: 2 additions & 1 deletion src/gui/editorwidgets/qgsrelationreferencewidget.h
Expand Up @@ -157,12 +157,13 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
void mapToolDeactivated();
void filterChanged();
void addEntry();
void updateAddEntryButton();
void editTextUpdated( const QString &text );

private:
void highlightFeature( QgsFeature f = QgsFeature(), CanvasExtent canvasExtent = Fixed );
void updateAttributeEditorFrame( const QgsFeature& feature );
void disableChainedComboBoxes( const QComboBox *scb );
void updateAddEntryButton();

// initialized
QgsAttributeEditorContext mEditorContext;
Expand Down

0 comments on commit 512acca

Please sign in to comment.