Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Disable attribute table save button when there are no uncommited changes
  • Loading branch information
uclaros authored and nyalldawson committed Apr 29, 2020
1 parent 326917f commit 53a083f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -201,6 +201,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mLayer, &QgsVectorLayer::featuresDeleted, this, &QgsAttributeTableDialog::updateTitle );
connect( mLayer, &QgsVectorLayer::editingStopped, this, &QgsAttributeTableDialog::updateTitle );
connect( mLayer, &QgsVectorLayer::readOnlyChanged, this, &QgsAttributeTableDialog::editingToggled );
connect( mLayer, &QgsVectorLayer::layerModified, this, &QgsAttributeTableDialog::updateLayerModifiedActions );

// connect table info to window
connect( mMainView, &QgsDualView::filterChanged, this, &QgsAttributeTableDialog::updateTitle );
Expand Down Expand Up @@ -256,7 +257,7 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
mActionToggleEditing->setChecked( mLayer->isEditable() );
mActionToggleEditing->blockSignals( false );

mActionSaveEdits->setEnabled( mActionToggleEditing->isEnabled() && mLayer->isEditable() );
mActionSaveEdits->setEnabled( mActionToggleEditing->isEnabled() && mLayer->isEditable() && mLayer->isModified() );
mActionReload->setEnabled( ! mLayer->isEditable() );
mActionAddAttribute->setEnabled( ( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
Expand Down Expand Up @@ -717,7 +718,7 @@ void QgsAttributeTableDialog::editingToggled()
{
mActionToggleEditing->blockSignals( true );
mActionToggleEditing->setChecked( mLayer->isEditable() );
mActionSaveEdits->setEnabled( mLayer->isEditable() );
mActionSaveEdits->setEnabled( mLayer->isEditable() && mLayer->isModified() );
mActionReload->setEnabled( ! mLayer->isEditable() );
updateMultiEditButtonState();
if ( mLayer->isEditable() )
Expand Down Expand Up @@ -950,6 +951,11 @@ void QgsAttributeTableDialog::toggleDockMode( bool docked )
}
}

void QgsAttributeTableDialog::updateLayerModifiedActions()
{
mActionSaveEdits->setEnabled( mActionToggleEditing->isEnabled() && mLayer->isEditable() && mLayer->isModified() );
}

//
// QgsAttributeTableDock
//
Expand Down
1 change: 1 addition & 0 deletions src/app/qgsattributetabledialog.h
Expand Up @@ -211,6 +211,7 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
void formFilterSet( const QString &filter, QgsAttributeForm::FilterType type );
void showContextMenu( QgsActionMenu *menu, QgsFeatureId fid );
void toggleDockMode( bool docked );
void updateLayerModifiedActions();

private:
QMenu *mMenuActions = nullptr;
Expand Down

0 comments on commit 53a083f

Please sign in to comment.