Skip to content
Permalink
Browse files

add sanity checks to new vector dialog and some cleanups

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@13079 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Mar 19, 2010
1 parent 92daba6 commit ee2123e262f377858e17075c2b64b8d920eb5dbb
Showing with 24 additions and 5 deletions.
  1. +22 −5 src/app/qgsnewvectorlayerdialog.cpp
  2. +2 −0 src/app/qgsnewvectorlayerdialog.h
@@ -57,6 +57,12 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl

mCrsId = srs.srsid();
leSpatialRefSys->setText( srs.toProj4() );

connect( mNameEdit, SIGNAL( textChanged( QString ) ), this, SLOT( nameChanged( QString ) ) );
connect( mAttributeView, SIGNAL( itemSelectionChanged() ), this, SLOT( selectionChanged() ) );

mAddAttributeButton->setEnabled( false );
mRemoveAttributeButton->setEnabled( false );
}

QgsNewVectorLayerDialog::~QgsNewVectorLayerDialog()
@@ -69,23 +75,24 @@ void QgsNewVectorLayerDialog::on_mTypeBox_currentIndexChanged( int index )
switch ( index )
{
case 0: // Text data
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 255 )
mWidth->setText( "80" );
mPrecision->setEnabled( false );
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
break;

case 1: // Whole number
if ( mWidth->text().toInt() > 10 )
if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 10 )
mWidth->setText( "10" );
mPrecision->setEnabled( false );
mWidth->setValidator( new QIntValidator( 1, 10, this ) );
break;

case 2: // Decimal number
if ( mWidth->text().toInt() > 20 )
if ( mWidth->text().toInt() < 1 || mWidth->text().toInt() > 20 )
mWidth->setText( "20" );
mPrecision->setEnabled( false );
mWidth->setValidator( new QIntValidator( 1, 20, this ) );
mPrecision->setEnabled( true );
mWidth->setValidator( new QIntValidator( 1, 20, this ) );
break;

default:
@@ -176,3 +183,13 @@ QString QgsNewVectorLayerDialog::selectedFileFormat() const
QString myType = mFileFormatComboBox->itemData( mFileFormatComboBox->currentIndex(), Qt::UserRole ).toString();
return myType;
}

void QgsNewVectorLayerDialog::nameChanged( QString name )
{
mAddAttributeButton->setDisabled( name.isEmpty() || mAttributeView->findItems( name, Qt::MatchExactly ).size() > 0 );
}

void QgsNewVectorLayerDialog::selectionChanged()
{
mRemoveAttributeButton->setDisabled( mAttributeView->selectedItems().size() == 0 );
}
@@ -46,6 +46,8 @@ class QgsNewVectorLayerDialog: public QDialog, private Ui::QgsNewVectorLayerDial
void on_mTypeBox_currentIndexChanged( int index );
void on_pbnChangeSpatialRefSys_clicked();
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
void nameChanged( QString );
void selectionChanged();

private:
QPushButton *mOkButton;

0 comments on commit ee2123e

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