Skip to content
Permalink
Browse files

limit shapefile fieldname to 10 in fieldcalculator and add attribute …

…dialog (fixes #8235)
  • Loading branch information
jef-n committed Jul 9, 2013
1 parent 36bf49d commit 7ccd3d0ab9c008791589d4cd4eedfc56370ea2a8
Showing with 11 additions and 3 deletions.
  1. +5 −2 src/app/qgsaddattrdialog.cpp
  2. +1 −1 src/app/qgsaddattrdialog.h
  3. +5 −0 src/app/qgsfieldcalculator.cpp
@@ -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++ )
{
@@ -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 )
@@ -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." ) );
@@ -41,7 +41,7 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase
void accept();

private:
QString mLayerType;
bool mIsShapeFile;

void setPrecisionMinMax();
};
@@ -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 );

0 comments on commit 7ccd3d0

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