示例#1
0
文件: layout_utils.py 项目: gltn/stdm
    def load_template_into_layout(layout: QgsLayout, file_path: str):
        """
        Loads a document template into the view and updates the necessary STDM-related composer items.
        """
        copy_file = file_path.replace('sdt', 'cpy')

        # remove existing copy file
        if QFile.exists(copy_file):
            copy_template = QFile(copy_file)
            copy_template.remove()

        orig_template_file = QFile(file_path)

        layout.setCustomProperty('variable_template_path', file_path)

        # make a copy of the original
        orig_template_file.copy(copy_file)

        # work with copy
        template_file = QFile(copy_file)

        if not template_file.open(QIODevice.ReadOnly):
            raise IOError(template_file.errorString())

        template_doc = QDomDocument()
        if template_doc.setContent(template_file):
            # First load vector layers for the table definitions in the config
            # collection before loading the composition from file.

            #  table_config_collection = TableConfigurationCollection.create(template_doc)

            # Load items into the composition and configure STDM data controls
            context = QgsReadWriteContext()
            try:
                layout.loadFromTemplate(template_doc, context)
            except:
                pass

            LayoutUtils.sync_ids_with_uuids(layout)

        template_file.close()
示例#2
0
文件: layout_utils.py 项目: gltn/stdm
 def set_stdm_data_category_for_layout(layout: QgsLayout,
                                       category: Optional[str]):
     layout.setCustomProperty(LayoutUtils.DATA_CATEGORY_PROPERTY, category)
示例#3
0
文件: layout_utils.py 项目: gltn/stdm
 def set_stdm_referenced_table_for_layout(layout: QgsLayout,
                                          table: Optional[str]):
     layout.setCustomProperty(LayoutUtils.REFERENCED_TABLE_PROPERTY, table)
示例#4
0
文件: layout_utils.py 项目: gltn/stdm
 def set_stdm_data_source_for_layout(layout: QgsLayout,
                                     source: Optional[str]):
     layout.setCustomProperty(LayoutUtils.DATA_SOURCE_PROPERTY, source)