Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
show warning when user tried to create field 'shape' in shapefile (fix
  • Loading branch information
alexbruy committed Dec 28, 2011
1 parent 397e3b4 commit d8f5b8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/app/qgsaddattrdialog.cpp
Expand Up @@ -20,13 +20,16 @@
#include "qgsvectordataprovider.h"
#include "qgslogger.h"

#include <QMessageBox>

QgsAddAttrDialog::QgsAddAttrDialog( QgsVectorLayer *vlayer, QWidget *parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
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 Down Expand Up @@ -70,6 +73,17 @@ void QgsAddAttrDialog::on_mTypeBox_currentIndexChanged( int idx )
mPrec->setValue( mPrec->maximum() );
}

void QgsAddAttrDialog::accept()
{
if ( mLayerType == "ESRI Shapefile" && mNameEdit->text().toLower() == "shape" )
{
QMessageBox::warning( this, tr( "Warning" ),
tr( "Invalid field name. This field name is reserved and cannot be used." ) );
return;
}
QDialog::accept();
}

QgsField QgsAddAttrDialog::field() const
{
QgsDebugMsg( QString( "idx:%1 name:%2 type:%3 typeName:%4 length:%5 prec:%6 comment:%7" )
Expand Down
4 changes: 4 additions & 0 deletions src/app/qgsaddattrdialog.h
Expand Up @@ -37,6 +37,10 @@ class QgsAddAttrDialog: public QDialog, private Ui::QgsAddAttrDialogBase

public slots:
void on_mTypeBox_currentIndexChanged( int idx );
void accept();

private:
QString mLayerType;

};

Expand Down

0 comments on commit d8f5b8d

Please sign in to comment.