Skip to content

Commit

Permalink
Merge pull request #733 from opengisch/source-uri
Browse files Browse the repository at this point in the history
Use functions with source provider instead of converted QgsDataSource
  • Loading branch information
signedav authored Sep 30, 2022
2 parents f385d5f + b1e7623 commit 9d5b39c
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 36 deletions.
15 changes: 7 additions & 8 deletions QgisModelBaker/gui/panel/dataset_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
***************************************************************************/
"""

from qgis.core import QgsDataSourceUri, QgsExpressionContextUtils, QgsProject
from qgis.core import QgsExpressionContextUtils, QgsProject
from qgis.PyQt.QtCore import QSortFilterProxyModel, Qt
from qgis.PyQt.QtWidgets import QComboBox, QWidget

Expand All @@ -26,8 +26,8 @@
Ili2DbCommandConfiguration,
)
from QgisModelBaker.libs.modelbaker.utils.db_utils import (
get_configuration_from_layersource,
get_schema_identificator_from_layersource,
get_configuration_from_sourceprovider,
get_schema_identificator_from_sourceprovider,
)
from QgisModelBaker.libs.modelbaker.utils.qt_utils import slugify
from QgisModelBaker.utils.gui_utils import BasketSourceModel
Expand Down Expand Up @@ -58,9 +58,8 @@ def set_current_layer(self, layer):
return

source_provider = layer.dataProvider()
source = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
schema_identificator = get_schema_identificator_from_layersource(
source_provider, source
schema_identificator = get_schema_identificator_from_sourceprovider(
source_provider
)
if not schema_identificator:
return
Expand All @@ -79,8 +78,8 @@ def set_current_layer(self, layer):

if not self.basket_model.schema_baskets_loaded(schema_identificator):
configuration = Ili2DbCommandConfiguration()
valid, mode = get_configuration_from_layersource(
source_provider, source, configuration
valid, mode = get_configuration_from_sourceprovider(
source_provider, configuration
)
if valid and mode:
db_factory = self.db_simple_factory.create_factory(mode)
Expand Down
11 changes: 5 additions & 6 deletions QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"""
from enum import IntEnum

from qgis.core import QgsDataSourceUri, QgsMapLayer, QgsProject
from qgis.core import QgsMapLayer, QgsProject
from qgis.PyQt.QtCore import QAbstractItemModel, QModelIndex, Qt
from qgis.PyQt.QtWidgets import QHeaderView, QTableView, QWizardPage

Expand Down Expand Up @@ -245,10 +245,9 @@ def _refresh_combobox(self):
for layer in QgsProject.instance().mapLayers().values():
if layer.type() == QgsMapLayer.VectorLayer:
source_provider = layer.dataProvider()
source = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
schema_identificator = (
db_utils.get_schema_identificator_from_layersource(
source_provider, source
db_utils.get_schema_identificator_from_sourceprovider(
source_provider
)
)
if (
Expand All @@ -258,8 +257,8 @@ def _refresh_combobox(self):
continue

configuration = Ili2DbCommandConfiguration()
valid, mode = db_utils.get_configuration_from_layersource(
source_provider, source, configuration
valid, mode = db_utils.get_configuration_from_sourceprovider(
source_provider, configuration
)
if valid and mode:
configuration.tool = mode
Expand Down
15 changes: 6 additions & 9 deletions QgisModelBaker/gui/topping_wizard/layers_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

from qgis.core import (
QgsApplication,
QgsDataSourceUri,
QgsLayerTree,
QgsLayerTreeModel,
QgsMapLayer,
Expand Down Expand Up @@ -359,10 +358,9 @@ def _load_ili_schema_identificators(self):
for layer in QgsProject.instance().mapLayers().values():
if layer.type() == QgsMapLayer.VectorLayer:
source_provider = layer.dataProvider()
source = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
schema_identificator = (
db_utils.get_schema_identificator_from_layersource(
source_provider, source
db_utils.get_schema_identificator_from_sourceprovider(
source_provider
)
)
if (
Expand All @@ -373,8 +371,8 @@ def _load_ili_schema_identificators(self):

checked_schema_identificator.append(schema_identificator)
configuration = Ili2DbCommandConfiguration()
valid, mode = db_utils.get_configuration_from_layersource(
source_provider, source, configuration
valid, mode = db_utils.get_configuration_from_sourceprovider(
source_provider, configuration
)
if valid and mode:
configuration.tool = mode
Expand All @@ -392,9 +390,8 @@ def _is_ili_schema(self, layer):
return False

source_provider = layer.dataProvider()
source = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
schema_identificator = db_utils.get_schema_identificator_from_layersource(
source_provider, source
schema_identificator = db_utils.get_schema_identificator_from_sourceprovider(
source_provider
)
return schema_identificator in self.ili_schema_identificators

Expand Down
11 changes: 5 additions & 6 deletions QgisModelBaker/gui/topping_wizard/models_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
***************************************************************************/
"""

from qgis.core import QgsDataSourceUri, QgsMapLayer, QgsProject
from qgis.core import QgsMapLayer, QgsProject
from qgis.PyQt.QtWidgets import QWizardPage

import QgisModelBaker.libs.modelbaker.utils.db_utils as db_utils
Expand Down Expand Up @@ -83,19 +83,18 @@ def _load_available_models(self):
for layer in QgsProject.instance().mapLayers().values():
if layer.type() == QgsMapLayer.VectorLayer:
source_provider = layer.dataProvider()
source = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
schema_identificator = (
db_utils.get_schema_identificator_from_layersource(
source_provider, source
db_utils.get_schema_identificator_from_sourceprovider(
source_provider
)
)
if schema_identificator in checked_identificators:
continue
else:
checked_identificators.append(schema_identificator)
current_configuration = Ili2DbCommandConfiguration()
valid, mode = db_utils.get_configuration_from_layersource(
source_provider, source, current_configuration
valid, mode = db_utils.get_configuration_from_sourceprovider(
source_provider, current_configuration
)
if valid and mode:
current_configuration.tool = mode
Expand Down
10 changes: 4 additions & 6 deletions QgisModelBaker/gui/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from PyQt5.QtGui import QColor, QGuiApplication
from qgis.core import (
QgsApplication,
QgsDataSourceUri,
QgsGeometry,
QgsMapLayer,
QgsPointXY,
Expand Down Expand Up @@ -185,9 +184,8 @@ def set_current_layer(self, layer):
return

source_provider = layer.dataProvider()
source = QgsDataSourceUri(layer.dataProvider().dataSourceUri())
schema_identificator = db_utils.get_schema_identificator_from_layersource(
source_provider, source
schema_identificator = db_utils.get_schema_identificator_from_sourceprovider(
source_provider
)
if not schema_identificator:
self.setDisabled(True)
Expand All @@ -199,8 +197,8 @@ def set_current_layer(self, layer):
self._reset_gui()

self.current_schema_identificator = schema_identificator
valid, mode = db_utils.get_configuration_from_layersource(
source_provider, source, self.current_configuration
valid, mode = db_utils.get_configuration_from_sourceprovider(
source_provider, self.current_configuration
)
if valid and mode:
output_file_name = "{}.xtf".format(self.current_schema_identificator)
Expand Down
2 changes: 1 addition & 1 deletion scripts/package_pip_packages.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
LIBS_DIR="QgisModelBaker/libs"

MODELBAKER_LIBRARY=("modelbaker" "1.3.1")
MODELBAKER_LIBRARY=("modelbaker" "1.3.2")
PACKAGING=("packaging" "21.3")

PACKAGES=(
Expand Down

0 comments on commit 9d5b39c

Please sign in to comment.