Skip to content

Commit

Permalink
Preserve visibility of relation editor edit state buttons
Browse files Browse the repository at this point in the history
... also when collapsing and uncollapsing a relation editor.

References #15102 (https://issues.qgis.org/issues/15102)
  • Loading branch information
m-kuhn committed May 19, 2017
1 parent 99a2f3b commit 523cd07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/gui/qgsrelationeditorwidget.cpp
Expand Up @@ -35,6 +35,7 @@ QgsRelationEditorWidget::QgsRelationEditorWidget( QWidget* parent )
, mViewMode( QgsDualView::AttributeEditor )
, mShowLabel( true )
, mVisible( false )
, mInitialized( false )
{
QVBoxLayout* topLayout = new QVBoxLayout( this );
topLayout->setContentsMargins( 0, 9, 0, 0 );
Expand Down Expand Up @@ -180,6 +181,7 @@ void QgsRelationEditorWidget::setRelationFeature( const QgsRelation& relation, c
QgsFeatureRequest myRequest = mRelation.getRelatedFeaturesRequest( mFeature );

mDualView->init( mRelation.referencingLayer(), nullptr, myRequest, mEditorContext );
mInitialized = true;
}
}

Expand All @@ -203,17 +205,6 @@ void QgsRelationEditorWidget::setRelations( const QgsRelation& relation, const Q
if ( !mRelation.isValid() )
return;

mToggleEditingButton->setVisible( true );

Q_FOREACH ( QgsTransactionGroup* tg, QgsProject::instance()->transactionGroups().values() )
{
if ( tg->layers().contains( mRelation.referencingLayer() ) )
{
mToggleEditingButton->setVisible( false );
mSaveEditsButton->setVisible( false );
}
}

connect( mRelation.referencingLayer(), SIGNAL( editingStarted() ), this, SLOT( updateButtons() ) );
connect( mRelation.referencingLayer(), SIGNAL( editingStopped() ), this, SLOT( updateButtons() ) );

Expand Down Expand Up @@ -532,7 +523,7 @@ void QgsRelationEditorWidget::updateUi()
// If it is already initialized, it has been set visible before and the currently shown feature is changing
// and the widget needs updating

if ( mVisible )
if ( mVisible && !mInitialized )
{
QgsFeatureRequest myRequest = mRelation.getRelatedFeaturesRequest( mFeature );

Expand Down Expand Up @@ -560,6 +551,18 @@ void QgsRelationEditorWidget::updateUi()
{
mDualView->init( mRelation.referencingLayer(), nullptr, myRequest, mEditorContext );
}
mInitialized = true;
}

mToggleEditingButton->setVisible( true );

Q_FOREACH ( QgsTransactionGroup* tg, QgsProject::instance()->transactionGroups().values() )
{
if ( tg->layers().contains( mRelation.referencingLayer() ) )
{
mToggleEditingButton->setVisible( false );
mSaveEditsButton->setVisible( false );
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsrelationeditorwidget.h
Expand Up @@ -151,6 +151,7 @@ class GUI_EXPORT QgsRelationEditorWidget : public QgsCollapsibleGroupBox

bool mShowLabel;
bool mVisible;
bool mInitialized;
};

#endif // QGSRELATIONEDITOR_H

0 comments on commit 523cd07

Please sign in to comment.