Skip to content

Commit

Permalink
Get rid of invert logic in favor or a more flexible and more explicit…
Browse files Browse the repository at this point in the history
… behavior concept
  • Loading branch information
nirvn committed Jun 30, 2024
1 parent b17f17b commit 1fa9ec4
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions libqfieldsync/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self):
FORCE_AUTO_PUSH_INTERVAL_MINS = "/forceAutoPushIntervalMins"
GEOFENCING_ACTIVE = "/geofencingActive"
GEOFENCING_LAYER = "/geofencingLayer"
GEOFENCING_INVERT_LOGIC = "/geofencingInvertLogic"
GEOFENCING_BEHAVIOR = "/geofencingBehavior"

class BaseMapType(object):
def __init__(self):
Expand All @@ -31,6 +31,16 @@ def __init__(self):
SINGLE_LAYER = "singleLayer"
MAP_THEME = "mapTheme"

class GeofencingBehavior(object):
def __init__(self):
raise RuntimeError(
"This object holds only project property static variables"
)

ALERT_INSIDE_AREAS = 1
ALERT_OUTSIDE_AREAS = 2
INFORM_ENTER_LEAVE_AREAS = 3


class ProjectConfiguration(object):
"""
Expand Down Expand Up @@ -120,16 +130,18 @@ def geofencing_layer(self, value):
self.project.writeEntry("qfieldsync", ProjectProperties.GEOFENCING_LAYER, value)

@property
def geofencing_invert_logic(self):
geofencing_invert_logic, _ = self.project.readBoolEntry(
"qfieldsync", ProjectProperties.GEOFENCING_INVERT_LOGIC, False
def geofencing_behavior(self):
geofencing_behavior, _ = self.project.readNumEntry(
"qfieldsync",
ProjectProperties.GEOFENCING_BEHAVIOR,
ProjectProperties.GeofencingBehavior.ALERT_INSIDE_AREAS,
)
return geofencing_invert_logic
return geofencing_behavior

@geofencing_invert_logic.setter
def geofencing_invert_logic(self, value):
@geofencing_behavior.setter
def geofencing_behavior(self, value):
self.project.writeEntry(
"qfieldsync", ProjectProperties.GEOFENCING_INVERT_LOGIC, value
"qfieldsync", ProjectProperties.GEOFENCING_BEHAVIOR, value
)

@property
Expand Down

0 comments on commit 1fa9ec4

Please sign in to comment.