diff --git a/arho_feature_template/core/exceptions.py b/arho_feature_template/core/exceptions.py deleted file mode 100644 index 50b61b5..0000000 --- a/arho_feature_template/core/exceptions.py +++ /dev/null @@ -1,2 +0,0 @@ -class UnexpectedNoneError(Exception): - """Internal QGIS errors that should not be happened""" diff --git a/arho_feature_template/exceptions.py b/arho_feature_template/exceptions.py index 51350d7..5e87eb1 100644 --- a/arho_feature_template/exceptions.py +++ b/arho_feature_template/exceptions.py @@ -6,3 +6,7 @@ def __init__(self, layer_name: str): class LayerNotVectorTypeError(Exception): def __init__(self, layer_name: str): super().__init__(f"Layer {layer_name} is not a vector layer") + + +class UnexpectedNoneError(Exception): + """Internal QGIS errors that should not be happened""" diff --git a/arho_feature_template/gui/feature_attribute_form.py b/arho_feature_template/gui/feature_attribute_form.py deleted file mode 100644 index 4ee366b..0000000 --- a/arho_feature_template/gui/feature_attribute_form.py +++ /dev/null @@ -1,35 +0,0 @@ -from __future__ import annotations - -from collections import defaultdict -from importlib import resources -from typing import TYPE_CHECKING - -from qgis.PyQt import uic -from qgis.PyQt.QtWidgets import QDialog, QLineEdit - -if TYPE_CHECKING: - from qgis.PyQt.QtWidgets import QDialogButtonBox, QFormLayout, QWidget - - from arho_feature_template.core.template_library_config import Feature - -ui_path = resources.files(__package__) / "feature_attribute_form.ui" -FormClass, _ = uic.loadUiType(ui_path) - - -class FeatureAttributeForm(QDialog, FormClass): # type: ignore - """Parent class for feature forms for adding and modifying feature attribute data.""" - - attribute_form_layout: QFormLayout - button_box: QDialogButtonBox - - def __init__(self, feature_template_config: Feature): - super().__init__() - self.setupUi(self) - - self.attribute_widgets: dict[str, dict[str, QWidget]] = defaultdict(dict) - - layer = feature_template_config.layer - for attribute_config in feature_template_config.attributes: - field = QLineEdit() - self.attribute_form_layout.addRow(attribute_config.attribute, field) - self.attribute_widgets[layer][attribute_config.attribute] = field diff --git a/arho_feature_template/gui/feature_attribute_form.ui b/arho_feature_template/gui/feature_attribute_form.ui deleted file mode 100644 index 8f08001..0000000 --- a/arho_feature_template/gui/feature_attribute_form.ui +++ /dev/null @@ -1,80 +0,0 @@ - - - Dialog - - - - 0 - 0 - 640 - 401 - - - - Dialog - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - button_box - accepted() - Dialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - button_box - rejected() - Dialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - diff --git a/arho_feature_template/core/__init__.py b/arho_feature_template/plan/__init__.py similarity index 100% rename from arho_feature_template/core/__init__.py rename to arho_feature_template/plan/__init__.py diff --git a/arho_feature_template/gui/load_plan_dialog.py b/arho_feature_template/plan/load_plan_dialog.py similarity index 98% rename from arho_feature_template/gui/load_plan_dialog.py rename to arho_feature_template/plan/load_plan_dialog.py index 2ec3b14..1a686c0 100644 --- a/arho_feature_template/gui/load_plan_dialog.py +++ b/arho_feature_template/plan/load_plan_dialog.py @@ -6,7 +6,7 @@ from qgis.PyQt.QtGui import QStandardItem, QStandardItemModel from qgis.PyQt.QtWidgets import QComboBox, QDialog, QDialogButtonBox, QLineEdit, QMessageBox, QPushButton, QTableView -from arho_feature_template.core.exceptions import UnexpectedNoneError +from arho_feature_template.exceptions import UnexpectedNoneError ui_path = resources.files(__package__) / "load_plan_dialog.ui" diff --git a/arho_feature_template/gui/load_plan_dialog.ui b/arho_feature_template/plan/load_plan_dialog.ui similarity index 100% rename from arho_feature_template/gui/load_plan_dialog.ui rename to arho_feature_template/plan/load_plan_dialog.ui diff --git a/arho_feature_template/core/plan_manager.py b/arho_feature_template/plan/plan_manager.py similarity index 97% rename from arho_feature_template/core/plan_manager.py rename to arho_feature_template/plan/plan_manager.py index 6b8a137..13a33b5 100644 --- a/arho_feature_template/core/plan_manager.py +++ b/arho_feature_template/plan/plan_manager.py @@ -9,10 +9,10 @@ from qgis.PyQt.QtWidgets import QDialog, QMessageBox from qgis.utils import iface -from arho_feature_template.core.lambda_service import LambdaService -from arho_feature_template.gui.load_plan_dialog import LoadPlanDialog -from arho_feature_template.gui.serialize_plan import SerializePlan +from arho_feature_template.plan.load_plan_dialog import LoadPlanDialog +from arho_feature_template.plan.serialize_plan import SerializePlan from arho_feature_template.utils.db_utils import get_existing_database_connection_names +from arho_feature_template.utils.lambda_service import LambdaService from arho_feature_template.utils.misc_utils import get_active_plan_id, get_layer_by_name, handle_unsaved_changes logger = logging.getLogger(__name__) diff --git a/arho_feature_template/gui/serialize_plan.py b/arho_feature_template/plan/serialize_plan.py similarity index 100% rename from arho_feature_template/gui/serialize_plan.py rename to arho_feature_template/plan/serialize_plan.py diff --git a/arho_feature_template/gui/serialize_plan.ui b/arho_feature_template/plan/serialize_plan.ui similarity index 100% rename from arho_feature_template/gui/serialize_plan.ui rename to arho_feature_template/plan/serialize_plan.ui diff --git a/arho_feature_template/gui/__init__.py b/arho_feature_template/plan_feature/__init__.py similarity index 100% rename from arho_feature_template/gui/__init__.py rename to arho_feature_template/plan_feature/__init__.py diff --git a/arho_feature_template/core/feature_template_library.py b/arho_feature_template/plan_feature/feature_template_library.py similarity index 96% rename from arho_feature_template/core/feature_template_library.py rename to arho_feature_template/plan_feature/feature_template_library.py index 0dada5d..9bd11cc 100644 --- a/arho_feature_template/core/feature_template_library.py +++ b/arho_feature_template/plan_feature/feature_template_library.py @@ -9,16 +9,16 @@ from qgis.PyQt.QtGui import QStandardItem, QStandardItemModel from qgis.utils import iface -from arho_feature_template.core.template_library_config import ( +from arho_feature_template.exceptions import LayerNotFoundError, LayerNotVectorTypeError +from arho_feature_template.plan_feature.plan_feature_form import PlanFeatureForm +from arho_feature_template.plan_feature.template_dock import TemplateLibraryDock +from arho_feature_template.plan_feature.template_library_config import ( FeatureTemplate, TemplateLibraryConfig, TemplateLibraryVersionError, TemplateSyntaxError, parse_template_library_config, ) -from arho_feature_template.exceptions import LayerNotFoundError, LayerNotVectorTypeError -from arho_feature_template.gui.template_attribute_form import TemplateAttributeForm -from arho_feature_template.gui.template_dock import TemplateLibraryDock from arho_feature_template.resources.template_libraries import library_config_files from arho_feature_template.utils.project_utils import get_layer_from_project @@ -157,7 +157,7 @@ def ask_for_feature_attributes(self, feature: QgsFeature) -> None: if not self.active_template: return - attribute_form = TemplateAttributeForm(self.active_template.config) + attribute_form = PlanFeatureForm(self.active_template.config) if attribute_form.exec_(): layer = get_layer_from_project(self.active_template.config.feature.layer) diff --git a/arho_feature_template/gui/template_attribute_form.py b/arho_feature_template/plan_feature/plan_feature_form.py similarity index 91% rename from arho_feature_template/gui/template_attribute_form.py rename to arho_feature_template/plan_feature/plan_feature_form.py index 2508cd8..063997e 100644 --- a/arho_feature_template/gui/template_attribute_form.py +++ b/arho_feature_template/plan_feature/plan_feature_form.py @@ -19,23 +19,23 @@ QTreeWidgetItem, ) -from arho_feature_template.core.plan_regulation_group_config import ( +from arho_feature_template.plan_regulation_group.plan_regulation_group_config import ( PlanRegulationGroupDefinition, PlanRegulationGroupLibrary, ) -from arho_feature_template.gui.plan_regulation_group_widget import PlanRegulationGroupWidget +from arho_feature_template.plan_regulation_group.plan_regulation_group_widget import PlanRegulationGroupWidget from arho_feature_template.qgis_plugin_tools.tools.resources import resources_path if TYPE_CHECKING: from qgis.PyQt.QtWidgets import QWidget - from arho_feature_template.core.template_library_config import FeatureTemplate + from arho_feature_template.plan_feature.template_library_config import FeatureTemplate -ui_path = resources.files(__package__) / "template_attribute_form.ui" +ui_path = resources.files(__package__) / "plan_feature_form.ui" FormClass, _ = uic.loadUiType(ui_path) -class TemplateAttributeForm(QDialog, FormClass): # type: ignore +class PlanFeatureForm(QDialog, FormClass): # type: ignore """Parent class for feature template forms for adding and modifying feature attribute data.""" def __init__(self, feature_template_config: FeatureTemplate): diff --git a/arho_feature_template/gui/template_attribute_form.ui b/arho_feature_template/plan_feature/plan_feature_form.ui similarity index 100% rename from arho_feature_template/gui/template_attribute_form.ui rename to arho_feature_template/plan_feature/plan_feature_form.ui diff --git a/arho_feature_template/gui/template_dock.py b/arho_feature_template/plan_feature/template_dock.py similarity index 100% rename from arho_feature_template/gui/template_dock.py rename to arho_feature_template/plan_feature/template_dock.py diff --git a/arho_feature_template/gui/template_dock.ui b/arho_feature_template/plan_feature/template_dock.ui similarity index 100% rename from arho_feature_template/gui/template_dock.ui rename to arho_feature_template/plan_feature/template_dock.ui diff --git a/arho_feature_template/core/template_library_config.py b/arho_feature_template/plan_feature/template_library_config.py similarity index 100% rename from arho_feature_template/core/template_library_config.py rename to arho_feature_template/plan_feature/template_library_config.py diff --git a/arho_feature_template/plan_regulation/__init__.py b/arho_feature_template/plan_regulation/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/arho_feature_template/core/plan_regulation_config.py b/arho_feature_template/plan_regulation/plan_regulation_config.py similarity index 100% rename from arho_feature_template/core/plan_regulation_config.py rename to arho_feature_template/plan_regulation/plan_regulation_config.py diff --git a/arho_feature_template/gui/plan_regulation_widget.py b/arho_feature_template/plan_regulation/plan_regulation_widget.py similarity index 98% rename from arho_feature_template/gui/plan_regulation_widget.py rename to arho_feature_template/plan_regulation/plan_regulation_widget.py index 0c11aa5..25dcfd5 100644 --- a/arho_feature_template/gui/plan_regulation_widget.py +++ b/arho_feature_template/plan_regulation/plan_regulation_widget.py @@ -19,13 +19,13 @@ QWidget, ) -from arho_feature_template.core.plan_regulation_config import PlanRegulationConfig, ValueType +from arho_feature_template.plan_regulation.plan_regulation_config import PlanRegulationConfig, ValueType from arho_feature_template.utils.misc_utils import get_additional_information_name, get_layer_by_name if TYPE_CHECKING: from qgis.PyQt.QtWidgets import QPushButton - from arho_feature_template.core.plan_regulation_group_config import PlanRegulationDefinition + from arho_feature_template.plan_regulation_group.plan_regulation_group_config import PlanRegulationDefinition ui_path = resources.files(__package__) / "plan_regulation_widget.ui" FormClass, _ = uic.loadUiType(ui_path) diff --git a/arho_feature_template/gui/plan_regulation_widget.ui b/arho_feature_template/plan_regulation/plan_regulation_widget.ui similarity index 100% rename from arho_feature_template/gui/plan_regulation_widget.ui rename to arho_feature_template/plan_regulation/plan_regulation_widget.ui diff --git a/arho_feature_template/plan_regulation_group/__init__.py b/arho_feature_template/plan_regulation_group/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/arho_feature_template/core/plan_regulation_group_config.py b/arho_feature_template/plan_regulation_group/plan_regulation_group_config.py similarity index 96% rename from arho_feature_template/core/plan_regulation_group_config.py rename to arho_feature_template/plan_regulation_group/plan_regulation_group_config.py index 0d455eb..e8833a8 100644 --- a/arho_feature_template/core/plan_regulation_group_config.py +++ b/arho_feature_template/plan_regulation_group/plan_regulation_group_config.py @@ -7,7 +7,7 @@ import yaml from qgis.utils import iface -from arho_feature_template.core.plan_regulation_config import PlanRegulationDefinition, PlanRegulationsSet +from arho_feature_template.plan_regulation.plan_regulation_config import PlanRegulationDefinition, PlanRegulationsSet if TYPE_CHECKING: from pathlib import Path diff --git a/arho_feature_template/gui/new_plan_regulation_group_form.py b/arho_feature_template/plan_regulation_group/plan_regulation_group_form.py similarity index 88% rename from arho_feature_template/gui/new_plan_regulation_group_form.py rename to arho_feature_template/plan_regulation_group/plan_regulation_group_form.py index 198e434..65ab82b 100644 --- a/arho_feature_template/gui/new_plan_regulation_group_form.py +++ b/arho_feature_template/plan_regulation_group/plan_regulation_group_form.py @@ -7,17 +7,17 @@ from qgis.PyQt.QtCore import Qt from qgis.PyQt.QtWidgets import QDialog, QTextBrowser, QTreeWidget, QTreeWidgetItem -from arho_feature_template.core.plan_regulation_config import PlanRegulationConfig, PlanRegulationsSet -from arho_feature_template.gui.plan_regulation_widget import PlanRegulationWidget +from arho_feature_template.plan_regulation.plan_regulation_config import PlanRegulationConfig, PlanRegulationsSet +from arho_feature_template.plan_regulation.plan_regulation_widget import PlanRegulationWidget if TYPE_CHECKING: from qgis.PyQt.QtWidgets import QBoxLayout, QWidget -ui_path = resources.files(__package__) / "new_plan_regulation_group_form.ui" +ui_path = resources.files(__package__) / "plan_regulation_group_form.ui" FormClass, _ = uic.loadUiType(ui_path) -class NewPlanRegulationGroupForm(QDialog, FormClass): # type: ignore +class PlanRegulationGroupForm(QDialog, FormClass): # type: ignore """Form to create a new plan regulation group.""" def __init__(self): diff --git a/arho_feature_template/gui/new_plan_regulation_group_form.ui b/arho_feature_template/plan_regulation_group/plan_regulation_group_form.ui similarity index 100% rename from arho_feature_template/gui/new_plan_regulation_group_form.ui rename to arho_feature_template/plan_regulation_group/plan_regulation_group_form.ui diff --git a/arho_feature_template/gui/plan_regulation_group_widget.py b/arho_feature_template/plan_regulation_group/plan_regulation_group_widget.py similarity index 86% rename from arho_feature_template/gui/plan_regulation_group_widget.py rename to arho_feature_template/plan_regulation_group/plan_regulation_group_widget.py index 89f51a0..4d28fc0 100644 --- a/arho_feature_template/gui/plan_regulation_group_widget.py +++ b/arho_feature_template/plan_regulation_group/plan_regulation_group_widget.py @@ -8,13 +8,13 @@ from qgis.PyQt.QtCore import pyqtSignal from qgis.PyQt.QtWidgets import QWidget -from arho_feature_template.gui.plan_regulation_widget import PlanRegulationWidget +from arho_feature_template.plan_regulation.plan_regulation_widget import PlanRegulationWidget if TYPE_CHECKING: from qgis.PyQt.QtWidgets import QFrame, QLineEdit, QPushButton - from arho_feature_template.core.plan_regulation_config import PlanRegulationDefinition - from arho_feature_template.core.plan_regulation_group_config import PlanRegulationGroupDefinition + from arho_feature_template.plan_regulation.plan_regulation_config import PlanRegulationDefinition + from arho_feature_template.plan_regulation_group.plan_regulation_group_config import PlanRegulationGroupDefinition ui_path = resources.files(__package__) / "plan_regulation_group_widget.ui" FormClass, _ = uic.loadUiType(ui_path) diff --git a/arho_feature_template/gui/plan_regulation_group_widget.ui b/arho_feature_template/plan_regulation_group/plan_regulation_group_widget.ui similarity index 100% rename from arho_feature_template/gui/plan_regulation_group_widget.ui rename to arho_feature_template/plan_regulation_group/plan_regulation_group_widget.ui diff --git a/arho_feature_template/plugin.py b/arho_feature_template/plugin.py index 5b8dc8c..d378647 100644 --- a/arho_feature_template/plugin.py +++ b/arho_feature_template/plugin.py @@ -7,13 +7,16 @@ from qgis.PyQt.QtWidgets import QAction, QWidget from qgis.utils import iface -from arho_feature_template.core.feature_template_library import FeatureTemplater, TemplateGeometryDigitizeMapTool -from arho_feature_template.core.plan_manager import PlanManager -from arho_feature_template.gui.new_plan_regulation_group_form import NewPlanRegulationGroupForm -from arho_feature_template.gui.plugin_settings import PluginSettings +from arho_feature_template.plan.plan_manager import PlanManager +from arho_feature_template.plan_feature.feature_template_library import ( + FeatureTemplater, + TemplateGeometryDigitizeMapTool, +) +from arho_feature_template.plan_regulation_group.plan_regulation_group_form import PlanRegulationGroupForm from arho_feature_template.qgis_plugin_tools.tools.custom_logging import setup_logger, teardown_logger from arho_feature_template.qgis_plugin_tools.tools.i18n import setup_translation from arho_feature_template.qgis_plugin_tools.tools.resources import plugin_name +from arho_feature_template.utils.plugin_settings import PluginSettings if TYPE_CHECKING: from qgis.gui import QgisInterface, QgsMapTool @@ -225,5 +228,5 @@ def toggle_template_dock(self, show: bool) -> None: # noqa: FBT001 self.templater.template_dock.setUserVisible(show) def open_plan_regulation_group_form(self): - self.new_plan_regulation_group_dialog = NewPlanRegulationGroupForm() + self.new_plan_regulation_group_dialog = PlanRegulationGroupForm() self.new_plan_regulation_group_dialog.exec_() diff --git a/arho_feature_template/plugin_settings/__init__.py b/arho_feature_template/plugin_settings/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/arho_feature_template/gui/plugin_settings.py b/arho_feature_template/plugin_settings/plugin_settings.py similarity index 100% rename from arho_feature_template/gui/plugin_settings.py rename to arho_feature_template/plugin_settings/plugin_settings.py diff --git a/arho_feature_template/gui/plugin_settings.ui b/arho_feature_template/plugin_settings/plugin_settings.ui similarity index 100% rename from arho_feature_template/gui/plugin_settings.ui rename to arho_feature_template/plugin_settings/plugin_settings.ui diff --git a/arho_feature_template/utils/db_utils.py b/arho_feature_template/utils/db_utils.py index b8f67a0..26e2a5c 100644 --- a/arho_feature_template/utils/db_utils.py +++ b/arho_feature_template/utils/db_utils.py @@ -4,7 +4,7 @@ from qgis.core import QgsProviderRegistry -from arho_feature_template.core.exceptions import UnexpectedNoneError +from arho_feature_template.exceptions import UnexpectedNoneError LOGGER = logging.getLogger("LandUsePlugin") diff --git a/arho_feature_template/core/lambda_service.py b/arho_feature_template/utils/lambda_service.py similarity index 100% rename from arho_feature_template/core/lambda_service.py rename to arho_feature_template/utils/lambda_service.py