Skip to content

Commit

Permalink
Update export layer names
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 20, 2019
1 parent 5a252a3 commit a3d6075
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
15 changes: 12 additions & 3 deletions src/core/layout/qgslayoutitemmap.cpp
Expand Up @@ -1133,7 +1133,10 @@ QgsLayoutItem::ExportLayerDetail QgsLayoutItemMap::exportLayerDetails() const
detail.mapLayerId = mStagedRendererJob->currentLayerId();
if ( const QgsMapLayer *layer = mLayout->project()->mapLayer( detail.mapLayerId ) )
{
detail.name = QStringLiteral( "%1: %2" ).arg( displayName(), layer->name() );
if ( !detail.mapTheme.isEmpty() )
detail.name = QStringLiteral( "%1 (%2): %3" ).arg( displayName(), detail.mapTheme, layer->name() );
else
detail.name = QStringLiteral( "%1: %2" ).arg( displayName(), layer->name() );
}
return detail;
}
Expand All @@ -1142,11 +1145,17 @@ QgsLayoutItem::ExportLayerDetail QgsLayoutItemMap::exportLayerDetails() const
detail.mapLayerId = mStagedRendererJob->currentLayerId();
if ( const QgsMapLayer *layer = mLayout->project()->mapLayer( detail.mapLayerId ) )
{
detail.name = tr( "%1: %2 (Labels)" ).arg( displayName(), layer->name() );
if ( !detail.mapTheme.isEmpty() )
detail.name = QStringLiteral( "%1 (%2): %3 (Labels)" ).arg( displayName(), detail.mapTheme, layer->name() );
else
detail.name = tr( "%1: %2 (Labels)" ).arg( displayName(), layer->name() );
}
else
{
detail.name = tr( "%1: Labels" ).arg( displayName() );
if ( !detail.mapTheme.isEmpty() )
detail.name = tr( "%1 (%2): Labels" ).arg( displayName(), detail.mapTheme );
else
detail.name = tr( "%1: Labels" ).arg( displayName() );
}
return detail;

Expand Down
14 changes: 7 additions & 7 deletions tests/src/core/testqgslayoutmap.cpp
Expand Up @@ -1273,7 +1273,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Background ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
QVERIFY( map->nextExportPart() );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: lines" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): lines" ) );
QCOMPARE( map->exportLayerDetails().mapLayerId, linesLayer->id() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand All @@ -1282,7 +1282,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Background ) );
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
QVERIFY( map->nextExportPart() );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: points" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): points" ) );
QCOMPARE( map->exportLayerDetails().mapLayerId, pointsLayer->id() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand All @@ -1292,7 +1292,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
QVERIFY( map->nextExportPart() );
// labels
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Labels" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset2): Labels" ) );
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset2" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand All @@ -1303,7 +1303,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( map->nextExportPart() );
// "test preset"
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: lines" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset): lines" ) );
QCOMPARE( map->exportLayerDetails().mapLayerId, linesLayer->id() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand All @@ -1313,7 +1313,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
QVERIFY( map->nextExportPart() );
// labels
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Labels" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset): Labels" ) );
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand All @@ -1324,7 +1324,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( map->nextExportPart() );
map->createStagedRenderJob( map->extent(), QSize( 512, 512 ), 72 );
// "test preset 3"
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: points" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset3): points" ) );
QCOMPARE( map->exportLayerDetails().mapLayerId, pointsLayer->id() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset3" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand All @@ -1334,7 +1334,7 @@ void TestQgsLayoutMap::testLayeredExport()
QVERIFY( map->shouldDrawPart( QgsLayoutItemMap::Layer ) );
QVERIFY( map->nextExportPart() );
// labels
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1: Labels" ) );
QCOMPARE( map->exportLayerDetails().name, QStringLiteral( "Map 1 (test preset3): Labels" ) );
QVERIFY( map->exportLayerDetails().mapLayerId.isEmpty() );
QCOMPARE( map->exportLayerDetails().mapTheme, QStringLiteral( "test preset3" ) );
QVERIFY( !map->shouldDrawPart( QgsLayoutItemMap::Grid ) );
Expand Down

0 comments on commit a3d6075

Please sign in to comment.