diff --git a/QgisModelBaker/gui/topping_wizard/models_page.py b/QgisModelBaker/gui/topping_wizard/models_page.py
index 29433bff8..e16363224 100644
--- a/QgisModelBaker/gui/topping_wizard/models_page.py
+++ b/QgisModelBaker/gui/topping_wizard/models_page.py
@@ -67,21 +67,27 @@ def validatePage(self) -> bool:
self.tr("No models set."),
gui_utils.LogColor.COLOR_SUCCESS,
)
+ self.topping_wizard.topping.preferred_datasource = (
+ self.source_combobox.currentData()
+ )
return super().validatePage()
def _refresh(self):
- self._load_available_models()
+ self._load_available_models_and_sources()
self.models_model.check_entries(self.topping_wizard.topping.models)
- def _load_available_models(self):
+ def _load_available_models_and_sources(self):
"""
Collects all the available sources in the project and makes the models_model to refresh accordingly.
"""
checked_identificators = []
db_connectors = []
+ sources = set()
+
for layer in QgsProject.instance().mapLayers().values():
if layer.type() == QgsMapLayer.VectorLayer:
source_provider = layer.dataProvider()
+ self._append_possible_sources(sources, source_provider)
schema_identificator = (
db_utils.get_schema_identificator_from_sourceprovider(
source_provider
@@ -101,3 +107,32 @@ def _load_available_models(self):
if db_connector:
db_connectors.append(db_connector)
self.models_model.refresh_model(db_connectors)
+
+ self._refresh_source_combobox(sources)
+
+ def _append_possible_sources(self, sources, provider):
+ if provider.name() == "postgres":
+ sources.add("pg")
+ elif provider.name() == "mssql":
+ sources.add("mssql")
+ elif provider.name() == "ogr" and provider.storageType() == "GPKG":
+ sources.add("gpkg")
+
+ def _refresh_source_combobox(self, sources):
+ display_map = {"pg": "PostGIS", "gpkg": "GeoPackage", "mssql": "MSSQL"}
+
+ self.source_combobox.clear()
+ for source in list(sources):
+ self.source_combobox.addItem(display_map[source], source)
+
+ none_text = self.tr("No source defined (allow all)")
+
+ self.source_combobox.addItem(none_text, None)
+
+ if len(sources) == 1:
+ # it's clear which one we take
+ self.source_combobox.setCurrentText(display_map[list(sources)[0]])
+ else:
+ # no sources or it's not clear which one
+ self.source_combobox.setCurrentText(none_text)
+ self.source_combobox.setEnabled(bool(sources))
diff --git a/QgisModelBaker/gui/topping_wizard/referencedata_page.py b/QgisModelBaker/gui/topping_wizard/referencedata_page.py
index 58b2a7f6a..0546cda20 100644
--- a/QgisModelBaker/gui/topping_wizard/referencedata_page.py
+++ b/QgisModelBaker/gui/topping_wizard/referencedata_page.py
@@ -27,8 +27,8 @@
import QgisModelBaker.utils.gui_utils as gui_utils
from QgisModelBaker.libs.modelbaker.iliwrapper.ilicache import (
IliDataCache,
+ IliDataFileCompleterDelegate,
IliDataItemModel,
- MetaConfigCompleterDelegate,
)
from QgisModelBaker.libs.modelbaker.utils.qt_utils import (
FileValidator,
@@ -76,7 +76,7 @@ def __init__(self, parent, title):
self.topping_wizard.log_panel.show_message
)
- self.ilireferencedata_delegate = MetaConfigCompleterDelegate()
+ self.ilireferencedata_delegate = IliDataFileCompleterDelegate()
self.input_line_edit.setPlaceholderText(
self.tr("[Search referenced data files from Repositories or Local System]")
)
diff --git a/QgisModelBaker/gui/topping_wizard/topping_wizard.py b/QgisModelBaker/gui/topping_wizard/topping_wizard.py
index 2cc5fabf3..cfe3a0532 100644
--- a/QgisModelBaker/gui/topping_wizard/topping_wizard.py
+++ b/QgisModelBaker/gui/topping_wizard/topping_wizard.py
@@ -101,7 +101,7 @@ def _current_page_title(self, id):
if id == ToppingWizardPageIds.Target:
return self.tr("Target Folder Selection")
elif id == ToppingWizardPageIds.Models:
- return self.tr("Model Selection")
+ return self.tr("Model and Source Selection")
elif id == ToppingWizardPageIds.Layers:
return self.tr("Layer Configuration")
elif id == ToppingWizardPageIds.Additives:
diff --git a/QgisModelBaker/gui/workflow_wizard/import_data_configuration_page.py b/QgisModelBaker/gui/workflow_wizard/import_data_configuration_page.py
index cbfe1b882..763941503 100644
--- a/QgisModelBaker/gui/workflow_wizard/import_data_configuration_page.py
+++ b/QgisModelBaker/gui/workflow_wizard/import_data_configuration_page.py
@@ -36,8 +36,8 @@
import QgisModelBaker.utils.gui_utils as gui_utils
from QgisModelBaker.gui.dataset_manager import DatasetManagerDialog
from QgisModelBaker.libs.modelbaker.iliwrapper.ilicache import (
+ IliDataFileCompleterDelegate,
IliDataItemModel,
- MetaConfigCompleterDelegate,
)
from QgisModelBaker.utils.globals import CATALOGUE_DATASETNAME, DEFAULT_DATASETNAME
from QgisModelBaker.utils.gui_utils import CheckDelegate, LogColor
@@ -118,7 +118,7 @@ def __init__(self, parent, title):
self.workflow_wizard.ilireferencedatacache.file_download_failed.connect(
self._on_referencedata_failed
)
- self.ilireferencedata_delegate = MetaConfigCompleterDelegate()
+ self.ilireferencedata_delegate = IliDataFileCompleterDelegate()
self.ilireferencedata_line_edit.setPlaceholderText(
self.tr("[Search referenced data files from UsabILIty Hub]")
)
diff --git a/QgisModelBaker/gui/workflow_wizard/import_schema_configuration_page.py b/QgisModelBaker/gui/workflow_wizard/import_schema_configuration_page.py
index 74a86c940..8d0eb1a43 100644
--- a/QgisModelBaker/gui/workflow_wizard/import_schema_configuration_page.py
+++ b/QgisModelBaker/gui/workflow_wizard/import_schema_configuration_page.py
@@ -27,10 +27,11 @@
from qgis.PyQt.QtWidgets import QCompleter, QWizardPage
from QgisModelBaker.gui.ili2db_options import Ili2dbOptionsDialog
+from QgisModelBaker.libs.modelbaker.iliwrapper.globals import DbIliMode
from QgisModelBaker.libs.modelbaker.iliwrapper.ilicache import (
IliDataCache,
+ IliDataFileCompleterDelegate,
IliDataItemModel,
- MetaConfigCompleterDelegate,
)
from QgisModelBaker.utils import gui_utils
from QgisModelBaker.utils.globals import CRS_PATTERNS
@@ -71,7 +72,7 @@ def __init__(self, parent, title):
self.ilimetaconfigcache = IliDataCache(
self.workflow_wizard.import_schema_configuration.base_configuration
)
- self.metaconfig_delegate = MetaConfigCompleterDelegate()
+ self.metaconfig_delegate = IliDataFileCompleterDelegate()
self.metaconfig = configparser.ConfigParser()
self.current_models = []
self.current_metaconfig_id = None
@@ -158,8 +159,6 @@ def _update_models_dependent_info(self):
- Calls update of ilireferencedata cache to load referenced
"""
model_list = self.model_list_view.model().checked_models()
- if set(model_list) == set(self.current_models):
- return
self.current_models = model_list
for pattern, crs in CRS_PATTERNS.items():
if re.search(pattern, ", ".join(model_list)):
@@ -173,6 +172,11 @@ def _update_ilimetaconfigcache(self):
self.ilimetaconfigcache = IliDataCache(
self.workflow_wizard.import_schema_configuration.base_configuration,
models=";".join(self.model_list_view.model().checked_models()),
+ datasources=["pg"]
+ if (self.workflow_wizard.import_schema_configuration.tool & DbIliMode.pg)
+ else ["gpkg"]
+ if (self.workflow_wizard.import_schema_configuration.tool & DbIliMode.gpkg)
+ else None,
)
self.ilimetaconfigcache.file_download_succeeded.connect(
lambda dataset_id, path: self._on_metaconfig_received(path)
diff --git a/QgisModelBaker/gui/workflow_wizard/import_source_selection_page.py b/QgisModelBaker/gui/workflow_wizard/import_source_selection_page.py
index fb82ee0ac..3b670bd9d 100644
--- a/QgisModelBaker/gui/workflow_wizard/import_source_selection_page.py
+++ b/QgisModelBaker/gui/workflow_wizard/import_source_selection_page.py
@@ -75,20 +75,19 @@ def __init__(self, parent, title):
self.workflow_wizard.import_schema_configuration.base_configuration
)
self.model_delegate = ModelCompleterDelegate()
- self._refresh_ili_models_cache()
self.input_line_edit.setPlaceholderText(
self.tr("[Browse for file or search model from repository]")
)
# very unhappy about this behavior, but okay for prototype
- self.first_time_punched = False
- self.input_line_edit.punched.connect(self._first_time_punch)
+ self.input_line_edit.textChanged.connect(self._complete_models_completer)
+ self.input_line_edit.punched.connect(self._complete_models_completer)
self.source_list_view.setModel(self.workflow_wizard.source_model)
self.add_button.clicked.connect(self._add_row)
self.remove_button.clicked.connect(self._remove_selected_rows)
- self.add_button.setEnabled(self._valid_source())
+ self.add_button.setEnabled(False)
self.input_line_edit.textChanged.connect(
lambda: self.add_button.setEnabled(self._valid_source())
)
@@ -106,24 +105,10 @@ def __init__(self, parent, title):
self.clear_cache_button.clicked.connect(self._clear_cache_button_clicked)
def nextId(self):
- self._disconnect_punch_slots()
return self.workflow_wizard.next_id()
- def _first_time_punch(self):
- # might be nicer
- self.input_line_edit.punched.disconnect(self._first_time_punch)
- self.input_line_edit.textChanged.emit(self.input_line_edit.text())
- self.input_line_edit.textChanged.connect(self._complete_models_completer)
- self.input_line_edit.punched.connect(self._complete_models_completer)
- self.first_time_punched = True
-
- def _disconnect_punch_slots(self):
- # might be nicer
- if self.first_time_punched:
- self.input_line_edit.textChanged.disconnect(self._complete_models_completer)
- self.input_line_edit.punched.disconnect(self._complete_models_completer)
- self.input_line_edit.punched.connect(self._first_time_punch)
- self.first_time_punched = False
+ def initializePage(self) -> None:
+ self._refresh_ili_models_cache()
def _refresh_ili_models_cache(self):
self.ilicache.new_message.connect(self.workflow_wizard.log_panel.show_message)
diff --git a/QgisModelBaker/ui/topping_wizard/models.ui b/QgisModelBaker/ui/topping_wizard/models.ui
index 50c2263ba..d7739d539 100644
--- a/QgisModelBaker/ui/topping_wizard/models.ui
+++ b/QgisModelBaker/ui/topping_wizard/models.ui
@@ -14,6 +14,19 @@
Select Files
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 693
+ 20
+
+
+
+
-
@@ -28,8 +41,11 @@
true
+
+ <html><head/><body><p><span style=" font-weight:600;">Select the type for which this topping should be made or specify none (allow all). This value will be written into the categories and the toppings will be filtered accordingly.</span></p></body></html>
+
- Select the Models of Interest. These are the models on what you will find the metaconfiguration / topping at UsabILIty Hub.
+ Select the models for which you want to find this topping at UsabILIty Hub.
Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
@@ -39,6 +55,13 @@
+ -
+
+
+ Refresh
+
+
+
-
@@ -49,23 +72,35 @@
+ -
+
+
-
+
+ Allow all sources
+
+
+ -
+
+ PostGIS
+
+
+ -
+
+ GeoPackage
+
+
+
+
-
-
-
- Qt::Horizontal
-
-
-
- 693
- 20
-
+
+
+
-
-
- -
-
- Refresh
+ <html><head/><body><p>Select the database type for which you want to find this topping (or specify none to be visible for all).</p></body></html>
+
+
+ true
diff --git a/docs/background_info/usabilityhub/technical_concept.md b/docs/background_info/usabilityhub/technical_concept.md
index d5fceb7b6..6a1a919fc 100644
--- a/docs/background_info/usabilityhub/technical_concept.md
+++ b/docs/background_info/usabilityhub/technical_concept.md
@@ -41,7 +41,7 @@ Additional servers/repositories can be linked via the `ilisite.xml`. The `Datase
- http://codes.opengis.ch/modelbaker
+ http://codes.modelbaker.ch/preferredDataSource/gpkg