Source code for radioviz.controllers.image_metadata_window_controller
# Copyright 2026 European Union
# Author: Bulgheroni Antonio (antonio.bulgheroni@ec.europa.eu)
# SPDX-License-Identifier: EUPL-1.2
"""
Controller for displaying image metadata in a dedicated window.
This module defines the :class:`ImageMetadataWindowController` which owns
metadata extracted from an image and exposes read-only entries suitable
for display in a metadata window view.
"""
from __future__ import annotations
from typing import Any
from radioviz.controllers.sub_window_controller import SubWindowController, SubWindowEnum
from radioviz.models.data_model import DataOrigin, DataSource, DataStorage
from radioviz.services.tiff_metadata import metadata_entries
from radioviz.views.image_metadata_window import ImageMetadataWindow
[docs]
class ImageMetadataWindowController(SubWindowController[ImageMetadataWindow]):
"""
Controller for a read-only metadata window.
This controller owns the metadata data structure and provides formatted
entries for display. It is intentionally read-only and does not support
save or export operations.
"""
# Used for UI enablement; window instantiation is handled by WindowFactory.
sub_window_type = SubWindowEnum.MetadataWindow
def __init__(self, source: DataSource, metadata: dict[str, Any], title: str):
"""
Initialize the metadata window controller.
:param source: Data source describing the metadata origin.
:type source: DataSource
:param metadata: Metadata dictionary to display.
:type metadata: dict[str, Any]
:param title: Window title for the metadata view.
:type title: str
"""
super().__init__(source=source, storage=DataStorage(path=None), view=None)
self.metadata = metadata
self.name = title
[docs]
def metadata_items(self) -> list[tuple[str, str, str]]:
"""
Provide formatted metadata items for display.
:return: List of tag/name/value tuples representing metadata entries.
:rtype: list[tuple[str, str, str]]
"""
return metadata_entries(self.metadata)
[docs]
def build_metadata_source(label: str, parent: DataSource | None) -> DataSource:
"""
Build a data source describing metadata derived from an image.
:param label: Display label for the metadata source.
:type label: str
:param parent: Parent data source, if any.
:type parent: DataSource | None
:return: Constructed data source.
:rtype: DataSource
"""
return DataSource(label=label, origin=DataOrigin.DERIVED, parent=parent)