Skip to content
Permalink
Browse files

QgsMapSettings and QgsComposerMap store layers for rendering as weak …

…pointers

... instead of using layer IDs which need to be resolved using QgsProject
  • Loading branch information
wonder-sk committed Dec 10, 2016
1 parent 64f1356 commit c143be7a73fe64e031f0dd7774579d64d823bf61
Showing with 340 additions and 281 deletions.
  1. +3 −0 doc/api_break.dox
  2. +2 −2 python/core/composer/qgscomposermap.sip
  3. +6 −3 python/core/qgsmapsettings.sip
  4. +3 −2 python/gui/qgsmapoverviewcanvas.sip
  5. +3 −4 src/app/composer/qgscomposermapwidget.cpp
  6. +11 −0 src/app/qgsmapthemes.cpp
  7. +4 −0 src/app/qgsmapthemes.h
  8. +84 −65 src/core/composer/qgscomposermap.cpp
  9. +4 −4 src/core/composer/qgscomposermap.h
  10. +3 −2 src/core/qgslabelingengine.cpp
  11. +2 −2 src/core/qgsmaphittest.cpp
  12. +4 −14 src/core/qgsmaprendererjob.cpp
  13. +30 −17 src/core/qgsmapsettings.cpp
  14. +9 −4 src/core/qgsmapsettings.h
  15. +12 −0 src/core/qgsmapthemecollection.cpp
  16. +10 −0 src/core/qgsmapthemecollection.h
  17. +4 −4 src/core/qgssnappingutils.cpp
  18. +13 −27 src/gui/qgsmapcanvas.cpp
  19. +5 −5 src/gui/qgsmapcanvastracer.cpp
  20. +7 −11 src/gui/qgsmapoverviewcanvas.cpp
  21. +3 −2 src/gui/qgsmapoverviewcanvas.h
  22. +2 −3 src/plugins/georeferencer/qgsgcpcanvasitem.cpp
  23. +3 −4 src/plugins/georeferencer/qgsgeorefplugingui.cpp
  24. +12 −1 src/server/qgsmaprenderer.cpp
  25. +3 −0 src/server/qgsmaprenderer.h
  26. +13 −3 src/server/qgswmsconfigparser.cpp
  27. +1 −3 tests/bench/qgsbench.cpp
  28. +1 −1 tests/src/core/testqgs25drenderer.cpp
  29. +1 −1 tests/src/core/testqgsatlascomposition.cpp
  30. +12 −12 tests/src/core/testqgsblendmodes.cpp
  31. +1 −1 tests/src/core/testqgscentroidfillsymbol.cpp
  32. +1 −1 tests/src/core/testqgscomposerdd.cpp
  33. +1 −1 tests/src/core/testqgscomposerlabel.cpp
  34. +14 −14 tests/src/core/testqgscomposermap.cpp
  35. +1 −1 tests/src/core/testqgscomposermapoverview.cpp
  36. +1 −1 tests/src/core/testqgscomposerrotation.cpp
  37. +1 −1 tests/src/core/testqgscomposerscalebar.cpp
  38. +1 −1 tests/src/core/testqgscomposertablev2.cpp
  39. +1 −1 tests/src/core/testqgsdiagram.cpp
  40. +1 −1 tests/src/core/testqgsellipsemarker.cpp
  41. +1 −1 tests/src/core/testqgsfilledmarker.cpp
  42. +1 −1 tests/src/core/testqgsfontmarker.cpp
  43. +1 −1 tests/src/core/testqgsgradients.cpp
  44. +1 −1 tests/src/core/testqgsinvertedpolygonrenderer.cpp
  45. +8 −8 tests/src/core/testqgslabelingengine.cpp
  46. +4 −19 tests/src/core/testqgslegendrenderer.cpp
  47. +1 −1 tests/src/core/testqgslinefillsymbol.cpp
  48. +2 −2 tests/src/core/testqgsmaprendererjob.cpp
  49. +3 −3 tests/src/core/testqgsmaprotation.cpp
  50. +3 −3 tests/src/core/testqgsmarkerlinesymbol.cpp
  51. +6 −6 tests/src/core/testqgspainteffect.cpp
  52. +1 −1 tests/src/core/testqgspointpatternfillsymbol.cpp
  53. +1 −1 tests/src/core/testqgsrasterfill.cpp
  54. +6 −6 tests/src/core/testqgsrasterlayer.cpp
  55. +1 −1 tests/src/core/testqgsrenderers.cpp
  56. +1 −1 tests/src/core/testqgsshapeburst.cpp
  57. +1 −1 tests/src/core/testqgssimplemarker.cpp
  58. +1 −1 tests/src/core/testqgssnappingutils.cpp
  59. +1 −1 tests/src/core/testqgssvgmarker.cpp
  60. +2 −2 tests/src/core/testqgssymbol.cpp
  61. +1 −1 tests/src/providers/testqgswcspublicservers.cpp
@@ -527,6 +527,7 @@ QgsComposerLegendItem {#qgis_api_break_3_0_QgsComposerLegendItem}
QgsComposerMap {#qgis_api_break_3_0_QgsComposerMap}
--------------

- layerSet() and setLayerSet() have been replaced by layers() and setLayers() which work with list of layers instead of layer IDs
- containsWMSLayer() has been renamed to containsWmsLayer()
- mapRenderer() has been removed. Use mapSettings() instead.
- All grid style and format enums were moved to QgsComposerMapGrid.
@@ -1121,6 +1122,7 @@ QgsMapLayerRegistry {#qgis_api_break_3_0_QgsMapLayerRegistry}
QgsMapOverviewCanvas {#qgis_api_break_3_0_QgsMapOverviewCanvas}
--------------------

- layerSet() and setLayerSet() have been replaced by layers() and setLayers() which work with list of layers instead of layer IDs
- destinationSrsChanged() was renamed to destinationCrsChanged()


@@ -1174,6 +1176,7 @@ The whole class has been refactored to stop using WKB and to use QgsAbstractGeom
QgsMapSettings {#qgis_api_break_3_0_QgsMapSettings}
--------------

- layers() and setLayers() now work with list of layers instead of layer IDs
- layerTransform() now returns a QgsCoordinateTransform object, not a pointer. An invalid QgsCoordinateTransform will
be returned instead of a null pointer if no transformation is required.
- destinationCrs() now returns a copy instead of a reference to the CRS. This has no effect on PyQGIS code, but c++
@@ -136,9 +136,9 @@ class QgsComposerMap : QgsComposerItem
void setKeepLayerSet( bool enabled );

/** Getter for stored layer set that is used if mKeepLayerSet is true */
QStringList layerSet() const;
QList<QgsMapLayer*> layers() const;
/** Setter for stored layer set that is used if mKeepLayerSet is true */
void setLayerSet( const QStringList& layerSet );
void setLayers( const QList<QgsMapLayer*> layers );
/** Stores the current layer set of the qgis mapcanvas in mLayerSet*/
void storeCurrentLayerSet();

@@ -54,10 +54,13 @@ class QgsMapSettings

//! Get list of layer IDs for map rendering
//! The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
QStringList layers() const;
//! Set list of layer IDs for map rendering. The layers must be registered in QgsProject.
QStringList layerIds() const;
//! Get list of layers for map rendering
//! The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
void setLayers( const QStringList& layers );
QList<QgsMapLayer*> layers();
//! Set list of layers for map rendering. The layers must be registered in QgsProject.
//! The layers are stored in the reverse order of how they are rendered (layer with index 0 will be on top)
void setLayers( const QList<QgsMapLayer*>& layers );

//! Get map of map layer style overrides (key: layer ID, value: style name) where a different style should be used instead of the current one
//! @note added in 2.8
@@ -17,9 +17,10 @@ class QgsMapOverviewCanvas : QWidget
void setBackgroundColor( const QColor& color );

//! updates layer set for overview
void setLayerSet( const QStringList& layerSet );
void setLayers( const QList<QgsMapLayer*>& layers );

QStringList layerSet() const;
//! Returns list of layers visible in the overview
QList<QgsMapLayer*> layers() const;

void enableAntiAliasing( bool flag );

@@ -197,11 +197,11 @@ void QgsComposerMapWidget::keepLayersVisibilityPresetSelected()
return;

QString presetName = action->text();
QStringList lst = QgsMapThemes::instance()->orderedPresetVisibleLayers( presetName );
QList<QgsMapLayer*> lst = QgsMapThemes::instance()->orderedPresetVisibleLayers2( presetName );
if ( mComposerMap )
{
mKeepLayerListCheckBox->setChecked( true );
mComposerMap->setLayerSet( lst );
mComposerMap->setLayers( lst );

mKeepLayerStylesCheckBox->setChecked( true );

@@ -836,8 +836,7 @@ void QgsComposerMapWidget::on_mKeepLayerListCheckBox_stateChanged( int state )
}
else
{
QStringList emptyLayerSet;
mComposerMap->setLayerSet( emptyLayerSet );
mComposerMap->setLayers( QList<QgsMapLayer*>() );
mComposerMap->setKeepLayerSet( false );

mKeepLayerStylesCheckBox->setChecked( Qt::Unchecked );
@@ -151,6 +151,17 @@ QStringList QgsMapThemes::orderedPresetVisibleLayers( const QString& name ) cons
return order2;
}

QList<QgsMapLayer*> QgsMapThemes::orderedPresetVisibleLayers2( const QString& name ) const
{
QList<QgsMapLayer*> lst;
Q_FOREACH ( const QString& layerId, orderedPresetVisibleLayers( name ) )
{
if ( QgsMapLayer* layer = QgsProject::instance()->mapLayer( layerId ) )
lst << layer;
}
return lst;
}

QMenu* QgsMapThemes::menu()
{
return mMenu;
@@ -50,6 +50,10 @@ class APP_EXPORT QgsMapThemes : public QObject
//! The order will match the layer order from the map canvas
QStringList orderedPresetVisibleLayers( const QString& name ) const;

//! Return list of layer IDs that should be visible for particular preset.
//! The order will match the layer order from the map canvas
QList<QgsMapLayer*> orderedPresetVisibleLayers2( const QString& name ) const;

//! Convenience menu that lists available presets and actions for management
QMenu* menu();

0 comments on commit c143be7

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