Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix QgsClipboard::retrieveFields and adapt unit test (because feature…
…s without geometries are now allowed in QgsClipboard)
- Loading branch information
Showing
with
13 additions
and
2 deletions.
-
+11
−0
src/app/qgsclipboard.cpp
-
+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() |
|
|