File tree 3 files changed +17
-4
lines changed
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 1
- from qgis .core import QgsProject , QgsVectorLayer
1
+ from qgis .core import QgsExpressionContextUtils , QgsProject , QgsVectorLayer
2
2
from qgis .PyQt .QtWidgets import QDialog , QMessageBox
3
3
from qgis .utils import iface
4
4
@@ -64,6 +64,7 @@ def feature_added(self):
64
64
new_feature = self .kaava_layer .getFeature (new_feature_id )
65
65
if new_feature .isValid ():
66
66
feature_id_value = new_feature ["id" ]
67
+ QgsExpressionContextUtils .setProjectVariable (QgsProject .instance (), "active_plan_id" , feature_id_value )
67
68
update_selected_plan (LandUsePlan (feature_id_value ))
68
69
else :
69
70
iface .messageBar ().pushMessage ("Error" , "Invalid feature retrieved." , level = 3 )
@@ -92,6 +93,7 @@ def load_land_use_plan(self):
92
93
return
93
94
94
95
plan = LandUsePlan (selected_plan_id )
96
+ QgsExpressionContextUtils .setProjectVariable (QgsProject .instance (), "active_plan_id" , selected_plan_id )
95
97
update_selected_plan (plan )
96
98
97
99
def clear_all_filters (self ):
Original file line number Diff line number Diff line change 15
15
from arho_feature_template .qgis_plugin_tools .tools .resources import plugin_name
16
16
17
17
# from arho_feature_template.utils.misc_utils import get_lambda_address, get_lambda_settings
18
- from arho_feature_template .utils .misc_utils import get_lambda_settings
18
+ from arho_feature_template .utils .misc_utils import get_active_plan_id , get_lambda_settings
19
19
20
20
if TYPE_CHECKING :
21
21
from qgis .gui import QgisInterface , QgsMapTool
@@ -197,9 +197,14 @@ def load_existing_land_use_plan(self):
197
197
def validate_plan (self ):
198
198
"""Validate the plan."""
199
199
lambda_host , lambda_port = get_lambda_settings ()
200
+ active_plan = get_active_plan_id ()
200
201
201
202
# Testing.
202
- QMessageBox .information (None , "Lambda Settings" , f"Lambda Host: { lambda_host } \n Lambda Port: { lambda_port } " )
203
+ QMessageBox .information (
204
+ None ,
205
+ "Lambda asetukset" ,
206
+ f"Lambdan isäntä: { lambda_host } \n Lambdan portti: { lambda_port } \n Aktiivinen kaava: { active_plan } " ,
207
+ )
203
208
# print(f"Hard Coded Lambda Host: {hc_lambda_host}")
204
209
# print(f"Hard Coded Lambda Port: {hc_lambda_port}")
205
210
Original file line number Diff line number Diff line change 1
1
import os
2
2
3
- from qgis .core import QgsProject , QgsVectorLayer
3
+ from qgis .core import QgsExpressionContextUtils , QgsProject , QgsVectorLayer
4
4
from qgis .PyQt .QtCore import QSettings
5
5
from qgis .PyQt .QtWidgets import QMessageBox
6
6
@@ -60,6 +60,12 @@ def handle_unsaved_changes() -> bool:
60
60
return True
61
61
62
62
63
+ def get_active_plan_id ():
64
+ """Retrieve the active plan ID stored as a project variable."""
65
+ # return QgsExpressionContextUtils.projectScope(QgsProject.instance(), "active_plan_id")
66
+ return QgsExpressionContextUtils .projectScope (QgsProject .instance ()).variable ("active_plan_id" )
67
+
68
+
63
69
def get_lambda_settings ():
64
70
"""Retrieve Lambda settings, using defaults if not set."""
65
71
settings = QSettings ("ArhoFeatureTemplate" )
You can’t perform that action at this time.
0 commit comments