Skip to content
Permalink
Browse files
Fix QgsClipboard::retrieveFields and adapt unit test (because feature…
…s without geometries are now allowed in QgsClipboard)
  • Loading branch information
mhugent authored and nyalldawson committed Aug 10, 2018
1 parent 036000f commit 83da5707b8b47c12bbfe0635fa6df26113ac4d27
Showing with 13 additions and 2 deletions.
  1. +11 −0 src/app/qgsclipboard.cpp
  2. +2 −2 tests/src/app/testqgisappclipboard.cpp
@@ -255,11 +255,22 @@ QgsFields QgsClipboard::retrieveFields() const
QgsFields f = QgsOgrUtils::stringToFields( string, QTextCodec::codecForName( "System" ) );
if ( f.size() < 1 )
{
if ( string.isEmpty() )
{
return f;
}

//wkt?
QStringList lines = string.split( "\n" );
if ( lines.size() > 0 )
{
QStringList fieldNames = lines.at( 0 ).split( "\t" );
//wkt / text always has wkt_geom as first attribute (however values can be NULL)
if ( fieldNames.at( 0 ) != "wkt_geom" )
{
return f;
}

for ( int i = 0; i < fieldNames.size(); ++i )
{
QString fieldName = fieldNames.at( i );
@@ -241,10 +241,10 @@ void TestQgisAppClipboard::pasteWkt()
QCOMPARE( point->x(), 125.0 );
QCOMPARE( point->y(), 10.0 );

// only fields => no geom so no feature list is returned
//clipboard now supports features without geometry
mQgisApp->clipboard()->setText( QStringLiteral( "MNL 11 282 km \nMNL 11 347.80000000000001 km " ) );
features = mQgisApp->clipboard()->copyOf();
QCOMPARE( features.length(), 0 );
QCOMPARE( features.length(), 2 );
}

void TestQgisAppClipboard::pasteGeoJson()

0 comments on commit 83da570

Please sign in to comment.