Esempio n. 1
0
    def __init__(self, parent, layout_object):
        super().__init__(parent, layout_object)

        label = LayoutGuiUtils.create_heading_label(
            QCoreApplication.translate('StdmItems', 'STDM Item Properties'))

        vl = QVBoxLayout()
        vl.setContentsMargins(0, 0, 0, 0)
        vl.addWidget(label)

        field_selector = ComposerFieldSelector(layout_object)
        field_selector.selectFieldName(layout_object.linked_field())
        vl.addWidget(field_selector)

        self.base_widget = LayoutGuiUtils.create_standard_item_widget(
            layout_object, QgsLayoutItemRegistry.LayoutLabel)
        expression_button = self.base_widget.findChild(
            QWidget, 'mInsertExpressionButton')
        if expression_button is not None:
            expression_button.setVisible(False)

        self.connectChildPanel(self.base_widget)
        vl.addWidget(self.base_widget)

        self.setLayout(vl)
Esempio n. 2
0
    def __init__(self, parent, layout_object):
        super().__init__(parent, layout_object)
        label = LayoutGuiUtils.create_heading_label(
            QCoreApplication.translate('StdmItems', 'STDM Item Properties'))

        vl = QVBoxLayout()
        vl.setContentsMargins(0, 0, 0, 0)
        vl.addWidget(label)

        self.data_source_editor = ComposerQREditor(layout_object)
        self.data_source_editor.selectFieldName(layout_object.linked_field())
        vl.addWidget(self.data_source_editor)

        self.base_widget = LayoutGuiUtils.create_standard_item_widget(
            layout_object, QgsLayoutItemRegistry.LayoutPicture)

        for name in ('mSVGFrame', 'mRotationGroupBox', 'mSVGParamsGroupBox',
                     'mRadioSVG', 'mRadioRaster', 'mRasterFrame',
                     'mPreviewGroupBox'):
            widget = self.base_widget.findChild(QWidget, name)
            if widget is not None:
                widget.setVisible(False)

        self.connectChildPanel(self.base_widget)
        vl.addWidget(self.base_widget)

        self.setLayout(vl)

        self.data_source_editor.changed.connect(self._item_changed)
Esempio n. 3
0
    def __init__(self, parent, layout_object):
        super().__init__(parent, layout_object)

        label = LayoutGuiUtils.create_heading_label(
            QCoreApplication.translate('StdmItems', 'STDM Item Properties'))

        vl = QVBoxLayout()
        vl.setContentsMargins(0, 0, 0, 0)
        vl.addWidget(label)

        self.source_editor = ComposerTableDataSourceEditor(layout_object)
        vl.addWidget(self.source_editor)

        self.base_widget = LayoutGuiUtils.create_standard_item_widget(
            layout_object, QgsLayoutItemRegistry.LayoutAttributeTable)

        for name in ('mRefreshPushButton'):
            widget = self.base_widget.findChild(QWidget, name)
            if widget is not None:
                widget.setVisible(False)

        self.connectChildPanel(self.base_widget)
        vl.addWidget(self.base_widget)

        self.setLayout(vl)
Esempio n. 4
0
    def __init__(self, parent, layout_object):
        super().__init__(parent, layout_object)

        label = LayoutGuiUtils.create_heading_label(
            QCoreApplication.translate('StdmItems', 'STDM Item Properties'))

        vl = QVBoxLayout()
        vl.setContentsMargins(0, 0, 0, 0)
        vl.addWidget(label)

        self.symbol_editor = ComposerSymbolEditor(layout_object)
        vl.addWidget(self.symbol_editor)

        self.base_widget = LayoutGuiUtils.create_standard_item_widget(
            layout_object, QgsLayoutItemRegistry.LayoutMap)

        self.connectChildPanel(self.base_widget)
        vl.addWidget(self.base_widget)

        self.setLayout(vl)
Esempio n. 5
0
    def __init__(self, parent, layout_object):
        super().__init__(parent, layout_object)

        label = LayoutGuiUtils.create_heading_label(
            QCoreApplication.translate('StdmItems', 'STDM Item Properties'))

        vl = QVBoxLayout()
        vl.setContentsMargins(0, 0, 0, 0)
        vl.addWidget(label)

        self.base_widget = LayoutGuiUtils.create_standard_item_widget(
            layout_object, QgsLayoutItemRegistry.LayoutPolyline)

        arrow_group = self.base_widget.findChild(QWidget,
                                                 'mArrowMarkersGroupBox')
        if arrow_group is not None:
            arrow_group.setVisible(False)

        self.connectChildPanel(self.base_widget)
        vl.addWidget(self.base_widget)

        self.setLayout(vl)
Esempio n. 6
0
    def create_new_document_designer(self, file_path):
        """
        Creates a new document designer and loads the document template
        defined in file path.
        :param file_path: Path to document template
        :type file_path: str
        """
        if not QFile.exists(file_path):
            QMessageBox.critical(
                self.mainWindow(),
                QApplication.translate("OpenTemplateConfig",
                                       "Open Template Error"),
                QApplication.translate(
                    "OpenTemplateConfig",
                    "The specified template does not exist."))
            return

        if not [
                i for i in self.composition().items() if isinstance(
                    i, QgsLayoutItem) and not isinstance(i, QgsLayoutItemPage)
        ]:
            self.mainWindow().close()

        layout = LayoutGuiUtils.create_unique_named_layout()
        layout.initializeDefaults()

        # Load template
        try:
            self.composition().setCustomProperty('variable_template_path',
                                                 file_path)
            self.variable_template_path = file_path
            LayoutUtils.load_template_into_layout(layout, file_path)
        except IOError as e:
            QMessageBox.critical(
                self.mainWindow(),
                QApplication.translate("ComposerWrapper",
                                       "Open Operation Error"),
                "{0}\n{1}".format(
                    QApplication.translate("ComposerWrapper",
                                           "Cannot read template file."),
                    str(e)))

        self._iface.openLayoutDesigner(layout)