mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
do not display twice the same result
This commit is contained in:
parent
2ae418da24
commit
dd19040226
@ -354,7 +354,7 @@ QStringList QgsActiveLayerFeaturesLocatorFilter::prepare( const QString &string,
|
|||||||
|
|
||||||
void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &, QgsFeedback *feedback )
|
void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &, QgsFeedback *feedback )
|
||||||
{
|
{
|
||||||
int found = 0;
|
QgsFeatureIds featuresFound;
|
||||||
QgsFeature f;
|
QgsFeature f;
|
||||||
QString searchString = string;
|
QString searchString = string;
|
||||||
fieldRestriction( searchString );
|
fieldRestriction( searchString );
|
||||||
@ -377,8 +377,9 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
|
|||||||
result.score = static_cast< double >( searchString.length() ) / result.displayString.size();
|
result.score = static_cast< double >( searchString.length() ) / result.displayString.size();
|
||||||
emit resultFetched( result );
|
emit resultFetched( result );
|
||||||
|
|
||||||
found++;
|
featuresFound << f.id();
|
||||||
if ( found >= mMaxTotalResults )
|
|
||||||
|
if ( featuresFound.count() >= mMaxTotalResults )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -389,6 +390,10 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
|
|||||||
if ( feedback->isCanceled() )
|
if ( feedback->isCanceled() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// do not display twice the same feature
|
||||||
|
if ( featuresFound.contains( f.id() ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
QgsLocatorResult result;
|
QgsLocatorResult result;
|
||||||
|
|
||||||
mContext.setFeature( f );
|
mContext.setFeature( f );
|
||||||
@ -418,8 +423,8 @@ void QgsActiveLayerFeaturesLocatorFilter::fetchResults( const QString &string, c
|
|||||||
result.score = static_cast< double >( searchString.length() ) / result.displayString.size();
|
result.score = static_cast< double >( searchString.length() ) / result.displayString.size();
|
||||||
emit resultFetched( result );
|
emit resultFetched( result );
|
||||||
|
|
||||||
found++;
|
featuresFound << f.id();
|
||||||
if ( found >= mMaxTotalResults )
|
if ( featuresFound.count() >= mMaxTotalResults )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user