From a99e3e205b417a15cdeb574d95c2153c47a3fa50 Mon Sep 17 00:00:00 2001
From: towa <7078986+towa@users.noreply.github.com>
Date: Tue, 27 Sep 2022 10:34:08 +0200
Subject: [PATCH 1/4] make adding code to forms optional
---
.../core/load_gmlas_in_qgis.py | 6 ++++--
.../gui/import_gmlas_panel.py | 1 +
.../ui/import_gmlas_panel.ui | 15 +++++++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
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 9d921346..285ca778 100644
--- a/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
+++ b/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
@@ -99,7 +99,8 @@ 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
@@ -389,4 +390,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 fd827955..753239e9 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 f9179c68..8de07925 100644
--- a/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
+++ b/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
@@ -48,8 +48,8 @@
0
0
- 677
- 773
+ 663
+ 825
@@ -195,8 +195,8 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<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>
+</style></head><body style=" font-family:'Cantarell'; 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-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
+
+
+
-
From 6e242a7cc24dd403bf67d6dea57105416d643195 Mon Sep 17 00:00:00 2001
From: towa <7078986+towa@users.noreply.github.com>
Date: Tue, 27 Sep 2022 10:44:36 +0200
Subject: [PATCH 2/4] small fixes
---
gml_application_schema_toolbox/core/load_gmlas_in_qgis.py | 5 +++--
gml_application_schema_toolbox/ui/import_gmlas_panel.ui | 6 +++---
2 files changed, 6 insertions(+), 5 deletions(-)
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 285ca778..7f09e317 100644
--- a/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
+++ b/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
@@ -99,8 +99,9 @@ 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,
- add_form_code: bool, 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
diff --git a/gml_application_schema_toolbox/ui/import_gmlas_panel.ui b/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
index 8de07925..faf85ab0 100644
--- a/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
+++ b/gml_application_schema_toolbox/ui/import_gmlas_panel.ui
@@ -48,8 +48,8 @@
0
0
- 663
- 825
+ 677
+ 773
@@ -195,7 +195,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
-</style></head><body style=" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;">
+</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-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>
From 4a9e1f1359650c9f30fa6d3d6a2959e3279cbf0a Mon Sep 17 00:00:00 2001
From: towa <7078986+towa@users.noreply.github.com>
Date: Tue, 27 Sep 2022 12:28:08 +0200
Subject: [PATCH 3/4] fix tests
---
tests/qgis/test_load_in_qgis.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/qgis/test_load_in_qgis.py b/tests/qgis/test_load_in_qgis.py
index 4a21cdf4..8e3ba590 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()):
From 0d4940f5eb7208d1d942fd7bdc1a33fe70396992 Mon Sep 17 00:00:00 2001
From: towa <7078986+towa@users.noreply.github.com>
Date: Mon, 17 Oct 2022 09:01:26 +0200
Subject: [PATCH 4/4] add doc string
---
gml_application_schema_toolbox/core/load_gmlas_in_qgis.py | 1 +
1 file changed, 1 insertion(+)
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 e1db3387..2416fd27 100644
--- a/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
+++ b/gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
@@ -106,6 +106,7 @@ def import_in_qgis(
@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(