From 7a86a78100c6ad8a42834257f4d1b08b73263aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Thu, 24 Oct 2024 22:18:57 -0500 Subject: [PATCH 1/4] [gui] Project creation page: add combobox to select the preferred translation language --- .../workflow_wizard/project_creation_page.py | 17 +- .../ui/workflow_wizard/project_creation.ui | 182 +++++++++++------- QgisModelBaker/utils/globals.py | 7 + 3 files changed, 137 insertions(+), 69 deletions(-) diff --git a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py index 013a20e85..526939d27 100644 --- a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py +++ b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py @@ -41,7 +41,7 @@ from QgisModelBaker.libs.modelbaker.utils.globals import OptimizeStrategy from QgisModelBaker.libs.modelbaker.utils.qt_utils import make_file_selector from QgisModelBaker.utils import gui_utils -from QgisModelBaker.utils.globals import CATALOGUE_DATASETNAME +from QgisModelBaker.utils.globals import CATALOGUE_DATASETNAME, displayLanguages from QgisModelBaker.utils.gui_utils import TRANSFERFILE_MODELS_BLACKLIST, LogLevel PAGE_UI = gui_utils.get_ui_class("workflow_wizard/project_creation.ui") @@ -65,8 +65,10 @@ def __init__(self, parent, title): self.existing_projecttopping_id = None self.projecttopping_id = None + self.db_connector = None self._update_optimize_combo() + self._update_translation_combo() self.create_project_button.clicked.connect(self._create_project) self.is_complete = False @@ -115,6 +117,9 @@ def restore_configuration(self, configuration): self.configuration.inheritance = self._inheritance() self._update_optimize_combo() + # get translation languages + self._update_translation_combo() + # get existing topping self.existing_topping_checkbox.setVisible(False) self.existing_projecttopping_id = self._existing_projecttopping_id() @@ -231,6 +236,15 @@ def _update_optimize_combo(self): self.optimize_combo.addItem(self.tr("No optimization"), OptimizeStrategy.NONE) self.optimize_combo.setCurrentIndex(index) + def _update_translation_combo(self): + self.translation_combo.clear() + + if self.db_connector: + for lang in self.db_connector.get_available_languages(): + self.translation_combo.addItem(displayLanguages.get(lang, lang), lang) + + self.translation_combo.addItem(self.tr("Original model language"), "__") + def _complete_completer(self): if self.topping_line_edit.hasFocus() and self.topping_line_edit.completer(): if not self.topping_line_edit.text(): @@ -341,6 +355,7 @@ def _create_project(self): mgmt_uri=mgmt_uri, consider_basket_handling=True, optimize_strategy=self.optimize_combo.currentData(), + preferred_language=self.translation_combo.currentData(), ) generator.stdout.connect(self.workflow_wizard.log_panel.print_info) generator.new_message.connect(self.workflow_wizard.log_panel.show_message) diff --git a/QgisModelBaker/ui/workflow_wizard/project_creation.ui b/QgisModelBaker/ui/workflow_wizard/project_creation.ui index 4478ecc5f..93a476bed 100644 --- a/QgisModelBaker/ui/workflow_wizard/project_creation.ui +++ b/QgisModelBaker/ui/workflow_wizard/project_creation.ui @@ -14,7 +14,7 @@ Select Files - + Qt::Horizontal @@ -27,6 +27,97 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Generate a QGIS Project from an existing database. + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + + + + + + 0 + 0 + + + + <html><head/><body><p>If you don't get it - nevermind and keep the default. If it's not like expected - try again with 'No optimization'...</p></body></html> + + + Project optimization strategy concerning inheritances + + + + + + + + 0 + 0 + + + + <html><head/><body><p><span style=" font-weight:600;">Hide unused base class layers:</span></p><p>- Base class layers with same named extensions will be <span style=" font-style:italic;">hidden</span> and and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will <span style=" font-style:italic;">not</span> be <span style=" font-style:italic;">hidden</span> but <span style=" font-style:italic;">renamed</span>.</p><p>- Relations of hidden layers will <span style=" font-style:italic;">not</span> be <span style=" font-style:italic;">created</span> and with them <span style=" font-style:italic;">no</span> widgets<br/></p><p><span style=" font-weight:600;">Group unused base class layers:</span></p><p>- Base class layers with same named extensions will be <span style=" font-style:italic;">collected in a group</span> and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will <span style=" font-style:italic;">not</span> be <span style=" font-style:italic;">grouped</span> but <span style=" font-style:italic;">renamed</span>.</p><p>- Relations of grouped layers will be <span style=" font-style:italic;">created</span> but the widgets <span style=" font-style:italic;">not applied</span> to the form.</p></body></html> + + + + Hide unused base class layers + + + + + Group unused base class layers + + + + + No optimization + + + + + + + @@ -92,97 +183,59 @@ - - - - - 0 - 0 - - - - - 75 - true - - - - Generate a QGIS Project from an existing database. - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - + 0 - - + + + + Generate + + + + + - + - - - - 0 - 0 - - - - <html><head/><body><p>If you don't get it - nevermind and keep the default. If it's not like expected - try again with 'No optimization'...</p></body></html> - + - Project optimization strategy concerning inheritances + Preferred language for database objects like tables and fields - + 0 0 - - <html><head/><body><p><span style=" font-weight:600;">Hide unused base class layers:</span></p><p>- Base class layers with same named extensions will be <span style=" font-style:italic;">hidden</span> and and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will <span style=" font-style:italic;">not</span> be <span style=" font-style:italic;">hidden</span> but <span style=" font-style:italic;">renamed</span>.</p><p>- Relations of hidden layers will <span style=" font-style:italic;">not</span> be <span style=" font-style:italic;">created</span> and with them <span style=" font-style:italic;">no</span> widgets<br/></p><p><span style=" font-weight:600;">Group unused base class layers:</span></p><p>- Base class layers with same named extensions will be <span style=" font-style:italic;">collected in a group</span> and base class layers with multiple extensions as well. Except if the extension is in the same model, then it's will <span style=" font-style:italic;">not</span> be <span style=" font-style:italic;">grouped</span> but <span style=" font-style:italic;">renamed</span>.</p><p>- Relations of grouped layers will be <span style=" font-style:italic;">created</span> but the widgets <span style=" font-style:italic;">not applied</span> to the form.</p></body></html> - - Hide unused base class layers + English - Group unused base class layers + French - No optimization + German + + + + + Italian @@ -190,13 +243,6 @@ - - - - Generate - - - diff --git a/QgisModelBaker/utils/globals.py b/QgisModelBaker/utils/globals.py index ab5255a22..edf4ad1a4 100644 --- a/QgisModelBaker/utils/globals.py +++ b/QgisModelBaker/utils/globals.py @@ -45,6 +45,13 @@ ), } +displayLanguages = { + "en": QCoreApplication.translate("QgisModelBaker", "English"), + "de": QCoreApplication.translate("QgisModelBaker", "German"), + "fr": QCoreApplication.translate("QgisModelBaker", "French"), + "it": QCoreApplication.translate("QgisModelBaker", "Italian"), +} + class AdministrativeDBActionTypes(Enum): """Defines constants for modelbaker actions that require superuser login""" From 7aa03b1a8f77a4ed0aaa3d25aac21fbd1fb2f965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 29 Oct 2024 22:38:50 -0500 Subject: [PATCH 2/4] [wizard] Address review: Add tooltip for translation label in Project creation page --- QgisModelBaker/ui/workflow_wizard/project_creation.ui | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/QgisModelBaker/ui/workflow_wizard/project_creation.ui b/QgisModelBaker/ui/workflow_wizard/project_creation.ui index 93a476bed..70bec618a 100644 --- a/QgisModelBaker/ui/workflow_wizard/project_creation.ui +++ b/QgisModelBaker/ui/workflow_wizard/project_creation.ui @@ -205,6 +205,10 @@ + + Several translations of the INTERLIS model are implemented in the database schema (TRANSLATION OF). +Select the language in which the QGIS project is to be set up. + Preferred language for database objects like tables and fields From be01c6a82362fa2884be2780ac8cb50c4b93426d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Carrillo?= Date: Tue, 29 Oct 2024 23:16:53 -0500 Subject: [PATCH 3/4] Address review: Make sure the language combobox has the same width as the project optimization combobox (project creation page) --- QgisModelBaker/gui/workflow_wizard/project_creation_page.py | 3 +++ QgisModelBaker/ui/workflow_wizard/project_creation.ui | 3 +++ 2 files changed, 6 insertions(+) diff --git a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py index 526939d27..277181e84 100644 --- a/QgisModelBaker/gui/workflow_wizard/project_creation_page.py +++ b/QgisModelBaker/gui/workflow_wizard/project_creation_page.py @@ -245,6 +245,9 @@ def _update_translation_combo(self): self.translation_combo.addItem(self.tr("Original model language"), "__") + # Synchronize length of both comboboxes + self.translation_combo.setMinimumSize(self.optimize_combo.minimumSizeHint()) + def _complete_completer(self): if self.topping_line_edit.hasFocus() and self.topping_line_edit.completer(): if not self.topping_line_edit.text(): diff --git a/QgisModelBaker/ui/workflow_wizard/project_creation.ui b/QgisModelBaker/ui/workflow_wizard/project_creation.ui index 70bec618a..595544cf8 100644 --- a/QgisModelBaker/ui/workflow_wizard/project_creation.ui +++ b/QgisModelBaker/ui/workflow_wizard/project_creation.ui @@ -222,6 +222,9 @@ Select the language in which the QGIS project is to be set up. 0 + + QComboBox::AdjustToContents + English From 1a6cf63b6011aa96998207da32ef412be1805263 Mon Sep 17 00:00:00 2001 From: signedav Date: Mon, 4 Nov 2024 14:47:30 +0100 Subject: [PATCH 4/4] bump model baker lib to 1.9.0 --- scripts/package_pip_packages.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/package_pip_packages.sh b/scripts/package_pip_packages.sh index b928128f1..924cceacc 100755 --- a/scripts/package_pip_packages.sh +++ b/scripts/package_pip_packages.sh @@ -1,7 +1,7 @@ #!/bin/bash LIBS_DIR="QgisModelBaker/libs" -MODELBAKER_LIBRARY=("modelbaker" "1.8.1") +MODELBAKER_LIBRARY=("modelbaker" "1.9.0") PACKAGING=("packaging" "21.3") PACKAGES=(