Skip to content

Commit

Permalink
Better reflect layer capabilities in attribute dialog toolbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 20, 2016
1 parent 1156c8d commit 1053c5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/app/qgsattributetabledialog.cpp
Expand Up @@ -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 );

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

Expand Down
1 change: 0 additions & 1 deletion src/ui/qgsattributetabledialog.ui
Expand Up @@ -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"/>
Expand Down

0 comments on commit 1053c5e

Please sign in to comment.