Skip to content
Permalink
Browse files

Revert "Remove no longer required hack to get composer maps to render"

Because... server
  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 3ffeabe commit a8d627d5ce883e96850ee3aa16240e99ddca8bce
@@ -934,6 +934,23 @@ bool QgsComposer::loadFromTemplate( const QDomDocument &templateDoc, bool clearE
return result;
}

void QgsComposer::onCanvasLayersChanged( const QList<QgsMapLayer *> &layers )
{
if ( !mComposition )
return;

QList< QgsComposerMap * > maps;
mComposition->composerItems( maps );

Q_FOREACH ( QgsComposerMap *map, maps )
{
if ( map->keepLayerSet() )
continue;

map->setLayers( layers );
}
}

void QgsComposer::updateStatusCursorPos( QPointF cursorPosition )
{
if ( !mComposition )
@@ -114,6 +114,16 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
*/
bool loadFromTemplate( const QDomDocument &templateDoc, bool clearExisting );

public slots:

/**
* Should be called whenever the app's canvas layers change (or layer order
* changes). Required to update composer maps which are synced to the canvas
* layer set with the new canvas layer set.
* @note added in QGIS 3.0
*/
void onCanvasLayersChanged( const QList< QgsMapLayer * > &layers );

protected:
//! Move event
virtual void moveEvent( QMoveEvent * ) override;
@@ -6828,6 +6828,7 @@ QgsComposer *QgisApp::createNewComposer( QString title )
connect( newComposerObject, &QgsComposer::composerAdded, this, &QgisApp::composerAdded );
connect( newComposerObject, &QgsComposer::composerWillBeRemoved, this, &QgisApp::composerWillBeRemoved );
connect( newComposerObject, &QgsComposer::atlasPreviewFeatureChanged, this, &QgisApp::refreshMapCanvas );
connect( mLayerTreeCanvasBridge, &QgsLayerTreeMapCanvasBridge::canvasLayersChanged, newComposerObject, &QgsComposer::onCanvasLayersChanged );

markDirty();
return newComposerObject;
@@ -6931,6 +6932,7 @@ bool QgisApp::loadComposersFromProject( const QDomDocument &doc )
connect( composer, &QgsComposer::composerAdded, this, &QgisApp::composerAdded );
connect( composer, &QgsComposer::composerWillBeRemoved, this, &QgisApp::composerWillBeRemoved );
connect( composer, &QgsComposer::atlasPreviewFeatureChanged, this, &QgisApp::refreshMapCanvas );
connect( mLayerTreeCanvasBridge, &QgsLayerTreeMapCanvasBridge::canvasLayersChanged, composer, &QgsComposer::onCanvasLayersChanged );

QgsDebugMsg( QString( "Loaded composer %1: %2ms" ).arg( title ).arg( t.elapsed() ) );
}
@@ -475,15 +475,11 @@ QList<QgsMapLayer *> QgsComposerMap::layersToRender( const QgsExpressionContext
if ( mComposition->project()->mapThemeCollection()->hasMapTheme( presetName ) )
renderLayers = mComposition->project()->mapThemeCollection()->mapThemeVisibleLayers( presetName );
else // fallback to using map canvas layers
renderLayers = mComposition->project()->mapThemeCollection()->masterVisibleLayers();
}
else if ( mKeepLayerSet )
{
renderLayers = layers();
renderLayers = layers();
}
else
{
renderLayers = mComposition->project()->mapThemeCollection()->masterVisibleLayers();
renderLayers = layers();
}

bool ok = false;
@@ -1500,7 +1496,6 @@ QList<QgsMapLayer *> QgsComposerMap::layers() const

void QgsComposerMap::setLayers( const QList<QgsMapLayer *> &layers )
{
mKeepLayerSet = true;
mLayers = _qgis_listRawToQPointer( layers );
}

@@ -220,16 +220,16 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
void setKeepLayerSet( bool enabled ) {mKeepLayerSet = enabled;}

/**
* Getter for stored layer set. This will only be used if the
* keepLayerSet() flag is true.
* Getter for stored layer set. This will usually be synchronized with the main app canvas
* layer set (and layer order), unless the keepLayerSet() flag is true.
* @see setLayers()
* @see keepLayerSet()
*/
QList<QgsMapLayer *> layers() const;

/**
* Setter for stored layer set. Calling this will automatically set
* keepLayerSet() to true.
* Setter for stored layer set. This will usually be synchronized with the main app canvas
* layer set (and layer order), unless the keepLayerSet() flag is true.
* @see layers()
* @see keepLayerSet()
*/
@@ -1001,6 +1001,7 @@ void QgsComposerView::mouseReleaseEvent( QMouseEvent *e )
if ( mCanvas )
{
composerMap->zoomToExtent( mCanvas->mapSettings().visibleExtent() );
composerMap->setLayers( mCanvas->mapSettings().layers() );
}

composition()->addComposerMap( composerMap );

0 comments on commit a8d627d

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