diff --git a/QgisModelBaker/gui/validate.py b/QgisModelBaker/gui/validate.py index b24676e78..211f915bb 100644 --- a/QgisModelBaker/gui/validate.py +++ b/QgisModelBaker/gui/validate.py @@ -22,6 +22,7 @@ from PyQt5.QtGui import QColor, QGuiApplication from qgis.core import ( QgsApplication, + QgsExpressionContextUtils, QgsGeometry, QgsMapLayer, QgsPointXY, @@ -165,9 +166,21 @@ def __init__(self, base_config, iface): self.auto_pan_button.clicked.connect(self._auto_pan_button_clicked) self.auto_zoom_button.clicked.connect(self._auto_zoom_button_clicked) - self.validator_config_file_tool_button.clicked.connect( - self._select_validator_config_file + save_config_file_action = QAction( + QgsApplication.getThemeIcon("/mActionFileSave.svg"), + self.tr("Save config file to project..."), + self, ) + save_config_file_action.triggered.connect(self._save_config_file) + self.config_file_tool_button.addAction(save_config_file_action) + load_config_file_action = QAction( + QgsApplication.getThemeIcon("/mActionFileOpen.svg"), + self.tr("Load config file from project..."), + self, + ) + load_config_file_action.triggered.connect(self._load_config_file) + self.config_file_tool_button.addAction(load_config_file_action) + self.config_file_tool_button.clicked.connect(self._select_config_file) def _reset_current_values(self): self.current_configuration = ValidateConfiguration() @@ -179,6 +192,7 @@ def _reset_current_values(self): self.current_filter_mode = SchemaDataFilterMode.NO_FILTER self.current_export_models_model = SchemaModelsModel() self.current_export_models_active = False + self.config_file_line_edit.clear() def _reset_gui(self): self._reset_current_values() @@ -284,6 +298,9 @@ def set_current_layer(self, layer): self.filter_data_panel.setup_dialog(self._basket_handling()) self.export_models_panel.setup_dialog(True) + + self._load_config_file() + self.setDisabled(False) def _visibility_changed(self, visible): @@ -363,9 +380,7 @@ def _run(self, edited_command=None): validator.configuration.skip_geometry_errors = ( self.skip_geometry_errors_check_box.isChecked() ) - validator.configuration.valid_config = ( - self.validator_config_file_line_edit.text() - ) + validator.configuration.valid_config = self.config_file_line_edit.text() self.progress_bar.setValue(20) validation_result_state = False @@ -632,12 +647,27 @@ def _auto_zoom_button_clicked(self): if self.auto_zoom_button.isChecked: self.auto_pan_button.setChecked(False) - def _select_validator_config_file(self): + def _select_config_file(self): filename, _ = QFileDialog.getOpenFileName( self, self.tr("Select the validator config file") ) if filename: - self.validator_config_file_line_edit.setText(filename) + self.config_file_line_edit.setText(filename) + + def _save_config_file(self): + filename = self.config_file_line_edit.text() + + QgsExpressionContextUtils.setProjectVariable( + QgsProject.instance(), + f"validator_config_{self.current_schema_identificator}", + filename, + ) + + def _load_config_file(self): + filename = QgsExpressionContextUtils.projectScope( + QgsProject.instance() + ).variable(f"validator_config_{self.current_schema_identificator}") + self.config_file_line_edit.setText(filename) def _validator_stdout(self, txt): lines = txt.strip().split("\n") diff --git a/QgisModelBaker/ui/validator.ui b/QgisModelBaker/ui/validator.ui index 18fe95b79..a2f24827f 100644 --- a/QgisModelBaker/ui/validator.ui +++ b/QgisModelBaker/ui/validator.ui @@ -15,7 +15,100 @@ - + + + + + + + true + + + + + + + 0 + + + + + + + 0 + + + + + + + Ignores geometry errors (--skipGeometryErrors) and AREA topology validation (--disableAreaValidation) + + + Skip Geometry Errors + + + + + + + ili2db option --validConfig + + + Validator config file (--validConfig) + + + + + + + ... + + + QToolButton::MenuButtonPopup + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + 0 + + + + + + + + + + + + @@ -94,100 +187,6 @@ - - - - 0 - - - - - - - 0 - - - - - - - Ignores geometry errors (--skipGeometryErrors) and AREA topology validation (--disableAreaValidation) - - - Skip Geometry Errors - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - ili2db option --validConfig - - - Validator config file (--validConfig) - - - - - - - ... - - - - - - - - - - - - true - - -