From cfa909b488e9df3b9296fdc2e298b44c84d52ffe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Wed, 9 Oct 2024 21:02:46 -0500 Subject: [PATCH] Add support for private layers in tree view --- modelbaker/dataobjects/layers.py | 1 + modelbaker/dataobjects/legend.py | 3 +++ modelbaker/generator/generator.py | 1 + 3 files changed, 5 insertions(+) diff --git a/modelbaker/dataobjects/layers.py b/modelbaker/dataobjects/layers.py index 27c4197..81266e6 100644 --- a/modelbaker/dataobjects/layers.py +++ b/modelbaker/dataobjects/layers.py @@ -121,6 +121,7 @@ def __init__( self.expanded = True self.checked = True self.featurecount = False + self.private = False def dump(self) -> dict: definition = dict() diff --git a/modelbaker/dataobjects/legend.py b/modelbaker/dataobjects/legend.py index f60a93e..c151fd5 100644 --- a/modelbaker/dataobjects/legend.py +++ b/modelbaker/dataobjects/legend.py @@ -24,6 +24,7 @@ QgsLayerDefinition, QgsLayerTreeGroup, QgsLayerTreeLayer, + QgsMapLayer, QgsProject, ) @@ -124,6 +125,8 @@ def create( layernode.setExpanded(item.expanded) layernode.setItemVisibilityChecked(item.checked) layernode.setCustomProperty("showFeatureCount", item.featurecount) + if item.private: + layer.setFlags(layer.flags() | QgsMapLayer.Private) group.insertChildNode(index, layernode) static_index += 1 diff --git a/modelbaker/generator/generator.py b/modelbaker/generator/generator.py index ba9a227..044be24 100644 --- a/modelbaker/generator/generator.py +++ b/modelbaker/generator/generator.py @@ -668,6 +668,7 @@ def full_node(self, layers, item, path_resolver=lambda path: path): current_node.expanded = item_properties.get("expanded", True) current_node.checked = item_properties.get("checked", True) current_node.featurecount = item_properties.get("featurecount", False) + current_node.private = item_properties.get("private", False) if "uri" in item_properties: current_node.uri = item_properties.get("uri") if "provider" in item_properties: