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

UsabILItyHub: Store optimize strategy in Project Variable #81

Merged
merged 4 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modelbaker/dataobjects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ def create(

self.load_layouts(qgis_project)

self.store_project_variables(qgis_project)

if path:
qgis_project.write(path)

Expand Down Expand Up @@ -371,6 +373,11 @@ def load_mapthemes(self, qgis_project):

qgis_project.mapThemeCollection().insert(name, map_theme_record)

def store_project_variables(self, qgis_project):
QgsExpressionContextUtils.setProjectVariable(
qgis_project, "optimize_strategy", self.optimize_strategy.name
)

def post_generate(self):
for layer in self.layers:
layer.post_generate(self)
14 changes: 13 additions & 1 deletion modelbaker/ilitoppingmaker/iliprojecttopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""


from qgis.core import Qgis, QgsProject
from qgis.core import Qgis, QgsExpressionContextUtils, QgsProject

from ..libs.toppingmaker import ExportSettings, ProjectTopping
from .ilidata import IliData
Expand Down Expand Up @@ -82,6 +82,9 @@ def makeit(self, project: QgsProject = None):
return False
# Creates and sets the project_topping considering the passed QgsProject and the existing ExportSettings.
self.parse_project(project, self.export_settings)

self.append_iliproperties(project)

# Generate topping files (layertree and depending files like style etc) considering existing ProjectTopping and Target.
projecttopping_id = self.generate_files(self.target)

Expand All @@ -102,3 +105,12 @@ def makeit(self, project: QgsProject = None):
)

return ilidata_path

def append_iliproperties(self, project):
# append ilispecific properties like the optimize_strategy to the properties object
optimize_strategy = QgsExpressionContextUtils.projectScope(project).variable(
"optimize_strategy"
)

if optimize_strategy:
self.properties["ili_optimize_strategy"] = optimize_strategy
2 changes: 1 addition & 1 deletion scripts/package_pip_packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ LIBS_DIR="modelbaker/libs"

DEPRECATION=("deprecation" "2.1.0")
PGSERVICEPARSER=("pgserviceparser" "1.1.0")
TOPPINGMAKER=("toppingmaker" "1.2.5")
TOPPINGMAKER=("toppingmaker" "1.3.0")

PACKAGES=(
DEPRECATION[@]
Expand Down
Loading