Skip to content
Permalink
Browse files

Better reflect layer capabilities in attribute dialog toolbar

  • Loading branch information
nyalldawson committed Jun 20, 2016
1 parent 1156c8d commit 1053c5e1261e45525fad92fb012bcf1249bd2d9e
Showing with 8 additions and 1 deletion.
  1. +8 −0 src/app/qgsattributetabledialog.cpp
  2. +0 −1 src/ui/qgsattributetabledialog.ui
@@ -239,11 +239,17 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
mActionSaveEdits->setEnabled( mActionToggleEditing->isEnabled() && mLayer->isEditable() );
mActionReload->setEnabled( ! mLayer->isEditable() );
mActionAddAttribute->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() );
if ( !canDeleteFeatures )
mToolbar->removeAction( mActionDeleteSelected );
mActionAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );
if ( !canAddFeatures )
mToolbar->removeAction( mActionAddFeature );

if ( canDeleteFeatures || canAddFeatures )
mToolbar->insertSeparator( mActionExpressionSelect );

mMainViewButtonGroup->setId( mTableViewButton, QgsDualView::AttributeTable );
mMainViewButtonGroup->setId( mAttributeViewButton, QgsDualView::AttributeEditor );

@@ -748,8 +754,10 @@ void QgsAttributeTableDialog::editingToggled()
bool canChangeAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues;
bool canDeleteFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteFeatures;
bool canAddAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes;
bool canDeleteAttributes = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::DeleteAttributes;
bool canAddFeatures = mLayer->dataProvider()->capabilities() & QgsVectorDataProvider::AddFeatures;
mActionAddAttribute->setEnabled(( canChangeAttributes || canAddAttributes ) && mLayer->isEditable() );
mActionRemoveAttribute->setEnabled( canDeleteAttributes && mLayer->isEditable() );
mActionDeleteSelected->setEnabled( canDeleteFeatures && mLayer->isEditable() );
mActionAddFeature->setEnabled( canAddFeatures && mLayer->isEditable() );

@@ -170,7 +170,6 @@
<addaction name="separator"/>
<addaction name="mActionAddFeature"/>
<addaction name="mActionDeleteSelected"/>
<addaction name="separator"/>
<addaction name="mActionExpressionSelect"/>
<addaction name="mActionSelectAll"/>
<addaction name="mActionInvertSelection"/>

0 comments on commit 1053c5e

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