Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b8e9b43

Browse files
committedNov 13, 2024·
Set active_plan_id in update_selected_plan-function instead.
- Move setting active_plan_id to update_selected_plan() - Removed "Vahvista kaava" button for now, it will be created properly later. - Removed settings button from toolbar.
1 parent 8b7d6d6 commit b8e9b43

File tree

3 files changed

+3
-26
lines changed

3 files changed

+3
-26
lines changed
 

‎arho_feature_template/core/plan_manager.py

-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def feature_added(self):
6464
new_feature = self.kaava_layer.getFeature(new_feature_id)
6565
if new_feature.isValid():
6666
feature_id_value = new_feature["id"]
67-
QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), "active_plan_id", feature_id_value)
6867
update_selected_plan(LandUsePlan(feature_id_value))
6968
else:
7069
iface.messageBar().pushMessage("Error", "Invalid feature retrieved.", level=3)
@@ -93,7 +92,6 @@ def load_land_use_plan(self):
9392
return
9493

9594
plan = LandUsePlan(selected_plan_id)
96-
QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), "active_plan_id", selected_plan_id)
9795
update_selected_plan(plan)
9896

9997
def clear_all_filters(self):

‎arho_feature_template/core/update_plan.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from dataclasses import dataclass
22

3-
from qgis.core import QgsMapLayer, QgsProject, QgsVectorLayer
3+
from qgis.core import QgsExpressionContextUtils, QgsMapLayer, QgsProject, QgsVectorLayer
44
from qgis.utils import iface
55

66

@@ -24,6 +24,7 @@ class LandUsePlan:
2424
def update_selected_plan(new_plan: LandUsePlan):
2525
"""Update the project layers based on the selected land use plan."""
2626
plan_id = new_plan.id
27+
QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), "active_plan_id", plan_id)
2728

2829
for layer_name, field_name in LAYER_PLAN_ID_MAP.items():
2930
# Set the filter on each layer using the plan_id

‎arho_feature_template/plugin.py

+1-23
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from qgis.PyQt.QtCore import QCoreApplication, Qt, QTranslator
66
from qgis.PyQt.QtGui import QIcon
7-
from qgis.PyQt.QtWidgets import QAction, QMessageBox, QWidget
7+
from qgis.PyQt.QtWidgets import QAction, QWidget
88
from qgis.utils import iface
99

1010
from arho_feature_template.core.feature_template_library import FeatureTemplater, TemplateGeometryDigitizeMapTool
@@ -13,7 +13,6 @@
1313
from arho_feature_template.qgis_plugin_tools.tools.custom_logging import setup_logger, teardown_logger
1414
from arho_feature_template.qgis_plugin_tools.tools.i18n import setup_translation
1515
from arho_feature_template.qgis_plugin_tools.tools.resources import plugin_name
16-
from arho_feature_template.utils.misc_utils import get_active_plan_id, get_lambda_settings
1716

1817
if TYPE_CHECKING:
1918
from qgis.gui import QgisInterface, QgsMapTool
@@ -164,15 +163,6 @@ def initGui(self) -> None: # noqa N802
164163
add_to_toolbar=True,
165164
)
166165

167-
self.validate_plan_action = self.add_action(
168-
"",
169-
text="Vahvista kaava",
170-
triggered_callback=self.validate_plan,
171-
add_to_menu=True,
172-
add_to_toolbar=True,
173-
status_tip="Vahvista kaava",
174-
)
175-
176166
self.plugin_settings_action = self.add_action(
177167
"",
178168
text="Asetukset",
@@ -192,18 +182,6 @@ def add_new_plan(self):
192182
def load_existing_land_use_plan(self):
193183
self.plan_manager.load_land_use_plan()
194184

195-
def validate_plan(self):
196-
"""Validate the plan."""
197-
lambda_host, lambda_port = get_lambda_settings()
198-
active_plan = get_active_plan_id()
199-
200-
# Testing.
201-
QMessageBox.information(
202-
None,
203-
"Lambda asetukset",
204-
f"Lambdan isäntä: {lambda_host}\nLambdan portti: {lambda_port}\nAktiivinen kaava: {active_plan}",
205-
)
206-
207185
def open_settings(self):
208186
"""Open the plugin settings dialog."""
209187
settings = PluginSettings()

0 commit comments

Comments
 (0)
Please sign in to comment.