Skip to content

Commit

Permalink
Merge pull request #241 from gbd-consult/bug/240_make_form_code_optional
Browse files Browse the repository at this point in the history
Bug/240 make form code optional
  • Loading branch information
Guts authored Oct 17, 2022
2 parents 79c2ba8 + 0d4940f commit f40f85f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions gml_application_schema_toolbox/core/load_gmlas_in_qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
1 change: 1 addition & 0 deletions gml_application_schema_toolbox/gui/import_gmlas_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down
9 changes: 8 additions & 1 deletion gml_application_schema_toolbox/ui/import_gmlas_panel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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;">
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Edit or create custom configuration files based on &lt;/span&gt;&lt;a href=&quot;https://github.com/OSGeo/gdal/blob/master/gdal/data/gmlasconf.xsd&quot;&gt;&lt;span style=&quot; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;GMLAS config file schema&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt; for more advanced options.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:8pt;&quot;&gt;Edit or create custom configuration files based on &lt;/span&gt;&lt;a href=&quot;https://github.com/OSGeo/gdal/blob/master/gdal/data/gmlasconf.xsd&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;GMLAS config file schema&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:8pt;&quot;&gt; for more advanced options.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
Expand Down Expand Up @@ -278,6 +278,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="addCodeToForm">
<property name="text">
<string>Add custom code to layer forms</string>
</property>
</widget>
</item>
<item>
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
Expand Down
2 changes: 1 addition & 1 deletion tests/qgis/test_load_in_qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Expand Down

0 comments on commit f40f85f

Please sign in to comment.