Skip to content
Permalink
Browse files

Flip layout locator filter to use layouts, not composers

  • Loading branch information
nyalldawson committed Jan 7, 2018
1 parent f287d40 commit 7edab2272797494242468ac3e2982c5979b0fd86
Showing with 9 additions and 8 deletions.
  1. +9 −8 src/app/locator/qgsinbuiltlocatorfilters.cpp
@@ -71,19 +71,20 @@ QgsLayoutLocatorFilter::QgsLayoutLocatorFilter( QObject *parent )

void QgsLayoutLocatorFilter::fetchResults( const QString &string, const QgsLocatorContext &, QgsFeedback *feedback )
{
Q_FOREACH ( QgsComposition *composition, QgsProject::instance()->layoutManager()->compositions() )
const QList< QgsMasterLayoutInterface * > layouts = QgsProject::instance()->layoutManager()->layouts();
for ( QgsMasterLayoutInterface *layout : layouts )
{
if ( feedback->isCanceled() )
return;

if ( composition && stringMatches( composition->name(), string ) )
if ( layout && stringMatches( layout->name(), string ) )
{
QgsLocatorResult result;
result.filter = this;
result.displayString = composition->name();
result.userData = composition->name();
result.displayString = layout->name();
result.userData = layout->name();
//result.icon = QgsMapLayerModel::iconForLayer( layer->layer() );
result.score = static_cast< double >( string.length() ) / composition->name().length();
result.score = static_cast< double >( string.length() ) / layout->name().length();
emit resultFetched( result );
}
}
@@ -92,11 +93,11 @@ void QgsLayoutLocatorFilter::fetchResults( const QString &string, const QgsLocat
void QgsLayoutLocatorFilter::triggerResult( const QgsLocatorResult &result )
{
QString layoutName = result.userData.toString();
QgsComposition *composition = QgsProject::instance()->layoutManager()->compositionByName( layoutName );
if ( !composition )
QgsMasterLayoutInterface *layout = QgsProject::instance()->layoutManager()->layoutByName( layoutName );
if ( !layout )
return;

QgisApp::instance()->openComposer( composition );
QgisApp::instance()->openLayoutDesignerDialog( layout );
}


0 comments on commit 7edab22

Please sign in to comment.
You can’t perform that action at this time.