@@ -101,8 +101,7 @@ def __init__(self):
101
101
self .regulation_groups_dock .new_regulation_group_requested .connect (self .create_new_regulation_group )
102
102
self .regulation_groups_dock .edit_regulation_group_requested .connect (self .edit_regulation_group )
103
103
self .regulation_groups_dock .delete_regulation_group_requested .connect (self .delete_regulation_group )
104
- if get_active_plan_id ():
105
- self .regulation_groups_dock .initialize_regulation_groups (regulation_group_library_from_active_plan ())
104
+ self .update_active_plan_regulation_group_library ()
106
105
self .regulation_groups_dock .hide ()
107
106
108
107
# Initialize digitize tools
@@ -153,6 +152,10 @@ def initialize_libraries(self):
153
152
]
154
153
self .new_feature_dock .initialize_feature_template_libraries (self .feature_template_libraries )
155
154
155
+ def update_active_plan_regulation_group_library (self ):
156
+ self .active_plan_regulation_group_library = regulation_group_library_from_active_plan ()
157
+ self .regulation_groups_dock .update_regulation_groups (self .active_plan_regulation_group_library )
158
+
156
159
def create_new_regulation_group (self ):
157
160
self ._open_regulation_group_form (RegulationGroup ())
158
161
@@ -166,11 +169,11 @@ def _open_regulation_group_form(self, regulation_group: RegulationGroup):
166
169
save_regulation_group_as_config (regulation_group_form .model )
167
170
else :
168
171
save_regulation_group (regulation_group_form .model )
169
- self .regulation_groups_dock . initialize_regulation_groups ( regulation_group_library_from_active_plan () )
172
+ self .update_active_plan_regulation_group_library ( )
170
173
171
174
def delete_regulation_group (self , group : RegulationGroup ):
172
175
delete_regulation_group (group )
173
- self .regulation_groups_dock . initialize_regulation_groups ( regulation_group_library_from_active_plan () )
176
+ self .update_active_plan_regulation_group_library ( )
174
177
175
178
def toggle_identify_plan_features (self , activate : bool ): # noqa: FBT001
176
179
if activate :
@@ -238,7 +241,7 @@ def edit_plan(self):
238
241
attribute_form = PlanAttributeForm (plan_model , self .regulation_group_libraries )
239
242
if attribute_form .exec_ ():
240
243
feature = save_plan (attribute_form .model )
241
- self .regulation_groups_dock . initialize_regulation_groups ( regulation_group_library_from_active_plan () )
244
+ self .update_active_plan_regulation_group_library ( )
242
245
243
246
def add_new_plan_feature (self ):
244
247
if not handle_unsaved_changes ():
@@ -294,11 +297,11 @@ def _plan_feature_geom_digitized(self, feature: QgsFeature):
294
297
295
298
plan_feature .geom = feature .geometry ()
296
299
attribute_form = PlanFeatureForm (
297
- plan_feature , title , [* self .regulation_group_libraries , regulation_group_library_from_active_plan () ]
300
+ plan_feature , title , [* self .regulation_group_libraries , self . active_plan_regulation_group_library ]
298
301
)
299
302
if attribute_form .exec_ ():
300
303
save_plan_feature (attribute_form .model )
301
- self .regulation_groups_dock . initialize_regulation_groups ( regulation_group_library_from_active_plan () )
304
+ self .update_active_plan_regulation_group_library ( )
302
305
303
306
def edit_plan_feature (self , feature : QgsFeature , layer_name : str ):
304
307
layer_class = FEATURE_LAYER_NAME_TO_CLASS_MAP [layer_name ]
@@ -307,11 +310,11 @@ def edit_plan_feature(self, feature: QgsFeature, layer_name: str):
307
310
# Geom editing handled with basic QGIS vertex editing?
308
311
title = plan_feature .name if plan_feature .name else layer_name
309
312
attribute_form = PlanFeatureForm (
310
- plan_feature , title , [* self .regulation_group_libraries , regulation_group_library_from_active_plan () ]
313
+ plan_feature , title , [* self .regulation_group_libraries , self . active_plan_regulation_group_library ]
311
314
)
312
315
if attribute_form .exec_ ():
313
316
save_plan_feature (attribute_form .model )
314
- self .regulation_groups_dock . initialize_regulation_groups ( regulation_group_library_from_active_plan () )
317
+ self .update_active_plan_regulation_group_library ( )
315
318
316
319
def set_active_plan (self , plan_id : str | None ):
317
320
"""Update the project layers based on the selected land use plan.
@@ -336,8 +339,7 @@ def set_active_plan(self, plan_id: str | None):
336
339
if previously_in_edit_mode :
337
340
plan_layer .startEditing ()
338
341
339
- # Update regulation group dock
340
- self .regulation_groups_dock .initialize_regulation_groups (regulation_group_library_from_active_plan ())
342
+ self .update_active_plan_regulation_group_library ()
341
343
342
344
def load_land_use_plan (self ):
343
345
"""Load an existing land use plan using a dialog selection."""
@@ -440,6 +442,11 @@ def unload(self):
440
442
441
443
442
444
def regulation_group_library_from_active_plan () -> RegulationGroupLibrary :
445
+ if not get_active_plan_id ():
446
+ return RegulationGroupLibrary (
447
+ name = "Käytössä olevat kaavamääräysryhmät" , version = None , description = None , regulation_group_categories = []
448
+ )
449
+
443
450
id_of_general_regulation_group_type = PlanRegulationGroupTypeLayer .get_attribute_value_by_another_attribute_value (
444
451
"id" , "value" , "generalRegulations"
445
452
)
0 commit comments