diff --git a/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py b/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
index a27d040..2416fd2 100644
--- a/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
+++ b/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
@@ -99,11 +99,14 @@ def createLayerTreeModelLegendNodes(self, layer_tree_layer):
return [QgsSimpleLegendNode(layer_tree_layer, self.text, self.icon, self)]
-def import_in_qgis(gmlas_uri: str, provider: str, schema: Union[str, None] = None):
+def import_in_qgis(
+ gmlas_uri: str, provider: str, add_form_code: bool, schema: Union[str, None] = None
+):
"""Imports layers from a GMLAS file in QGIS with relations and editor widgets
@param gmlas_uri connection parameters
@param provider name of the QGIS provider that handles gmlas_uri parameters
+ @param add_form_code set this to true to load the custom form code
@param schema name of the PostgreSQL schema where tables and metadata tables are
"""
PlgLogger.log(
@@ -391,4 +394,5 @@ def import_in_qgis(gmlas_uri: str, provider: str, schema: Union[str, None] = Non
couche.setEditFormConfig(fc)
- install_viewer_on_feature_form(couche)
+ if add_form_code:
+ install_viewer_on_feature_form(couche)
diff --git a/gml_application_schema_toolbox/gui/import_gmlas_panel.py b/gml_application_schema_toolbox/gui/import_gmlas_panel.py
index fd82795..753239e 100644
--- a/gml_application_schema_toolbox/gui/import_gmlas_panel.py
+++ b/gml_application_schema_toolbox/gui/import_gmlas_panel.py
@@ -406,6 +406,7 @@ def error_handler(err, err_no, msg):
import_in_qgis(
gmlas_uri=dest_db_name,
provider=provider,
+ add_form_code=self.addCodeToForm.isChecked(),
schema=schema,
)
diff --git a/gml_application_schema_toolbox/ui/import_gmlas_panel.ui b/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
index f9179c6..faf85ab 100644
--- a/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
+++ b/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
@@ -196,7 +196,7 @@
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Edit or create custom configuration files based on </span><a href="https://github.com/OSGeo/gdal/blob/master/gdal/data/gmlasconf.xsd"><span style=" font-size:8pt; text-decoration: underline; color:#0000ff;">GMLAS config file schema</span></a><span style=" font-size:8pt;"> for more advanced options.</span></p></body></html>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:8pt;">Edit or create custom configuration files based on </span><a href="https://github.com/OSGeo/gdal/blob/master/gdal/data/gmlasconf.xsd"><span style=" font-family:'Ubuntu'; font-size:8pt; text-decoration: underline; color:#0000ff;">GMLAS config file schema</span></a><span style=" font-family:'Ubuntu'; font-size:8pt;"> for more advanced options.</span></p></body></html>
true
@@ -278,6 +278,13 @@ p, li { white-space: pre-wrap; }
+ -
+
+
+ Add custom code to layer forms
+
+
+
-
diff --git a/tests/qgis/test_load_in_qgis.py b/tests/qgis/test_load_in_qgis.py
index 4a21cdf..8e3ba59 100644
--- a/tests/qgis/test_load_in_qgis.py
+++ b/tests/qgis/test_load_in_qgis.py
@@ -79,7 +79,7 @@ def convert_and_import(self, xml_file):
# fix geometry types
ds = None
# populate the qgis project
- import_in_qgis(gmlas_uri=out_file, provider="SQLite")
+ import_in_qgis(gmlas_uri=out_file, provider="SQLite", add_form_code=True)
layers = []
for lid in sorted(QgsProject.instance().mapLayers().keys()):