mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Flip layout locator filter to use layouts, not composers
This commit is contained in:
parent
f287d40a87
commit
7edab22727
@ -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 );
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user