Skip to content

Commit

Permalink
show warning when user tried to create field 'shape' in shapefile (fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Dec 28, 2011
1 parent 7f04787 commit 4629900
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 4629900

Please sign in to comment.