diff --git a/tests/test_toppingmaker.py b/tests/test_toppingmaker.py index 4beec2d..aea0d09 100644 --- a/tests/test_toppingmaker.py +++ b/tests/test_toppingmaker.py @@ -422,6 +422,15 @@ def test_generate_files(self): assert foundFirstVariable assert foundVariableWithStructure + # check transaction mode + with open(projecttopping_file_path, "r") as yamlfile: + projecttopping_data = yaml.safe_load(yamlfile) + assert "properties" in projecttopping_data + if Qgis.QGIS_VERSION_INT < 32600: + assert projecttopping_data["properties"]["transaction_mode"] == True + else: + assert projecttopping_data["properties"]["transaction_mode"] == "AutomaticGroups" + # check layouts layout_count = 0 foundLayoutOne = False @@ -706,6 +715,13 @@ def _make_project_and_export_settings(self): layout.setName("Layout Three") project.layoutManager().addLayout(layout) + # set transaction mode + if Qgis.QGIS_VERSION_INT < 32600: + project.setAutoTransaction(True) + else: + project.setTransactionMode(Qgis.TransactionMode.AutomaticGroups) + + # --- # and make the export settings # --- diff --git a/toppingmaker/projecttopping.py b/toppingmaker/projecttopping.py index 1566e43..e8bf59f 100644 --- a/toppingmaker/projecttopping.py +++ b/toppingmaker/projecttopping.py @@ -50,6 +50,7 @@ class ProjectTopping(QObject): - layerorder - map themes - project variables + - project properties - print layouts QML style files, QLR layer definition files and the source of a layer can be linked in the YAML file and are exported to the specific folders. @@ -428,6 +429,23 @@ def make_items( ).variable(variable_key) self[variable_key] = variable_value or None + class Properties(dict): + """ + A dict object of dict items describing a selection of projet properties + Currently we don't use export settings and export them per default. + """ + + def make_items( + self, + project: QgsProject + ): + self.clear() + transaction_mode = None + if Qgis.QGIS_VERSION_INT < 32600: + transaction_mode = project.autoTransaction() + else: + transaction_mode = project.transactionMode() + class Layouts(dict): """ A dict object of dict items describing a layout with templatefile according to the layout names listed in the ExportSettings passed on parsing the QGIS project. @@ -496,6 +514,7 @@ def __init__(self): self.mapthemes = self.MapThemes() self.layerorder = [] self.variables = self.Variables() + self.properties = self.Properties() self.layouts = self.Layouts(temporary_toppingfile_dir) def parse_project( @@ -528,6 +547,8 @@ def parse_project( self.variables.make_items(project, export_settings) # make print layouts self.layouts.make_items(project, export_settings) + # make properties + self.properties.make_items(project, export_settings) self.stdout.emit( self.tr("QGIS project map themes parsed with export settings."), @@ -586,6 +607,7 @@ def _projecttopping_dict(self, target: Target): Gets the layerorder as a list. Gets the mapthemes as a dict. Gets the variables as a dict. + Gets the properties as a dict. Gets the layouts as a dict. And it generates and stores the toppingfiles according th the Target. """ @@ -599,6 +621,9 @@ def _projecttopping_dict(self, target: Target): variables_dict = dict(self.variables) if variables_dict: projecttopping_dict["variables"] = variables_dict + properties_dict = dict(self.properties) + if properties_dict: + projecttopping_dict["properties"] = properties_dict layouts_item_dict = self.layouts.item_dict(target) if layouts_item_dict: projecttopping_dict["layouts"] = layouts_item_dict