Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
vectorlayer: better matching of supported types (fixes #10564)
  • Loading branch information
jef-n committed Jun 14, 2014
1 parent d8b54c4 commit 68fd061
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 16 deletions.
11 changes: 0 additions & 11 deletions src/app/qgisapp.cpp
Expand Up @@ -6138,17 +6138,6 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
}
}

#if 0
void QgisApp::pasteTransformations()
{
QgsPasteTransformations *pt = new QgsPasteTransformations();

mMapCanvas->freeze();

pt->exec();
}
#endif

void QgisApp::copyFeatures( QgsFeatureStore & featureStore )
{
clipboard()->replaceWithCopyOf( featureStore );
Expand Down
49 changes: 44 additions & 5 deletions src/core/qgsvectordataprovider.cpp
Expand Up @@ -264,13 +264,52 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
.arg( mNativeTypes[i].mMaxLen )
.arg( mNativeTypes[i].mMinPrec )
.arg( mNativeTypes[i].mMaxPrec ), 2 );
if ( field.type() == mNativeTypes[i].mType &&
field.length() >= mNativeTypes[i].mMinLen && field.length() <= mNativeTypes[i].mMaxLen &&
field.precision() >= mNativeTypes[i].mMinPrec && field.precision() <= mNativeTypes[i].mMaxPrec )

if ( field.type() != mNativeTypes[i].mType )
continue;

if ( field.length() == -1 )
{
// source length unlimited
if ( mNativeTypes[i].mMinLen > -1 || mNativeTypes[i].mMaxLen > -1 )
{
// destination limited
continue;
}
}
else
{
// source length limited
if ( mNativeTypes[i].mMinLen > -1 && mNativeTypes[i].mMaxLen > -1 &&
( field.length() < mNativeTypes[i].mMinLen || field.length() < mNativeTypes[i].mMaxLen ) )
{
// source length exceeds destination limits
continue;
}
}

if ( field.precision() == -1 )
{
// source precision unlimited / n/a
if ( mNativeTypes[i].mMinPrec > -1 || mNativeTypes[i].mMaxPrec > -1 )
{
// destination limited
continue;
}
}
else
{
QgsDebugMsg( "native type matches" );
return true;
// source precision unlimited / n/a
if ( mNativeTypes[i].mMinPrec > -1 && mNativeTypes[i].mMaxPrec > -1 &&
( field.precision() < mNativeTypes[i].mMinPrec || field.precision() < mNativeTypes[i].mMaxPrec ) )
{
// source precision exceeds destination limits
continue;
}
}

QgsDebugMsg( "native type matches" );
return true;
}

QgsDebugMsg( "no sufficient native type found" );
Expand Down

0 comments on commit 68fd061

Please sign in to comment.