mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -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 )
|
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() )
|
if ( feedback->isCanceled() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( composition && stringMatches( composition->name(), string ) )
|
if ( layout && stringMatches( layout->name(), string ) )
|
||||||
{
|
{
|
||||||
QgsLocatorResult result;
|
QgsLocatorResult result;
|
||||||
result.filter = this;
|
result.filter = this;
|
||||||
result.displayString = composition->name();
|
result.displayString = layout->name();
|
||||||
result.userData = composition->name();
|
result.userData = layout->name();
|
||||||
//result.icon = QgsMapLayerModel::iconForLayer( layer->layer() );
|
//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 );
|
emit resultFetched( result );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,11 +93,11 @@ void QgsLayoutLocatorFilter::fetchResults( const QString &string, const QgsLocat
|
|||||||
void QgsLayoutLocatorFilter::triggerResult( const QgsLocatorResult &result )
|
void QgsLayoutLocatorFilter::triggerResult( const QgsLocatorResult &result )
|
||||||
{
|
{
|
||||||
QString layoutName = result.userData.toString();
|
QString layoutName = result.userData.toString();
|
||||||
QgsComposition *composition = QgsProject::instance()->layoutManager()->compositionByName( layoutName );
|
QgsMasterLayoutInterface *layout = QgsProject::instance()->layoutManager()->layoutByName( layoutName );
|
||||||
if ( !composition )
|
if ( !layout )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QgisApp::instance()->openComposer( composition );
|
QgisApp::instance()->openLayoutDesignerDialog( layout );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user