Skip to content
Permalink
Browse files

Preserve visibility of relation editor edit state buttons

... 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 523cd074c8ef4df69f9f1d56ffbd8d0428410181
Showing with 16 additions and 12 deletions.
  1. +15 −12 src/gui/qgsrelationeditorwidget.cpp
  2. +1 −0 src/gui/qgsrelationeditorwidget.h
@@ -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 );
@@ -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;
}
}

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

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

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

@@ -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.
You can’t perform that action at this time.