Skip to content

Commit

Permalink
limit shapefile fieldname to 10 in fieldcalculator and add attribute …
Browse files Browse the repository at this point in the history
…dialog (fixes #8235)
  • Loading branch information
jef-n committed Jul 9, 2013
1 parent 36bf49d commit 7ccd3d0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/app/qgsaddattrdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
, mIsShapeFile( vlayer && vlayer->providerType() == "ogr" && vlayer->storageType() == "ESRI Shapefile" )
{
setupUi( this );

//fill data types into the combo box
const QList< QgsVectorDataProvider::NativeType > &typelist = vlayer->dataProvider()->nativeTypes();
mLayerType = vlayer->storageType();

for ( int i = 0; i < typelist.size(); i++ )
{
Expand All @@ -50,6 +50,9 @@ QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt:
}

on_mTypeBox_currentIndexChanged( 0 );

if ( mIsShapeFile )
mNameEdit->setMaxLength( 10 );
}

void QgsAddAttrDialog::on_mTypeBox_currentIndexChanged( int idx )
Expand Down Expand Up @@ -86,7 +89,7 @@ void QgsAddAttrDialog::setPrecisionMinMax()

void QgsAddAttrDialog::accept()
{
if ( mLayerType == "ESRI Shapefile" && mNameEdit->text().toLower() == "shape" )
if ( mIsShapeFile && mNameEdit->text().toLower() == "shape" )
{
QMessageBox::warning( this, tr( "Warning" ),
tr( "Invalid field name. This field name is reserved and cannot be used." ) );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsaddattrdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
void accept();

private:
QString mLayerType;
bool mIsShapeFile;

void setPrecisionMinMax();
};
Expand Down
5 changes: 5 additions & 0 deletions src/app/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ QgsFieldCalculator::QgsFieldCalculator( QgsVectorLayer* vl )
mOutputFieldWidthSpinBox->setValue( 10 );
mOutputFieldPrecisionSpinBox->setValue( 3 );

if ( vl->providerType() == "ogr" && vl->storageType() == "ESRI Shapefile" )
{
mOutputFieldNameLineEdit->setMaxLength( 10 );
}

mUpdateExistingGroupBox->setEnabled( vl->dataProvider()->capabilities() & QgsVectorDataProvider::ChangeAttributeValues );
mNewFieldGroupBox->setEnabled( vl->dataProvider()->capabilities() & QgsVectorDataProvider::AddAttributes );

Expand Down

0 comments on commit 7ccd3d0

Please sign in to comment.