Skip to content

Commit

Permalink
[composer] Cleanup handling of wms layer/advanced effect detection
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 16, 2017
1 parent 8a9cee0 commit f96364e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
34 changes: 12 additions & 22 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -3800,45 +3800,35 @@ void QgsComposer::setSelectionTool()

bool QgsComposer::containsWmsLayer() const
{
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QgsComposerItem* currentItem = nullptr;
QgsComposerMap* currentMap = nullptr;
QList< QgsComposerMap *> maps;
mComposition->composerItems( maps );

for ( ; item_it != mItemWidgetMap.constEnd(); ++item_it )
Q_FOREACH ( QgsComposerMap* map, maps )
{
currentItem = item_it.key();
currentMap = dynamic_cast<QgsComposerMap *>( currentItem );
if ( currentMap )
{
if ( currentMap->containsWmsLayer() )
{
return true;
}
}
if ( map->containsWmsLayer() )
return true;
}
return false;
}

bool QgsComposer::containsAdvancedEffects() const
{
// Check if composer contains any blend modes or flattened layers for transparency
QMap<QgsComposerItem*, QgsPanelWidget*>::const_iterator item_it = mItemWidgetMap.constBegin();
QgsComposerItem* currentItem = nullptr;
QgsComposerMap* currentMap = nullptr;
QList< QgsComposerItem *> items;
mComposition->composerItems( items );

for ( ; item_it != mItemWidgetMap.constEnd(); ++item_it )
Q_FOREACH ( QgsComposerItem* currentItem, items )
{
currentItem = item_it.key();
// Check composer item's blend mode
if ( currentItem->blendMode() != QPainter::CompositionMode_SourceOver )
{
return true;
}

// If item is a composer map, check if it contains any advanced effects
currentMap = dynamic_cast<QgsComposerMap *>( currentItem );
if ( currentMap && currentMap->containsAdvancedEffects() )
if ( QgsComposerMap * currentMap = dynamic_cast<QgsComposerMap *>( currentItem ) )
{
return true;
if ( currentMap->containsAdvancedEffects() )
return true;
}
}
return false;
Expand Down
5 changes: 3 additions & 2 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -1128,7 +1128,7 @@ void QgsComposerMap::updateItem()

bool QgsComposerMap::containsWmsLayer() const
{
Q_FOREACH ( QgsMapLayer* layer, mComposition->mapSettings().layers() )
Q_FOREACH ( QgsMapLayer* layer, layersToRender() )
{
if ( QgsRasterLayer* currentRasterLayer = qobject_cast<QgsRasterLayer *>( layer ) )
{
Expand Down Expand Up @@ -1164,7 +1164,7 @@ bool QgsComposerMap::containsAdvancedEffects() const
// check if map contains advanced effects like blend modes, or flattened layers for transparency

QgsTextFormat layerFormat;
Q_FOREACH ( QgsMapLayer* layer, mComposition->mapSettings().layers() )
Q_FOREACH ( QgsMapLayer* layer, layersToRender() )
{
if ( layer )
{
Expand All @@ -1188,6 +1188,7 @@ bool QgsComposerMap::containsAdvancedEffects() const
if ( QgsPalLabeling::staticWillUseLayer( currentVectorLayer ) )
{
// Check all label blending properties

layerFormat.readFromLayer( currentVectorLayer );
if ( layerFormat.containsAdvancedEffects() )
return true;
Expand Down

0 comments on commit f96364e

Please sign in to comment.