Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Architecture planning #1

Merged
merged 4 commits into from
Sep 18, 2024
Merged

Architecture planning #1

merged 4 commits into from
Sep 18, 2024

Conversation

nmaarnio
Copy link
Collaborator

No description provided.

@nmaarnio nmaarnio marked this pull request as ready for review September 13, 2024 09:26
Copy link

@LKajan LKajan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good start! Let's build on this and change things later if needed.

from arho_feature_template.qgis_plugin_tools.tools.resources import load_ui


class FeatureAttributeForm(QDialog, load_ui("feature_attribute_form.ui")):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of using the load_ui util from the plugin_tools. IMHO it is cleaner to have the ui files next to the corresponding python module than in a fixed arbitrary location. What do you think?

I would to suggest something like this:

from importlib import resources
from qgis.PyQt import uic

ui_path = resources.files() / "feature_attribute_form.ui"  # files() without arguments looks resources adjacent to the caller module
FormClass, _ = uic.loadUiType(ui_path)

class FeatureAttributeForm(QDialog, FormClass):
    ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have strong preference for the UI loading, but I like the idea that the ui files are next to the python module. Changed to this (but gave __package__ as an argument for files() since it seems to be needed in older Python versions).

from arho_feature_template.qgis_plugin_tools.tools.resources import load_ui


class AddFeaturePanel(QWidget, load_ui("add_feature_panel.ui")):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rename to something like TemplateLibraryPanel

feature_attribte_group: str
attribute_layer: QgsMapLayer # Is this correct type?
additional_information: str
input_field_type: QLineEdit | QgsSpinBox | QgsDoubleSpinBox | None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be read at form rendering time from the layer settings.



@dataclass
class FeatureTemplate:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now missing possible child features. But that's totally fine for now! Let's first try to get this working with the most simple one feature case. Probably the library config should be updated accordingly.

- Renamed AddFeaturePanel to TemplateLibraryPanel
- Changed how UI files are loaded and placed
- Commented out attribute_layer from FeatureTemplate
@nmaarnio nmaarnio merged commit 979e0ca into master Sep 18, 2024
1 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants