Skip to content

Commit

Permalink
Use private layer status only for QGIS 3.18+
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor committed Oct 10, 2024
1 parent 4d47d27 commit 8a10317
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 6 additions & 4 deletions tests/test_toppingmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_parse_project_with_mapthemes(self):
def test_generate_files(self):
"""
Generate projecttopping file with layertree, map themes, variables and layouts.
And all the toppingffor styles, definition and layouttemplatesiles .
And all the toppingfiles for styles, definition and layouttemplates.
"""
project, export_settings = self._make_project_and_export_settings()
layers = project.layerTreeRoot().findLayers()
Expand Down Expand Up @@ -225,8 +225,9 @@ def test_generate_files(self):
assert childnode["Layer Two"]["checked"]
if "Layer Four" in childnode:
foundLayerFour = True
assert "private" in childnode["Layer Four"]
assert childnode["Layer Four"]["private"]
if Qgis.QGIS_VERSION_INT >= 31800:
assert "private" in childnode["Layer Four"]
assert childnode["Layer Four"]["private"]
assert foundAllofEm
assert foundLayerOne
assert foundLayerTwo
Expand Down Expand Up @@ -659,7 +660,8 @@ def _make_project_and_export_settings(self):
allofemgroup.addLayer(l2)
node3 = allofemgroup.addLayer(l3)
node3.setItemVisibilityChecked(False)
l4.setFlags(l4.flags() | QgsMapLayer.Private)
if Qgis.QGIS_VERSION_INT >= 31800:
l4.setFlags(l4.flags() | QgsMapLayer.Private)
allofemgroup.addLayer(l4)
allofemgroup.addLayer(l5)

Expand Down
5 changes: 4 additions & 1 deletion toppingmaker/projecttopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ def make_item(
layer = self._layer_of_node(project, node)
self.properties.featurecount = node.customProperty("showFeatureCount")

self.properties.private = bool(layer.flags() & QgsMapLayer.Private)
if Qgis.QGIS_VERSION_INT >= 31800:
self.properties.private = bool(layer.flags() & QgsMapLayer.Private)
else:
self.properties.private = False

source_setting = export_settings.get_setting(
ExportSettings.ToppingType.SOURCE, node, node.name()
Expand Down

0 comments on commit 8a10317

Please sign in to comment.