Skip to content

Commit d7dc77a

Browse files
author
jef
committed
fix #2299
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12577 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1af6409 commit d7dc77a

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

src/app/qgsnewvectorlayerdialog.cpp

+28-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ QgsNewVectorLayerDialog::QgsNewVectorLayerDialog( QWidget *parent, Qt::WFlags fl
3636
mTypeBox->addItem( tr( "Decimal number" ), "Real" );
3737

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

4141
mPointRadioButton->setChecked( true );
4242
mFileFormatComboBox->addItem( tr( "ESRI Shapefile" ), "ESRI Shapefile" );
@@ -65,7 +65,33 @@ QgsNewVectorLayerDialog::~QgsNewVectorLayerDialog()
6565

6666
void QgsNewVectorLayerDialog::on_mTypeBox_currentIndexChanged( int index )
6767
{
68-
mPrecision->setEnabled( index == 2 ); // Real
68+
// FIXME: sync with providers/ogr/qgsogrprovider.cpp
69+
switch ( index )
70+
{
71+
case 0: // Text data
72+
mWidth->setValidator( new QIntValidator( 1, 255, this ) );
73+
mPrecision->setEnabled( false );
74+
break;
75+
76+
case 1: // Whole number
77+
if ( mWidth->text().toInt() > 10 )
78+
mWidth->setText( "10" );
79+
mPrecision->setEnabled( false );
80+
mWidth->setValidator( new QIntValidator( 1, 10, this ) );
81+
break;
82+
83+
case 2: // Decimal number
84+
if ( mWidth->text().toInt() > 20 )
85+
mWidth->setText( "20" );
86+
mPrecision->setEnabled( false );
87+
mWidth->setValidator( new QIntValidator( 1, 20, this ) );
88+
mPrecision->setEnabled( true );
89+
break;
90+
91+
default:
92+
QgsDebugMsg( "unexpected index" );
93+
break;
94+
}
6995
}
7096

7197
QGis::WkbType QgsNewVectorLayerDialog::selectedType() const

src/providers/ogr/qgsogrprovider.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,11 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
168168
valid = false;
169169
}
170170

171+
// FIXME: sync with app/qgsnewvectorlayerdialog.cpp
171172
mNativeTypes
172173
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 1, 10 )
173174
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (real)" ), "double", QVariant::Double, 1, 20, 0, 5 )
174-
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255, 0, 0 )
175+
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), "string", QVariant::String, 1, 255 )
175176
;
176177
}
177178

@@ -1534,7 +1535,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
15341535
break;
15351536
default:
15361537
{
1537-
QgsDebugMsg( QString("Unknown vector type of: %1").arg( ( int )( vectortype ) ) );
1538+
QgsDebugMsg( QString( "Unknown vector type of: %1" ).arg(( int )( vectortype ) ) );
15381539
return false;
15391540
break;
15401541
}

0 commit comments

Comments
 (0)