Skip to content

Commit

Permalink
fix #2299
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12577 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 22, 2009
1 parent f6cdd5d commit 5f4256a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
30 changes: 28 additions & 2 deletions src/app/qgsnewvectorlayerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl
mTypeBox->addItem( tr( "Decimal number" ), "Real" );

mWidth->setValidator( new QIntValidator( 1, 255, this ) );
mPrecision->setValidator( new QIntValidator( 0, 20, this ) );
mPrecision->setValidator( new QIntValidator( 0, 5, this ) );

mPointRadioButton->setChecked( true );
mFileFormatComboBox->addItem( tr( "ESRI Shapefile" ), "ESRI Shapefile" );
Expand Down Expand Up @@ -65,7 +65,33 @@ QgsNewVectorLayerDialog::~QgsNewVectorLayerDialog()

void QgsNewVectorLayerDialog::on_mTypeBox_currentIndexChanged( int index )
{
mPrecision->setEnabled( index == 2 ); // Real
// FIXME: sync with providers/ogr/qgsogrprovider.cpp
switch ( index )
{
case 0: // Text data
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
mPrecision->setEnabled( false );
break;

case 1: // Whole number
if ( 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 )
mWidth->setText( "20" );
mPrecision->setEnabled( false );
mWidth->setValidator( new QIntValidator( 1, 20, this ) );
mPrecision->setEnabled( true );
break;

default:
QgsDebugMsg( "unexpected index" );
break;
}
}

QGis::WkbType QgsNewVectorLayerDialog::selectedType() const
Expand Down
5 changes: 3 additions & 2 deletions src/providers/ogr/qgsogrprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
valid = false;
}

// FIXME: sync with app/qgsnewvectorlayerdialog.cpp
mNativeTypes
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 5 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255, 0, 0 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
;
}

Expand Down Expand Up @@ -1534,7 +1535,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
break;
default:
{
QgsDebugMsg( QString("Unknown vector type of: %1").arg( ( int )( vectortype ) ) );
QgsDebugMsg( QString( "Unknown vector type of: %1" ).arg(( int )( vectortype ) ) );
return false;
break;
}
Expand Down

0 comments on commit 5f4256a

Please sign in to comment.