[QgsRelationReferenceWidget] correctly enable/disable set null button, do not disable line edit (already read only), make openForm and mapIdentification public, more documentation

This commit is contained in:
Denis Rouzaud 2014-09-16 16:46:39 +02:00
parent 21c81d6f51
commit 096d9417cb
3 changed files with 26 additions and 6 deletions

View File

@ -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 );

View File

@ -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() );

View File

@ -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;