def enableAutomaticCacheReloading(): """ Enable automatic reloading of our geolocator caches. We set the internal app settings to re-enable the reloading of the geolocator cache when a signal is received. If a signal was received while the automatic reloading was disabled, we process that signal again to reload the appropriate cache. """ # Get the current XXX_did_change settings, so we know what's changed while # the automatic reloading was disabled. location_did_change = appSettings.get("location_did_change") == "1" location_name_did_change = \ appSettings.get("location_name_did_change") == "1" name_did_change = appSettings.get("name_did_change") == "1" outline_did_change = appSettings.get("outline_did_change") == "1" # Turn on automatic reloading again. appSettings.set("geolocator_cache_reload_enabled", "1") # If things have changed while reloading was disabled, reload the affected # cache(s). if location_did_change: on_location_changed() if location_name_did_change: on_location_name_changed() if name_did_change: on_name_changed() if outline_did_change: on_outline_changed()
def on_outline_changed(**kwargs): """ Respond to an outline_changed signal being received. """ if isAutomaticCacheReloadingEnabled(): resultsCache.dataChanged() else: appSettings.set("outline_did_change", "1")
def on_location_name_changed(**kwargs): """ Respond to a location_name_changed signal being received. """ if isAutomaticCacheReloadingEnabled(): locationNameCache.locationNameChanged() resultsCache.dataChanged() else: appSettings.set("location_name_did_change", "1")
def disableAutomaticCacheReloading(): """ Disable automatic reloading of our geolocator caches. We set various internal app settings to keep track of what's changed whle the cache reloading is disabled. This allows us to reload the appropriate caches when reloading is turned on again. """ appSettings.set("geolocator_cache_reload_enabled", "0") appSettings.set("location_did_change", "0") appSettings.set("location_name_did_change", "0") appSettings.set("name_did_change", "0") appSettings.set("outline_did_change", "0")