Skip to content

Commit 6497f10

Browse files
author
wonder
committedOct 22, 2009
Allow field calculator also for layers where adding new fields is not possible (user will have to use one of the existing fields)
git-svn-id: http://svn.osgeo.org/qgis/trunk@11828 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent e99592f commit 6497f10

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎src/app/qgsfieldcalculator.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl ): QDialog(), mVector
3535

3636
//disable ok button until there is text for output field and expression
3737
mButtonBox->button( QDialogButtonBox::Ok )->setEnabled( false );
38+
39+
// disable creation of new fields if not supported by data provider
40+
if ( !( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes ) )
41+
{
42+
mUpdateExistingFieldCheckBox->setEnabled( false ); // must stay checked
43+
mNewFieldGroupBox->setEnabled( false );
44+
mNewFieldGroupBox->setTitle( mNewFieldGroupBox->title() + tr( " (not supported by provider)" ) );
45+
}
3846
}
3947

4048
QgsFieldCalculator::~QgsFieldCalculator()

‎src/app/qgsvectorlayerproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ void QgsVectorLayerProperties::updateButtons()
355355
int cap = layer->dataProvider()->capabilities();
356356
mAddAttributeButton->setEnabled( cap & QgsVectorDataProvider::AddAttributes );
357357
mDeleteAttributeButton->setEnabled( cap & QgsVectorDataProvider::DeleteAttributes );
358-
mCalculateFieldButton->setEnabled(( cap & QgsVectorDataProvider::AddAttributes ) && ( cap & QgsVectorDataProvider::ChangeAttributeValues ) );
358+
mCalculateFieldButton->setEnabled( cap & QgsVectorDataProvider::ChangeAttributeValues );
359359
mToggleEditingButton->setChecked( true );
360360
}
361361
else

0 commit comments

Comments
 (0)
Please sign in to comment.