Coverage for gws-app/gws/plugin/qfieldcloud/core.py: 100%

24 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""QField project configuration and object.""" 

2 

3from typing import Optional 

4import gws 

5import gws.plugin.qgis.provider 

6 

7 

8class ProjectConfig(gws.ConfigWithAccess): 

9 """Project offered to QField, packaged from a QGIS project.""" 

10 

11 title: str = '' 

12 """Project title shown in QField.""" 

13 provider: gws.plugin.qgis.provider.Config 

14 """QGIS project the QField package is built from.""" 

15 models: Optional[list[gws.ext.config.model]] 

16 """Data models for editable layers, matched by table name.""" 

17 mapCacheLifeTime: gws.Duration = '0' 

18 """How long rendered offline base maps are reused.""" 

19 thumbnail: Optional[gws.FilePath] 

20 """Thumbnail image shown in the project details. (added in 8.5)""" 

21 

22 

23class QfcProject(gws.Node): 

24 """Project offered to QField. 

25 

26 Holds the QGIS provider of the source project, the models for editable 

27 layers and the base map settings used when the project is packaged. 

28 """ 

29 

30 title: str 

31 """Project title, the uid if no title is configured.""" 

32 qgisProvider: gws.plugin.qgis.provider.Object 

33 """QGIS provider for the source project.""" 

34 models: list[gws.DatabaseModel] 

35 """Configured models for editable layers.""" 

36 mapCacheLifeTime: int 

37 """How long rendered base maps are reused, in seconds. ``0`` disables the cache.""" 

38 thumbnail: str 

39 """Path to the thumbnail image, or an empty string.""" 

40 

41 def configure(self): 

42 self.title = self.cfg('title', '') or self.uid 

43 self.qgisProvider = self.create_child(gws.plugin.qgis.provider.Object, self.cfg('provider')) 

44 self.root.app.register_supported_crs(self.qgisProvider.forceCrs) 

45 self.models = self.create_children(gws.ext.object.model, self.cfg('models')) 

46 self.mapCacheLifeTime = self.cfg('mapCacheLifeTime') or 0 

47 self.thumbnail = self.cfg('thumbnail') or '' 

48 

49