Skip to content

Commit

Permalink
Synchronize edit button state with read only mode (#3562)
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 3, 2016
1 parent 8c90f7d commit 4fd5c01
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -10108,6 +10108,7 @@ void QgisApp::layersWereAdded( const QList<QgsMapLayer *>& theLayers )
connect( vlayer, SIGNAL( layerModified() ), this, SLOT( updateLayerModifiedActions() ) );
connect( vlayer, SIGNAL( editingStarted() ), this, SLOT( layerEditStateChanged() ) );
connect( vlayer, SIGNAL( editingStopped() ), this, SLOT( layerEditStateChanged() ) );
connect( vlayer, &QgsVectorLayer::readOnlyChanged, this, &QgisApp::layerEditStateChanged );
}

connect( vlayer, SIGNAL( raiseError( QString ) ), this, SLOT( onLayerError( QString ) ) );
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgsattributetabledialog.cpp
Expand Up @@ -185,6 +185,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
connect( mLayer, SIGNAL( featuresDeleted( QgsFeatureIds ) ), this, SLOT( updateTitle() ) );
connect( mLayer, SIGNAL( attributeAdded( int ) ), this, SLOT( columnBoxInit() ) );
connect( mLayer, SIGNAL( attributeDeleted( int ) ), this, SLOT( columnBoxInit() ) );
connect( mLayer, &QgsVectorLayer::readOnlyChanged, this, &QgsAttributeTableDialog::editingToggled );

// connect table info to window
connect( mMainView, SIGNAL( filterChanged() ), this, SLOT( updateTitle() ) );
Expand Down Expand Up @@ -235,7 +236,6 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mActionToggleEditing->blockSignals( true );
mActionToggleEditing->setCheckable( true );
mActionToggleEditing->setChecked( mLayer->isEditable() );
mActionToggleEditing->setEnabled(( canChangeAttributes || canDeleteFeatures || canAddAttributes || canDeleteAttributes || canAddFeatures ) && !mLayer->readOnly() );
mActionToggleEditing->blockSignals( false );

mActionSaveEdits->setEnabled( mActionToggleEditing->isEnabled() && mLayer->isEditable() );
Expand Down Expand Up @@ -761,6 +761,7 @@ void QgsAttributeTableDialog::editingToggled()
mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mActionAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
mActionToggleEditing->setEnabled(( canChangeAttributes || canDeleteFeatures || canAddAttributes || canDeleteAttributes || canAddFeatures ) && !mLayer->readOnly() );

mUpdateExpressionBox->setVisible( mLayer->isEditable() );
if ( mLayer->isEditable() && mFieldCombo->currentIndex() == -1 )
Expand Down
6 changes: 0 additions & 6 deletions src/app/qgsattributetabledialog.h
Expand Up @@ -168,12 +168,6 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
void replaceSearchWidget( QWidget* oldw, QWidget* neww );

signals:
/**
* Informs that editing mode has been toggled
* @param layer layer that has been toggled
*/
void editingToggled( QgsMapLayer *layer );

/**
* Informs that edits should be saved
* @param layer layer whose edits are to be saved
Expand Down

0 comments on commit 4fd5c01

Please sign in to comment.