A map theme (QGIS calls the stored form a visibility preset) records which
layers are visible, and which layer-tree groups are checked and expanded.
This returns both, in the shape rfp_qgs_theme_set() accepts - so reading
from one project and setting into another is how a theme is ported, with no
intermediate file.
Value
A list of four data frames:
layers-theme,layer,visible,expanded,stylegroups-theme,group_path,state("checked"/"expanded")themes- one row per theme:expanded_info,group_attr,group_info,single_root. Carries what the writer needs to reproduce a theme faithfully, in particular whether QGIS should APPLY its group and expansion state or ignore it. Pass the whole list torfp_qgs_theme_set()- a theme missing from here is written as a new one, with its group state inferred from where its layers sit.legend-theme,layer,node,state: per-class legend visibility and expansion, i.e. which categories or rules of a layer the theme turns on.nodeids are opaque (integers for categorized renderers,{uuid}for rule-based). Acheckedrow withnode = NArecords a block that is present but empty - meaning no class is checked, which is not the same as the layer having no block at all.
A theme with no layers still appears in groups, and in
rfp_qgs_theme_names(), so it can still be removed or kept by name.
Details
Layers are identified by name, not by the project-local id they are
stored under, because a name is the only thing meaningful in another project.
Groups are identified by their /-joined tree path.
See also
Other qgs:
rfp_qgs_form_add(),
rfp_qgs_layer_rm(),
rfp_qgs_preview_set(),
rfp_qgs_raster_add(),
rfp_qgs_service_add(),
rfp_qgs_service_rm(),
rfp_qgs_services(),
rfp_qgs_style_export(),
rfp_qgs_style_set(),
rfp_qgs_subset_get(),
rfp_qgs_subset_set(),
rfp_qgs_theme_add(),
rfp_qgs_theme_lookup(),
rfp_qgs_theme_names(),
rfp_qgs_theme_rm(),
rfp_qgs_theme_set(),
rfp_qgs_theme_unbury(),
rfp_qgs_vector_add(),
rfp_qwc_config_create(),
rfp_raster_style_path(),
rfp_raster_styles()
Examples
path <- system.file("testdata", "test_themes.qgs", package = "rfp")
themes <- rfp_qgs_themes(path)
themes$layers
#> theme layer visible expanded style
#> 1 Theme One Layer A TRUE TRUE default
#> 2 Theme One Layer B TRUE FALSE default
#> 3 Theme Two Layer A FALSE TRUE default
#> 4 Theme Two Layer C TRUE TRUE default
themes$groups
#> theme group_path state
#> 1 Theme One root checked
#> 2 Theme One root/group1 checked
#> 3 Theme One root/group1 expanded
