@@ -402,7 +402,7 @@ void QgsAllLayersFeaturesLocatorFilter::fetchResults( const QString &string, con
402
402
result.icon = preparedLayer.layerIcon ;
403
403
result.score = static_cast < double >( string.length () ) / result.displayString .size ();
404
404
405
- result.contextMenuActions << new QAction ( tr ( " Open form" ) );
405
+ result.contextMenuActions . insert ( OpenForm, new QAction ( tr ( " Open form" ) ) );
406
406
emit resultFetched ( result );
407
407
408
408
foundInCurrentLayer++;
@@ -417,28 +417,23 @@ void QgsAllLayersFeaturesLocatorFilter::fetchResults( const QString &string, con
417
417
418
418
void QgsAllLayersFeaturesLocatorFilter::triggerResult ( const QgsLocatorResult &result )
419
419
{
420
- triggerResultFromContextMenu ( result, nullptr );
420
+ triggerResultFromContextMenu ( result, NoEntry );
421
421
}
422
422
423
- void QgsAllLayersFeaturesLocatorFilter::triggerResultFromContextMenu ( const QgsLocatorResult &result, const QAction *action )
423
+ void QgsAllLayersFeaturesLocatorFilter::triggerResultFromContextMenu ( const QgsLocatorResult &result, const int id )
424
424
{
425
425
QVariantList dataList = result.userData .toList ();
426
- QgsFeatureId id = dataList.at ( 0 ).toLongLong ();
426
+ QgsFeatureId fid = dataList.at ( 0 ).toLongLong ();
427
427
QString layerId = dataList.at ( 1 ).toString ();
428
428
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer *>( QgsProject::instance ()->mapLayer ( layerId ) );
429
429
if ( !layer )
430
430
return ;
431
431
432
- if ( !action )
433
- {
434
- QgisApp::instance ()->mapCanvas ()->zoomToFeatureIds ( layer, QgsFeatureIds () << id );
435
- }
436
- else
432
+ if ( id == OpenForm )
437
433
{
438
- // no need to check for which action, since the filter shows only one
439
434
QgsFeature f;
440
435
QgsFeatureRequest request;
441
- request.setFilterFid ( id );
436
+ request.setFilterFid ( fid );
442
437
bool fetched = layer->getFeatures ( request ).nextFeature ( f );
443
438
if ( !fetched )
444
439
return ;
@@ -452,6 +447,10 @@ void QgsAllLayersFeaturesLocatorFilter::triggerResultFromContextMenu( const QgsL
452
447
action.viewFeatureForm ();
453
448
}
454
449
}
450
+ else
451
+ {
452
+ QgisApp::instance ()->mapCanvas ()->zoomToFeatureIds ( layer, QgsFeatureIds () << fid );
453
+ }
455
454
}
456
455
457
456
//
0 commit comments