diff --git a/qfieldsync/core/cloud_converter.py b/qfieldsync/core/cloud_converter.py index 7646eb70..55804ef9 100644 --- a/qfieldsync/core/cloud_converter.py +++ b/qfieldsync/core/cloud_converter.py @@ -21,7 +21,7 @@ from pathlib import Path -from qgis.core import QgsMapLayer, QgsProject, QgsProviderRegistry +from qgis.core import QgsMapLayer, QgsProject from qgis.PyQt.QtCore import QCoreApplication, QObject, pyqtSignal from qgis.utils import iface @@ -79,7 +79,6 @@ def convert(self) -> None: # noqa: C901 self.__layers = list(self.project.mapLayers().values()) # Loop through all layers and copy them to the destination folder - path_resolver = self.project.pathResolver() for current_layer_index, layer in enumerate(self.__layers): self.total_progress_updated.emit( current_layer_index, @@ -93,16 +92,9 @@ def convert(self) -> None: # noqa: C901 continue if layer.dataProvider() is not None: - provider_metadata = QgsProviderRegistry.instance().providerMetadata( - layer.dataProvider().name() - ) - if provider_metadata is not None: - decoded = provider_metadata.decodeUri(layer.source()) - if "path" in decoded: - path = path_resolver.writePath(decoded["path"]) - if path.startswith("localized:"): - # layer stored in localized data path, skip - continue + # layer stored in localized data path, skip + if layer_source.is_localized_path: + continue if layer.type() == QgsMapLayer.VectorLayer: if not layer_source.convert_to_gpkg(self.export_dirname): diff --git a/qfieldsync/gui/cloud_converter_dialog.py b/qfieldsync/gui/cloud_converter_dialog.py index f5810037..87f7310c 100644 --- a/qfieldsync/gui/cloud_converter_dialog.py +++ b/qfieldsync/gui/cloud_converter_dialog.py @@ -26,7 +26,7 @@ from pathlib import Path from typing import Optional -from qgis.core import Qgis, QgsProject, QgsProviderRegistry +from qgis.core import Qgis, QgsProject from qgis.gui import QgisInterface from qgis.PyQt.QtCore import QDir, Qt from qgis.PyQt.QtWidgets import ( @@ -48,6 +48,7 @@ from qfieldsync.core.cloud_transferrer import CloudTransferrer from qfieldsync.core.preferences import Preferences from qfieldsync.gui.cloud_login_dialog import CloudLoginDialog +from qfieldsync.libqfieldsync.layer import LayerSource from qfieldsync.libqfieldsync.utils.file_utils import ( fileparts, get_unique_empty_dirname, @@ -230,21 +231,14 @@ def update_info_visibility(self): """ Show the info label if there are unconfigured layers """ - pathResolver = QgsProject.instance().pathResolver() localizedDataPathLayers = [] for layer in list(self.project.mapLayers().values()): + layer_source = LayerSource(layer) if layer.dataProvider() is not None: - metadata = QgsProviderRegistry.instance().providerMetadata( - layer.dataProvider().name() - ) - if metadata is not None: - decoded = metadata.decodeUri(layer.source()) - if "path" in decoded: - path = pathResolver.writePath(decoded["path"]) - if path.startswith("localized:"): - localizedDataPathLayers.append( - "- {} ({})".format(layer.name(), path[10:]) - ) + if layer_source.is_localized_path: + localizedDataPathLayers.append( + "- {} ({})".format(layer.name(), layer_source.filename) + ) if localizedDataPathLayers: if len(localizedDataPathLayers) == 1: diff --git a/qfieldsync/gui/package_dialog.py b/qfieldsync/gui/package_dialog.py index 9e58e4e6..dfbe24a0 100644 --- a/qfieldsync/gui/package_dialog.py +++ b/qfieldsync/gui/package_dialog.py @@ -22,7 +22,7 @@ """ import os -from qgis.core import Qgis, QgsApplication, QgsProject, QgsProviderRegistry +from qgis.core import Qgis, QgsApplication, QgsProject from qgis.PyQt.QtCore import QDir, Qt from qgis.PyQt.QtGui import QIcon from qgis.PyQt.QtWidgets import QApplication, QDialog, QDialogButtonBox, QMessageBox @@ -156,24 +156,17 @@ def update_info_visibility(self): """ Show the info label if there are unconfigured layers """ - pathResolver = QgsProject.instance().pathResolver() showInfoConfiguration = False localizedDataPathLayers = [] for layer in list(self.project.mapLayers().values()): - if not LayerSource(layer).is_configured: + layer_source = LayerSource(layer) + if not layer_source.is_configured: showInfoConfiguration = True - if layer.dataProvider() is not None: - metadata = QgsProviderRegistry.instance().providerMetadata( - layer.dataProvider().name() + + if layer_source.is_localized_path: + localizedDataPathLayers.append( + "- {} ({})".format(layer.name(), layer_source.filename) ) - if metadata is not None: - decoded = metadata.decodeUri(layer.source()) - if "path" in decoded: - path = pathResolver.writePath(decoded["path"]) - if path.startswith("localized:"): - localizedDataPathLayers.append( - "- {} ({})".format(layer.name(), path[10:]) - ) self.infoConfigurationLabel.setVisible(showInfoConfiguration) if localizedDataPathLayers: diff --git a/qfieldsync/libqfieldsync b/qfieldsync/libqfieldsync index f4ce3ad0..1b6fc311 160000 --- a/qfieldsync/libqfieldsync +++ b/qfieldsync/libqfieldsync @@ -1 +1 @@ -Subproject commit f4ce3ad06a57662e006709ddae614a7979258e42 +Subproject commit 1b6fc3111f9c88780f64cf8688246a946d7ffd82