Skip to content
Permalink
Browse files

Relation Reference Widget: Only enable form button when a feature is set

  • Loading branch information
m-kuhn committed Jun 16, 2016
1 parent 8868303 commit 3ea35fc0339fcd5ad18b9a517bbf996731c4d87a
@@ -323,7 +323,7 @@ void QgsRelationReferenceWidget::deleteForeignKey()
emit foreignKeyChanged( QVariant( QVariant::Int ) );
}

QgsFeature QgsRelationReferenceWidget::referencedFeature()
QgsFeature QgsRelationReferenceWidget::referencedFeature() const
{
QgsFeature f;
if ( mReferencedLayer )
@@ -356,7 +356,7 @@ void QgsRelationReferenceWidget::showIndeterminateState()
updateAttributeEditorFrame( QgsFeature() );
}

QVariant QgsRelationReferenceWidget::foreignKey()
QVariant QgsRelationReferenceWidget::foreignKey() const
{
if ( mReadOnlySelector )
{
@@ -557,6 +557,7 @@ void QgsRelationReferenceWidget::init()

// Only connect after iterating, to have only one iterator on the referenced table at once
connect( mComboBox, SIGNAL( currentIndexChanged( int ) ), this, SLOT( comboReferenceChanged( int ) ) );
updateAttributeEditorFrame( mFeature );
QApplication::restoreOverrideCursor();
}
}
@@ -706,13 +707,11 @@ void QgsRelationReferenceWidget::comboReferenceChanged( int index )

void QgsRelationReferenceWidget::updateAttributeEditorFrame( const QgsFeature& feature )
{
mOpenFormButton->setEnabled( feature.isValid() );
// Check if we're running with an embedded frame we need to update
if ( mAttributeEditorFrame )
if ( mAttributeEditorFrame && mReferencedAttributeForm )
{
if ( mReferencedAttributeForm )
{
mReferencedAttributeForm->setFeature( feature );
}
mReferencedAttributeForm->setFeature( feature );
}
}

@@ -62,7 +62,7 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
void setForeignKey( const QVariant &value );

//! returns the related feature foreign key
QVariant foreignKey();
QVariant foreignKey() const;

void setEditorContext( const QgsAttributeEditorContext& context, QgsMapCanvas* canvas, QgsMessageBar* messageBar );

@@ -106,7 +106,7 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget

//! return the related feature (from the referenced layer)
//! if no feature is related, it returns an invalid feature
QgsFeature referencedFeature();
QgsFeature referencedFeature() const;

/** Sets the widget to display in an indeterminate "mixed value" state.
* @note added in QGIS 2.16

0 comments on commit 3ea35fc

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