Skip to content

Commit

Permalink
do not display twice the same result
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Sep 21, 2020
1 parent 2ae418d commit dd19040
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/app/locator/qgsinbuiltlocatorfilters.cpp
Expand Up @@ -354,7 +354,7 @@ QStringList QgsActiveLayerFeaturesLocatorFilter::prepare( const QString &string,

void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &, QgsFeedback *feedback )
{
int found = 0;
QgsFeatureIds featuresFound;
QgsFeature f;
QString searchString = string;
fieldRestriction( searchString );
Expand All @@ -377,8 +377,9 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
result.score = static_cast< double >( searchString.length() ) / result.displayString.size();
emit resultFetched( result );

found++;
if ( found >= mMaxTotalResults )
featuresFound << f.id();

if ( featuresFound.count() >= mMaxTotalResults )
break;
}
}
Expand All @@ -389,6 +390,10 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
if ( feedback->isCanceled() )
return;

// do not display twice the same feature
if ( featuresFound.contains( f.id() ) )
continue;

QgsLocatorResult result;

mContext.setFeature( f );
Expand Down Expand Up @@ -418,8 +423,8 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
result.score = static_cast< double >( searchString.length() ) / result.displayString.size();
emit resultFetched( result );

found++;
if ( found >= mMaxTotalResults )
featuresFound << f.id();
if ( featuresFound.count() >= mMaxTotalResults )
break;
}
}
Expand Down

0 comments on commit dd19040

Please sign in to comment.