Skip to content
Permalink
Browse files

[QgsRelationReferenceWidget] correctly enable/disable set null button…

…, do not disable line edit (already read only), make openForm and mapIdentification public, more documentation
  • Loading branch information
3nids committed Sep 17, 2014
1 parent 21c81d6 commit 096d9417cb65ad42382abe964a26610637f82cf9
@@ -29,18 +29,28 @@ class QgsRelationReferenceWidget : QWidget

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

//! determines if the form of the related feature will be shown
bool embedForm();
void setEmbedForm( bool display );

//! determines if the foreign key is shown in a combox box or a read-only line edit
bool readOnlySelector();
void setReadOnlySelector( bool readOnly );

//! determines if the widge offers the possibility to select the related feature on the map (using a dedicated map tool)
bool allowMapIdentification();
void setAllowMapIdentification( bool allowMapIdentification );

//! determines the open form button is visible in the widget
bool openFormButtonVisible();
void setOpenFormButtonVisible( bool openFormButtonVisible );

public slots:
//! open the form of the related feature in a new dialog
void openForm();
//! activate the map tool to select the related feature on the map
void mapIdentification();

protected:
virtual void showEvent( QShowEvent* e );

@@ -52,6 +52,7 @@ QgsRelationReferenceWidget::QgsRelationReferenceWidget( QWidget* parent )
, mReferencingLayer( NULL )
, mWindowWidget( NULL )
, mShown( false )
, mIsEditable( true )
, mEmbedForm( false )
, mReadOnlySelector( false )
, mAllowMapIdentification( false )
@@ -181,10 +182,10 @@ void QgsRelationReferenceWidget::setRelation( QgsRelation relation, bool allowNu

void QgsRelationReferenceWidget::setRelationEditable( bool editable )
{
mLineEdit->setEnabled( editable );
mComboBox->setEnabled( editable );
mMapIdentificationButton->setEnabled( editable );
mRemoveFKButton->setEnabled( editable );
mIsEditable = editable;
}

void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )
@@ -235,7 +236,7 @@ void QgsRelationReferenceWidget::setForeignKey( const QVariant& value )
}
}

mRemoveFKButton->setEnabled( true );
mRemoveFKButton->setEnabled( mIsEditable );
highlightFeature( f );
updateAttributeEditorFrame( f );
emit foreignKeyChanged( foreignKey() );
@@ -508,7 +509,7 @@ void QgsRelationReferenceWidget::deleteHighlight()

void QgsRelationReferenceWidget::mapIdentification()
{
if ( !mReferencedLayer )
if ( !mAllowMapIdentification || !mReferencedLayer )
return;

const QgsVectorLayerTools* tools = mEditorContext.vectorLayerTools();
@@ -570,7 +571,7 @@ void QgsRelationReferenceWidget::featureIdentified( const QgsFeature& feature )
mComboBox->setCurrentIndex( mComboBox->findData( feature.attribute( mFkeyFieldIdx ) ) );
}

mRemoveFKButton->setEnabled( true );
mRemoveFKButton->setEnabled( mIsEditable );
highlightFeature( feature );
updateAttributeEditorFrame( feature );
emit foreignKeyChanged( foreignKey() );
@@ -59,18 +59,28 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget

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

//! determines if the form of the related feature will be shown
bool embedForm() {return mEmbedForm;}
void setEmbedForm( bool display );

//! determines if the foreign key is shown in a combox box or a read-only line edit
bool readOnlySelector() {return mReadOnlySelector;}
void setReadOnlySelector( bool readOnly );

//! determines if the widge offers the possibility to select the related feature on the map (using a dedicated map tool)
bool allowMapIdentification() {return mAllowMapIdentification;}
void setAllowMapIdentification( bool allowMapIdentification );

//! determines the open form button is visible in the widget
bool openFormButtonVisible() {return mOpenFormButtonVisible;}
void setOpenFormButtonVisible( bool openFormButtonVisible );

public slots:
//! open the form of the related feature in a new dialog
void openForm();
//! activate the map tool to select the related feature on the map
void mapIdentification();

protected:
virtual void showEvent( QShowEvent* e );

@@ -82,8 +92,6 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
private slots:
void highlightActionTriggered( QAction* action );
void deleteHighlight();
void openForm();
void mapIdentification();
void comboReferenceChanged( int index );
void deleteForeignKey();
void featureIdentified( const QgsFeature& feature );
@@ -113,6 +121,7 @@ class GUI_EXPORT QgsRelationReferenceWidget : public QWidget
QWidget* mWindowWidget;
bool mShown;
QgsRelation mRelation;
bool mIsEditable;

// Q_PROPERTY
bool mEmbedForm;

0 comments on commit 096d941

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