Navigation Menu

Skip to content

Commit

Permalink
fix wrong feedback message in case addFeatures had not been successfu…
Browse files Browse the repository at this point in the history
…l in paste and improvements of the message texts
  • Loading branch information
signedav committed Jul 8, 2020
1 parent ee660f7 commit d523eb9
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/app/qgisapp.cpp
Expand Up @@ -10270,32 +10270,38 @@ void QgisApp::pasteFromClipboard( QgsMapLayer *destinationLayer )

void QgisApp::pasteFeatures( QgsVectorLayer *pasteVectorLayer, int invalidGeometriesCount, int nTotalFeatures, QgsFeatureList &features )
{
pasteVectorLayer->addFeatures( features );
QgsFeatureIds newIds;
newIds.reserve( features.size() );
for ( const QgsFeature &f : qgis::as_const( features ) )
int nCopiedFeatures = features.count();
if ( pasteVectorLayer->addFeatures( features ) )
{
newIds << f.id();
}
QgsFeatureIds newIds;
newIds.reserve( features.size() );
for ( const QgsFeature &f : qgis::as_const( features ) )
{
newIds << f.id();
}

pasteVectorLayer->selectByIds( newIds );
pasteVectorLayer->selectByIds( newIds );
}
else
{
nCopiedFeatures = 0;
}
pasteVectorLayer->endEditCommand();
pasteVectorLayer->updateExtents();

int nCopiedFeatures = features.count();
Qgis::MessageLevel level = ( nCopiedFeatures == 0 || invalidGeometriesCount > 0 ) ? Qgis::Warning : Qgis::Info;
QString message;
if ( nCopiedFeatures == 0 )
{
message = tr( "No features could be successfully pasted." );
message = tr( "No features pasted." );
}
else if ( nCopiedFeatures == nTotalFeatures )
{
message = tr( "%1 features were successfully pasted." ).arg( nCopiedFeatures );
message = tr( "%1 features were pasted." ).arg( nCopiedFeatures );
}
else
{
message = tr( "%1 of %2 features could be successfully pasted." ).arg( nCopiedFeatures ).arg( nTotalFeatures );
message = tr( "%1 of %2 features could be pasted." ).arg( nCopiedFeatures ).arg( nTotalFeatures );
}

// warn the user if the pasted features have invalid geometries
Expand Down

0 comments on commit d523eb9

Please sign in to comment.