Skip to content

Commit

Permalink
Merge pull request #986 from opengisch/export_metaconfig
Browse files Browse the repository at this point in the history
[toppingwizard] Export all ili2db settings to metaconfig file
  • Loading branch information
signedav authored Nov 27, 2024
2 parents e273c33 + 1ccab15 commit fae8bcc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:

# Remove unused imports/variables
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v2.3.1
hooks:
- id: autoflake
args:
Expand Down
22 changes: 16 additions & 6 deletions QgisModelBaker/gui/topping_wizard/ili2dbsettings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@
* *
***************************************************************************/
"""
import tempfile
from enum import IntEnum

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

from QgisModelBaker.libs.modelbaker.iliwrapper.ili2dbconfig import (
Ili2DbCommandConfiguration,
)
from QgisModelBaker.libs.modelbaker.utils import db_utils
from QgisModelBaker.libs.modelbaker.utils.ili2db_utils import Ili2DbUtils
from QgisModelBaker.libs.modelbaker.utils.qt_utils import make_file_selector
from QgisModelBaker.utils import gui_utils

Expand Down Expand Up @@ -288,14 +290,22 @@ def _refresh_combobox(self):

def _schema_changed(self):
configuration = self.schema_combobox.currentData()
parsed_from_file = False
if configuration:
db_connector = db_utils.get_db_connector(configuration)
if db_connector:
self.topping_wizard.topping.metaconfig.ili2db_settings.parse_parameters_from_db(
db_connector
_, tmp_ini_file = tempfile.mkstemp(".ini")

ili2db_utils = Ili2DbUtils()
ili2db_utils.log_on_error.connect(self._log_on_export_metagonfig_error)
res, msg = ili2db_utils.export_metaconfig(tmp_ini_file, configuration)
if res:
parsed_from_file = self.topping_wizard.topping.metaconfig.ili2db_settings.parse_parameters_from_ini_file(
tmp_ini_file
)
else:
if not parsed_from_file:
self.topping_wizard.topping.metaconfig.ili2db_settings.parameters = {}
self.parameters_model.refresh_model(
self.topping_wizard.topping.metaconfig.ili2db_settings.parameters
)

def _log_on_export_metagonfig_error(self, log):
QgsMessageLog.logMessage(log, self.tr("Export metaConfig"), Qgis.Critical)

0 comments on commit fae8bcc

Please sign in to comment.