diff --git a/QgisModelBaker/gui/topping_wizard/models_page.py b/QgisModelBaker/gui/topping_wizard/models_page.py index 29433bff8..ec1383a19 100644 --- a/QgisModelBaker/gui/topping_wizard/models_page.py +++ b/QgisModelBaker/gui/topping_wizard/models_page.py @@ -70,18 +70,21 @@ def validatePage(self) -> bool: 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 +104,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/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/ui/topping_wizard/models.ui b/QgisModelBaker/ui/topping_wizard/models.ui index 50c2263ba..a225dc242 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,6 +41,9 @@ 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. @@ -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 type for which this topping should be made or specify none (allow all).</p></body></html> + + + true