Skip to content

Commit

Permalink
Move Ili2DbUtils to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor committed Oct 1, 2024
1 parent c074485 commit 805ee0e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 105 deletions.
11 changes: 8 additions & 3 deletions QgisModelBaker/gui/basket_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
***************************************************************************/
"""

from qgis.core import QgsApplication, QgsProject
from qgis.core import Qgis, QgsApplication, QgsMessageLog, QgsProject
from qgis.PyQt.QtWidgets import QDialog, QMessageBox

from QgisModelBaker.gui.create_baskets import CreateBasketDialog
Expand All @@ -26,8 +26,8 @@
from QgisModelBaker.libs.modelbaker.iliwrapper.ili2dbconfig import (
Ili2DbCommandConfiguration,
)
from QgisModelBaker.libs.modelbaker.utils.ili2db_utils import Ili2DbUtils
from QgisModelBaker.utils import gui_utils
from QgisModelBaker.utils.ili2db_utils import Ili2DbUtils

DIALOG_UI = gui_utils.get_ui_class("basket_manager.ui")

Expand Down Expand Up @@ -188,7 +188,9 @@ def _do_delete_basket(self, basket_config):
)

# Remove temporary dataset
res, msg = Ili2DbUtils().delete_dataset(tmp_dataset_name, self.configuration)
ili2db_utils = Ili2DbUtils()
ili2db_utils.log_on_error.connect(self._log_on_delete_dataset_error)
res, msg = ili2db_utils.delete_dataset(tmp_dataset_name, self.configuration)

# If anything went bad, leave everything as the original status,
# i.e., move the basket to its original dataset
Expand All @@ -210,3 +212,6 @@ def _do_delete_basket(self, basket_config):
)

return res, msg

def _log_on_delete_dataset_error(self, log):
QgsMessageLog.logMessage(log, self.tr("Delete dataset from DB"), Qgis.Critical)
11 changes: 8 additions & 3 deletions QgisModelBaker/gui/dataset_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
***************************************************************************/
"""

from qgis.core import QgsApplication, QgsMapLayer, QgsProject
from qgis.core import Qgis, QgsApplication, QgsMapLayer, QgsMessageLog, QgsProject
from qgis.gui import QgsMessageBar
from qgis.PyQt.QtCore import QSettings, Qt
from qgis.PyQt.QtWidgets import (
Expand All @@ -35,9 +35,9 @@
from QgisModelBaker.libs.modelbaker.iliwrapper.ili2dbconfig import (
Ili2DbCommandConfiguration,
)
from QgisModelBaker.libs.modelbaker.utils.ili2db_utils import Ili2DbUtils
from QgisModelBaker.utils import gui_utils
from QgisModelBaker.utils.gui_utils import DatasetModel
from QgisModelBaker.utils.ili2db_utils import Ili2DbUtils

DIALOG_UI = gui_utils.get_ui_class("dataset_manager.ui")

Expand Down Expand Up @@ -190,7 +190,9 @@ def _delete_dataset(self):
dataset = self.dataset_tableview.selectedIndexes()[0].data(
int(DatasetModel.Roles.DATASETNAME)
)
res, msg = Ili2DbUtils().delete_dataset(dataset, self.configuration)
ili2db_utils = Ili2DbUtils()
ili2db_utils.log_on_error.connect(self._log_on_delete_dataset_error)
res, msg = ili2db_utils.delete_dataset(dataset, self.configuration)
if res:
# After deletion, make sure canvas is refreshed
self._refresh_map_layers()
Expand All @@ -206,6 +208,9 @@ def _delete_dataset(self):
warning_box.setText(msg)
warning_box.exec_()

def _log_on_delete_dataset_error(self, log):
QgsMessageLog.logMessage(log, self.tr("Delete dataset from DB"), Qgis.Critical)

def _refresh_map_layers(self):
# Refresh layer data sources and also their symbology (including feature count)
layer_tree_view = self.iface.layerTreeView()
Expand Down
99 changes: 0 additions & 99 deletions QgisModelBaker/utils/ili2db_utils.py

This file was deleted.

0 comments on commit 805ee0e

Please sign in to comment.