Skip to content
Permalink
Browse files

Don't use canvas mapSettings when composer maps respond to layer changes

  • Loading branch information
nyalldawson committed Jan 18, 2017
1 parent 07c54e5 commit 2183887759571fc173153051d97d8256c043e2f8
@@ -570,6 +570,7 @@ instead.
- atlasFixedScale() and setAtlasFixedScale() were removed. Use atlasScalingMode()
and setAtlasScalingMode() instead.
- storeCurrentLayerSet() was removed. Use setLayers() instead.
- The layersChanged() slot was removed.

QgsComposerMapGrid {#qgis_api_break_3_0_QgsComposerMapGrid}
------------------
@@ -387,12 +387,4 @@ class QgsComposerMap : QgsComposerItem

virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = 0 );

protected slots:

/** Called when layers are added or removed from the layer registry. Updates the maps
* layer set and redraws the map if required.
* @note added in QGIS 2.9
*/
void layersChanged();

};
@@ -501,7 +501,7 @@ void QgsComposerMap::updateCachedImage()
{
mCacheUpdated = false;
cache();
QGraphicsRectItem::update();
update();
}

void QgsComposerMap::renderModeUpdateCachedImage()
@@ -512,12 +512,6 @@ void QgsComposerMap::renderModeUpdateCachedImage()
}
}

void QgsComposerMap::layersChanged()
{
syncLayerSet();
renderModeUpdateCachedImage();
}

void QgsComposerMap::setCacheUpdated( bool u )
{
mCacheUpdated = u;
@@ -1220,8 +1214,12 @@ void QgsComposerMap::connectUpdateSlot()
QgsProject* project = mComposition->project();
if ( project )
{
connect( project, SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( layersChanged() ) );
connect( project, SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( layersChanged() ) );
// handles updating the stored layer state BEFORE the layers are removed
connect( project, static_cast < void ( QgsProject::* )( const QList<QgsMapLayer*>& layers ) > ( &QgsProject::layersWillBeRemoved ),
this, &QgsComposerMap::layersAboutToBeRemoved );
// redraws the map AFTER layers are removed
connect( project, &QgsProject::layersRemoved, this, &QgsComposerMap::renderModeUpdateCachedImage );
connect( project, &QgsProject::legendLayersAdded, this, &QgsComposerMap::renderModeUpdateCachedImage );
}
}

@@ -1628,33 +1626,14 @@ void QgsComposerMap::storeCurrentLayerStyles()
}
}

void QgsComposerMap::syncLayerSet()
void QgsComposerMap::layersAboutToBeRemoved( QList< QgsMapLayer* > layers )
{
if ( mLayers.size() < 1 )
{
return;
}

//if layer set is fixed, do a lookup in the layer registry to also find the non-visible layers
QList<QgsMapLayer*> currentLayers;
if ( mKeepLayerSet )
{
currentLayers = mComposition->project()->mapLayers().values();
}
else //only consider layers visible in the map
{
currentLayers = mComposition->mapSettings().layers();
}

for ( int i = mLayers.size() - 1; i >= 0; --i )
if ( !mLayers.isEmpty() || mLayerStyleOverrides.isEmpty() )
{
if ( QgsMapLayer* layer = mLayers.at( i ).data() )
Q_FOREACH ( QgsMapLayer* layer, layers )
{
if ( !currentLayers.contains( layer ) )
{
mLayerStyleOverrides.remove( layer->id() );
mLayers.removeAt( i );
}
mLayerStyleOverrides.remove( layer->id() );
mLayers.removeAll( layer );
}
}
}
@@ -458,13 +458,8 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem

virtual void refreshDataDefinedProperty( const QgsComposerObject::DataDefinedProperty property = QgsComposerObject::AllProperties, const QgsExpressionContext* context = nullptr ) override;

protected slots:

/** Called when layers are added or removed from the layer registry. Updates the maps
* layer set and redraws the map if required.
* @note added in QGIS 2.9
*/
void layersChanged();
private slots:
void layersAboutToBeRemoved( QList<QgsMapLayer*> layers );

private:

0 comments on commit 2183887

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