Skip to contents

Drop themes by name, or keep only the ones named. The counterpart to rfp_qgs_theme_set(), and what curating a project's theme list needed before this existed — the alternative was reaching into an unexported internal, or QGIS Desktop.

Usage

rfp_qgs_theme_rm(path, themes = NULL, keep = NULL, backup = TRUE)

Arguments

path

Character. Path to the .qgs.

themes

Character. Theme names to remove.

keep

Character. Theme names to keep; every other theme is removed.

backup

Logical. Write <path>.bak before mutating. Default TRUE.

Value

Invisibly, the character vector of theme names remaining.

Details

Give exactly one of themes or keep. A name in neither is an error rather than a silent no-op: theme_rm(p, "Low detail") against a project holding "Low Detail" would otherwise report success and change nothing.

Examples

src <- system.file("templates", "bcrestoration_mobile.qgs", package = "rfp")
p <- file.path(tempdir(), "trimmed.qgs")
file.copy(src, p, overwrite = TRUE)
#> [1] TRUE

rfp_qgs_theme_names(p)
#> [1] "High Detail - Crossings"       "Land Tenure"                  
#> [3] "Low Detail - Bull Trout Model" "Low Detail - Salmon Model"    
#> [5] "Low Detail - Steelhead Model" 
rfp_qgs_theme_rm(p, keep = "Land Tenure", backup = FALSE)
#>  Removed 4 themes from /tmp/RtmpfSNDuG/trimmed.qgs; 1 remains.