@@ -291,58 +291,39 @@ const QList< QgsVectorDataProvider::NativeType > &QgsVectorDataProvider::nativeT
291291
292292bool QgsVectorDataProvider::supportedType ( const QgsField &field ) const
293293{
294- int i;
295294 QgsDebugMsgLevel ( QString ( " field name = %1 type = %2 length = %3 precision = %4" )
296295 .arg ( field.name (),
297296 QVariant::typeToName ( field.type () ) )
298297 .arg ( field.length () )
299298 .arg ( field.precision () ), 2 );
300- for ( i = 0 ; i < mNativeTypes . size (); i++ )
299+ Q_FOREACH ( const NativeType &nativeType, mNativeTypes )
301300 {
302301 QgsDebugMsgLevel ( QString ( " native field type = %1 min length = %2 max length = %3 min precision = %4 max precision = %5" )
303- .arg ( QVariant::typeToName ( mNativeTypes [i] .mType ) )
304- .arg ( mNativeTypes [i] .mMinLen )
305- .arg ( mNativeTypes [i] .mMaxLen )
306- .arg ( mNativeTypes [i] .mMinPrec )
307- .arg ( mNativeTypes [i] .mMaxPrec ), 2 );
302+ .arg ( QVariant::typeToName ( nativeType .mType ) )
303+ .arg ( nativeType .mMinLen )
304+ .arg ( nativeType .mMaxLen )
305+ .arg ( nativeType .mMinPrec )
306+ .arg ( nativeType .mMaxPrec ), 2 );
308307
309- if ( field.type () != mNativeTypes [i] .mType )
308+ if ( field.type () != nativeType .mType )
310309 continue ;
311310
312- if ( field.length () == -1 )
313- {
314- // source length unlimited
315- if ( mNativeTypes [i].mMinLen > -1 || mNativeTypes [i].mMaxLen > -1 )
316- {
317- // destination limited
318- continue ;
319- }
320- }
321- else
311+ if ( field.length () > 0 )
322312 {
323313 // source length limited
324- if ( mNativeTypes [i] .mMinLen > - 1 && mNativeTypes [i]. mMaxLen > - 1 &&
325- ( field. length () < mNativeTypes [i]. mMinLen || field.length () > mNativeTypes [i] .mMaxLen ) )
314+ if (( nativeType .mMinLen > 0 && field. length () < nativeType. mMinLen ) ||
315+ ( nativeType. mMaxLen > 0 && field.length () > nativeType .mMaxLen ) )
326316 {
327317 // source length exceeds destination limits
328318 continue ;
329319 }
330320 }
331321
332- if ( field.precision () == -1 )
333- {
334- // source precision unlimited / n/a
335- if ( mNativeTypes [i].mMinPrec > -1 || mNativeTypes [i].mMaxPrec > -1 )
336- {
337- // destination limited
338- continue ;
339- }
340- }
341- else
322+ if ( field.precision () > 0 )
342323 {
343- // source precision unlimited / n/a
344- if ( mNativeTypes [i] .mMinPrec > - 1 && mNativeTypes [i]. mMaxPrec > - 1 &&
345- ( field. precision () < mNativeTypes [i]. mMinPrec || field.precision () > mNativeTypes [i] .mMaxPrec ) )
324+ // source precision limited
325+ if (( nativeType .mMinPrec > 0 && field. precision () < nativeType. mMinPrec ) ||
326+ ( nativeType. mMaxPrec > 0 && field.precision () > nativeType .mMaxPrec ) )
346327 {
347328 // source precision exceeds destination limits
348329 continue ;
0 commit comments