Skip to content

Map repeat item widget

Widget for the custom CPLUS layout map item.

CplusMapLayoutItemGuiMetadata

CplusMapLayoutItemGuiMetadata()

Bases: QgsLayoutItemAbstractGuiMetadata

GUI metadata for a CPLUS map layout item.

Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def __init__(self):
    super().__init__(CPLUS_MAP_REPEAT_ITEM_TYPE, CPLUS_ITEM_NAME)

createItem

createItem(layout)

Factory override that returns the map item.

Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def createItem(self, layout) -> QgsLayoutItem:
    """Factory override that returns the map item."""
    return CplusMapRepeatItem(layout)

createItemWidget

createItemWidget(item)

Factory override for the item widget.

Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def createItemWidget(self, item) -> QtWidgets.QWidget:
    """Factory override for the item widget."""
    return CplusMapRepeatItemWidget(None, item)

creationIcon

creationIcon()

Factory override for item icon.

Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def creationIcon(self) -> QtGui.QIcon:
    """Factory override for item icon."""
    return FileUtils.get_icon("mLayoutItemMap_cplus_add.svg")

newItemAddedToLayout

newItemAddedToLayout(map_repeat_item)

Define action that is called when the CplusMapItem is added to a layout through the GUI.

Parameters:

Name Type Description Default
map_repeat_item CplusMapRepeatItem

Map repeat item to be added to the layout.

required
Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def newItemAddedToLayout(self, map_repeat_item: CplusMapRepeatItem):
    """Define action that is called when the CplusMapItem
    is added to a layout through the GUI.

    :param map_repeat_item: Map repeat item to be added to the layout.
    :type map_repeat_item: CplusMapRepeatItem
    """
    items = map_repeat_item.layout().items()
    counter = 1
    for item in items:
        if isinstance(item, CplusMapRepeatItem):
            counter += 1

    # Set frame properties
    map_repeat_item.setFrameEnabled(True)
    map_repeat_item.setFrameJoinStyle(QtCore.Qt.MiterJoin)
    map_repeat_item.setFrameStrokeColor(QtGui.QColor(132, 192, 68))
    map_repeat_item.setFrameStrokeWidth(QgsLayoutMeasurement(0.4))

    map_repeat_item.setId(f"{CPLUS_ITEM_NAME} {counter!s}")

visibleName

visibleName()

Override for user-visible name identifying the item.

Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def visibleName(self) -> str:
    """Override for user-visible name identifying the item."""
    return CPLUS_ITEM_NAME

CplusMapRepeatItemWidget

CplusMapRepeatItemWidget(parent, layout_object)

Bases: QgsLayoutItemBaseWidget, WidgetUi

Widget for configuring the CPLUS layout map repeat item.

Source code in src/cplus_plugin/gui/map_repeat_item_widget.py
def __init__(self, parent, layout_object: CplusMapRepeatItem):
    super().__init__(parent, layout_object)
    self.setupUi(self)

    self._map_item = layout_object

    # Common item properties widget
    self._prop_widget = QgsLayoutItemPropertiesWidget(self, layout_object)
    self.layout.addWidget(self._prop_widget, 2, 0, 1, 2)

    self.cbo_map_type.addItem(
        self.tr("Activity"),
        ModelComponentType.ACTIVITY.value,
    )

Last update: October 2, 2024
Back to top