Coverage for gws-app / gws / plugin / qfieldcloud / __init__.py: 0%

2 statements  

« prev     ^ index     » next       coverage.py v7.13.4, created at 2026-03-03 10:12 +0100

1"""QField Cloud plugin. 

2 

3This plugin emulates QField Cloud API to allow QField Mobile to synchronize with GWS. 

4The plugin packages QGIS projects based on settings made with QFieldSync QGIS plugin. 

5 

6## Configuration 

7 

8The plugin exposes an Action of type `qfieldcloud`. In the action config, you can define multiple `projects`, each representing a QField project. 

9 

10``` 

11actions+ { 

12 type "qfieldcloud" 

13  

14 projects+ { 

15 title "My Project" 

16 provider.path "/path/to/file.qgs" 

17 } 

18} 

19``` 

20 

21## Downloading data 

22 

23Data flow GWS -> QField, also called "packaging". 

24 

25In the given QGIS project, the plugin looks for Postgres layers marked as "offline editable", fetches their related data and packages them into a GeoPackage file. A modified QGIS project file is also created, pointing to the GeoPackage layers instead of the original Postgres layers. 

26 

27For each offline table, a Model can be configured to customize field selection and data filtering. Models are defined in the action configuration. By default, the plugin uses a generic Model that includes all fields and all features. 

28 

29Background maps are rendered via QGIS Server WMS requests and included in the package as raster layers. 

30 

31## Uploading data 

32 

33Data flow QField -> GWS, also called "patching". 

34 

35For each incoming "delta" package from QField, the plugin extracts the modified features and passes them to the respective Model. The Model is responsible for applying the changes to the Postgres database. 

36 

37## File uploads 

38 

39If a Model supports file uploads, it should contain a virtual file field with `pathColumn` and `contentColumn`: 

40 

41``` 

42actions+ { 

43 type "qfieldcloud" 

44 

45 projects+ { 

46 title "My Project" 

47 provider.path "/path/to/file.qgs" 

48 

49 models+ { 

50 type "postgres" 

51 ... 

52 fields+ { 

53 type "file" 

54 name "virtual_file_field" 

55 contentColumn "file_content" 

56 pathColumn "file_path" 

57 } 

58 } 

59 } 

60} 

61``` 

62 

63QField sends uploads in two steps: first, the file path is included along with the feature changes in the delta package. Later, the actual file content is uploaded in a separate request. The plugin matches the file content to the respective features based on the `pathColumn` value. 

64 

65## Extending 

66 

67Override the packager and patcher classes to customize packaging and patching behavior. 

68In your custom action class, override `get_packager()` and `get_patcher()` methods to return your custom classes. 

69 

70""" 

71 

72from . import ( 

73 action, 

74 packager, 

75 patcher, 

76 caps, 

77) 

78 

79__all__ = [ 

80 'action', 

81 'packager', 

82 'patcher', 

83 'caps', 

84]