Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed Mar 19, 2010
1 parent 92daba6 commit ee2123e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
27 changes: 22 additions & 5 deletions src/app/qgsnewvectorlayerdialog.cpp
Expand Up @@ -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()
Expand All @@ -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:
Expand Down Expand Up @@ -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 );
}
2 changes: 2 additions & 0 deletions src/app/qgsnewvectorlayerdialog.h
Expand Up @@ -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;
Expand Down

0 comments on commit ee2123e

Please sign in to comment.