Skip to content

Commit

Permalink
Add a project settting to keep track of map themes' default active layer
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jul 21, 2024
1 parent 528345d commit 60a1aba
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libqfieldsync/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(self):
GEOFENCING_LAYER = "/geofencingLayer"
GEOFENCING_BEHAVIOR = "/geofencingBehavior"
GEOFENCING_SHOULD_PREVENT_DIGITIZING = "/geofencingShouldPreventDigitizing"
MAP_THEMES_ACTIVE_LAYER = "/mapThemesActiveLayers"

class BaseMapType(object):
def __init__(self):
Expand Down Expand Up @@ -158,6 +159,29 @@ def geofencing_should_prevent_digitizing(self, value):
"qfieldsync", ProjectProperties.GEOFENCING_SHOULD_PREVENT_DIGITIZING, value
)

@property
def map_themes_active_layer(self):
entries, _ = self.project.readListEntry(
"qfieldsync", ProjectProperties.MAP_THEMES_ACTIVE_LAYER
)

map_themes_active_layer = {}
for entry in entries:
details = entry.split("}|~~|{")
if len(details) == 2:
map_themes_active_layer[details[0]] = details[1]

return map_themes_active_layer

@map_themes_active_layer.setter
def map_themes_active_layer(self, value):
entries = []
for key in value:
entries.append(f"{key}}}|~~|{{{value[key]}")
self.project.writeEntry(
"qfieldsync", ProjectProperties.MAP_THEMES_ACTIVE_LAYER, entries
)

@property
def geofencing_is_active(self):
geofencing_is_active, _ = self.project.readBoolEntry(
Expand Down

0 comments on commit 60a1aba

Please sign in to comment.