Skip to content

Commit

Permalink
[composer] Remove QgsComposerMap::storeCurrentLayerSet
Browse files Browse the repository at this point in the history
This method was used to sync the canvas layers to a composer map.
The logic has been moved to app to avoid a dependancy between
compositions and the main map canvas
  • Loading branch information
nyalldawson committed Jan 16, 2017
1 parent f96364e commit 4941121
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion doc/api_break.dox
Expand Up @@ -569,7 +569,7 @@ and should be accessed using QgsComposerMap::overview() or QgsComposerMap::overv
instead.
- atlasFixedScale() and setAtlasFixedScale() were removed. Use atlasScalingMode()
and setAtlasScalingMode() instead.

- storeCurrentLayerSet() was removed. Use setLayers() instead.

QgsComposerMapGrid {#qgis_api_break_3_0_QgsComposerMapGrid}
------------------
Expand Down
2 changes: 0 additions & 2 deletions python/core/composer/qgscomposermap.sip
Expand Up @@ -139,8 +139,6 @@ class QgsComposerMap : QgsComposerItem
QList<QgsMapLayer*> layers() const;
/** Setter for stored layer set that is used if mKeepLayerSet is true */
void setLayers( const QList<QgsMapLayer*> layers );
/** Stores the current layer set of the qgis mapcanvas in mLayerSet*/
void storeCurrentLayerSet();

/** Getter for flag that determines if current styles of layers should be overridden by previously stored styles. @note added in 2.8 */
bool keepLayerStyles() const;
Expand Down
17 changes: 16 additions & 1 deletion src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -828,7 +828,7 @@ void QgsComposerMapWidget::on_mKeepLayerListCheckBox_stateChanged( int state )

if ( state == Qt::Checked )
{
mComposerMap->storeCurrentLayerSet();
storeCurrentLayerSet();
mComposerMap->setKeepLayerSet( true );

// mutually exclusive with following a preset
Expand Down Expand Up @@ -1450,6 +1450,21 @@ void QgsComposerMapWidget::updateOverviewFrameSymbolMarker( const QgsComposerMap
}
}

void QgsComposerMapWidget::storeCurrentLayerSet()
{
if ( !mComposerMap )
return;

QList<QgsMapLayer*> layers = QgisApp::instance()->mapCanvas()->mapSettings().layers();
mComposerMap->setLayers( layers );

if ( mComposerMap->keepLayerStyles() )
{
// also store styles associated with the layers
mComposerMap->storeCurrentLayerStyles();
}
}

QListWidgetItem* QgsComposerMapWidget::addOverviewListItem( const QString& id, const QString& name )
{
QListWidgetItem* item = new QListWidgetItem( name, nullptr );
Expand Down
3 changes: 3 additions & 0 deletions src/app/composer/qgscomposermapwidget.h
Expand Up @@ -163,6 +163,9 @@ class QgsComposerMapWidget: public QgsComposerItemBaseWidget, private Ui::QgsCom
void loadOverviewEntries();

void updateOverviewFrameSymbolMarker( const QgsComposerMapOverview* overview );

void storeCurrentLayerSet();

};

#endif
11 changes: 0 additions & 11 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -1561,17 +1561,6 @@ bool QgsComposerMap::readXml( const QDomElement& itemElem, const QDomDocument& d
return true;
}

void QgsComposerMap::storeCurrentLayerSet()
{
mLayers = _qgis_listRawToQPointer( mComposition->mapSettings().layers() );

if ( mKeepLayerStyles )
{
// also store styles associated with the layers
storeCurrentLayerStyles();
}
}

QList<QgsMapLayer*> QgsComposerMap::layers() const
{
return _qgis_listQPointerToRaw( mLayers );
Expand Down
2 changes: 0 additions & 2 deletions src/core/composer/qgscomposermap.h
Expand Up @@ -178,8 +178,6 @@ class CORE_EXPORT QgsComposerMap : public QgsComposerItem
QList<QgsMapLayer*> layers() const;
//! Setter for stored layer set that is used if mKeepLayerSet is true
void setLayers( const QList<QgsMapLayer*> layers );
//! Stores the current layer set of the qgis mapcanvas in mLayerSet
void storeCurrentLayerSet();

//! Getter for flag that determines if current styles of layers should be overridden by previously stored styles. @note added in 2.8
bool keepLayerStyles() const { return mKeepLayerStyles; }
Expand Down

0 comments on commit 4941121

Please sign in to comment.