-
Notifications
You must be signed in to change notification settings - Fork 0
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
Lomakkeen tuottaminen templaatista #38
Merged
LKajan
merged 5 commits into
main
from
14-lomakkeen-tuottaminen-templaatin-konfiguraatiosta
Oct 30, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
41e37e6
feat: add feature template form draft version
nmaarnio 2287c42
implement remove plan regulation group button
nmaarnio 0e88381
Implement add plan regulation group button
nmaarnio 69fead5
add new template attribute form
nmaarnio fda2581
make new template attribute form initialize itself correctly, attempt…
nmaarnio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from __future__ import annotations | ||
|
||
from importlib import resources | ||
from typing import TYPE_CHECKING | ||
|
||
from qgis.core import QgsApplication | ||
from qgis.PyQt import uic | ||
from qgis.PyQt.QtCore import pyqtSignal | ||
from qgis.PyQt.QtWidgets import QWidget | ||
|
||
from arho_feature_template.gui.plan_regulation_widget import PlanRegulationWidget | ||
|
||
if TYPE_CHECKING: | ||
from qgis.PyQt.QtWidgets import QFrame, QLineEdit, QPushButton | ||
|
||
from arho_feature_template.core.template_library_config import Feature | ||
|
||
ui_path = resources.files(__package__) / "plan_regulation_group_widget.ui" | ||
FormClass, _ = uic.loadUiType(ui_path) | ||
|
||
|
||
class PlanRegulationGroupWidget(QWidget, FormClass): # type: ignore | ||
"""A widget representation of a plan regulation group.""" | ||
|
||
delete_signal = pyqtSignal(QWidget) | ||
|
||
def __init__(self, feature: Feature): | ||
super().__init__() | ||
self.setupUi(self) | ||
|
||
# TYPES | ||
self.frame: QFrame | ||
self.heading: QLineEdit | ||
self.del_btn: QPushButton | ||
|
||
# INIT | ||
self.feature = feature | ||
self.layer = self.feature.layer # Should be plan_regulation_group layer | ||
|
||
self.init_buttons() | ||
self.set_group_heading() | ||
self.add_plan_regulation_widgets() | ||
|
||
def request_delete(self): | ||
self.delete_signal.emit(self) | ||
|
||
def init_buttons(self): | ||
self.del_btn.setIcon(QgsApplication.getThemeIcon("mActionDeleteSelected.svg")) | ||
self.del_btn.clicked.connect(self.request_delete) | ||
|
||
def set_group_heading(self): | ||
for attribute_config in self.feature.attributes: | ||
if attribute_config.attribute == "name": | ||
self.heading.setText(attribute_config.display()) | ||
|
||
def add_plan_regulation_widgets(self): | ||
if self.feature.child_features is not None: | ||
for child in self.feature.child_features: | ||
if child.layer == "plan_requlation": | ||
self.add_plan_regulation_widget(child) | ||
|
||
def add_plan_regulation_widget(self, plan_regulation_feature: Feature): | ||
plan_regulation_widget = PlanRegulationWidget(plan_regulation_feature) | ||
self.frame.layout().addWidget(plan_regulation_widget) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>plan_regulation_group_form</class> | ||
<widget class="QWidget" name="plan_regulation_group_form"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>514</width> | ||
<height>65</height> | ||
</rect> | ||
</property> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<item> | ||
<widget class="QFrame" name="frame"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="frameShape"> | ||
<enum>QFrame::StyledPanel</enum> | ||
</property> | ||
<property name="frameShadow"> | ||
<enum>QFrame::Raised</enum> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QLineEdit" name="heading"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="del_btn"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>30</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
196 changes: 196 additions & 0 deletions
196
arho_feature_template/gui/plan_regulation_group_widget_old.ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>plan_regulation_group_form</class> | ||
<widget class="QWidget" name="plan_regulation_group_form"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>582</width> | ||
<height>195</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="plan_regulation_group_heading_layout"> | ||
<item> | ||
<widget class="QLabel" name="heading_label"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="text"> | ||
<string>Otsikko:</string> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLineEdit" name="heading"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="conf_btn"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>30</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="del_btn"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>30</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<property name="text"> | ||
<string/> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="plan_regulation_group_heading_spacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeType"> | ||
<enum>QSizePolicy::Maximum</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<layout class="QHBoxLayout" name="plan_regulation_group_contents_layout"> | ||
<item> | ||
<spacer name="plan_regulation_groupbox_spacer1"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeType"> | ||
<enum>QSizePolicy::Fixed</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>20</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QgsCollapsibleGroupBox" name="plan_regulation_groupbox"> | ||
<property name="title"> | ||
<string/> | ||
</property> | ||
<property name="flat"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="checkable"> | ||
<bool>false</bool> | ||
</property> | ||
<layout class="QHBoxLayout" name="horizontalLayout_4"> | ||
<item> | ||
<layout class="QGridLayout" name="plan_regulation_grid_layout"> | ||
<item row="0" column="0"> | ||
<widget class="QLabel" name="plan_regulation_label"> | ||
<property name="sizePolicy"> | ||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred"> | ||
<horstretch>0</horstretch> | ||
<verstretch>0</verstretch> | ||
</sizepolicy> | ||
</property> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>175</width> | ||
<height>0</height> | ||
</size> | ||
</property> | ||
<property name="maximumSize"> | ||
<size> | ||
<width>175</width> | ||
<height>16777215</height> | ||
</size> | ||
</property> | ||
<property name="font"> | ||
<font> | ||
<weight>75</weight> | ||
<bold>true</bold> | ||
</font> | ||
</property> | ||
<property name="text"> | ||
<string>Kaavamääräyslaji</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<spacer name="plan_regulation_groupbox_spacer2"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>0</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</widget> | ||
<customwidgets> | ||
<customwidget> | ||
<class>QgsCollapsibleGroupBox</class> | ||
<extends>QGroupBox</extends> | ||
<header>qgscollapsiblegroupbox.h</header> | ||
<container>1</container> | ||
</customwidget> | ||
</customwidgets> | ||
<resources/> | ||
<connections/> | ||
</ui> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that its a common practice to define the types in the class section as following:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used to do it like this too, until at some point VSCode stopped recognizing this sort of typing for me... If it is an editor bug, I will look into it more