Skip to content
Permalink
Browse files

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 53a083f053db614d1302a33203f0cb655ddc17e5
Showing with 9 additions and 2 deletions.
  1. +8 −2 src/app/qgsattributetabledialog.cpp
  2. +1 −0 src/app/qgsattributetabledialog.h
@@ -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 );
@@ -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() );
@@ -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() )
@@ -950,6 +951,11 @@ void QgsAttributeTableDialog::toggleDockMode( bool docked )
}
}

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

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

0 comments on commit 53a083f

Please sign in to comment.
You can’t perform that action at this time.