Skip to content

Commit

Permalink
Allow field calculator also for layers where adding new fields is not…
Browse files Browse the repository at this point in the history
… possible (user will have to use one of the existing fields)

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11828 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Oct 22, 2009
1 parent ee82f84 commit d727f91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/app/qgsfieldcalculator.cpp
Expand Up @@ -35,6 +35,14 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl ): QDialog(), mVector

//disable ok button until there is text for output field and expression
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( false );

// disable creation of new fields if not supported by data provider
if ( !( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
{
mUpdateExistingFieldCheckBox->setEnabled( false ); // must stay checked
mNewFieldGroupBox->setEnabled( false );
mNewFieldGroupBox->setTitle( mNewFieldGroupBox->title() + tr( " (not supported by provider)" ) );
}
}

QgsFieldCalculator::~QgsFieldCalculator()
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -355,7 +355,7 @@ void QgsVectorLayerProperties::updateButtons()
int cap = layer->dataProvider()->capabilities();
mAddAttributeButton->setEnabled( cap & QgsVectorDataProvider::AddAttributes );
mDeleteAttributeButton->setEnabled( cap & QgsVectorDataProvider::DeleteAttributes );
mCalculateFieldButton->setEnabled(( cap & QgsVectorDataProvider::AddAttributes ) && ( cap & QgsVectorDataProvider::ChangeAttributeValues ) );
mCalculateFieldButton->setEnabled( cap & QgsVectorDataProvider::ChangeAttributeValues );
mToggleEditingButton->setChecked( true );
}
else
Expand Down

0 comments on commit d727f91

Please sign in to comment.