RTC Toolkit 6.1.0-pre1
Loading...
Searching...
No Matches
gui.metadata_model.MetadataModel Class Reference

Qt table model for MetadataEdit widget, for displaying and editing metadata entries. More...

Inheritance diagram for gui.metadata_model.MetadataModel:

Classes

class  EditError
 Error codes returned when editing metadata fails. More...
 

Public Member Functions

 __init__ (self, dict|None data=None)
 
 data (self, index, role=...)
 Returns the data for the specified model index and Qt item role.
 
 setData (self, index, value, role=...)
 Updates a metadata entry with the provided value.
 
 rowCount (self, parent=QModelIndex())
 Returns the number of rows in the metadata table.
 
 columnCount (self, parent=QModelIndex())
 Returns number of columns.
 
 headerData (self, section, orientation, role=...)
 Returns the header string for display for a specific column.
 
 flags (self, index)
 Returns the flags applicable for a particular table cell based on index.
 
dict|None get_metadata (self)
 Returns the current metadata.
 
 set_metadata (self, dict|None new_metadata)
 Replaces the current metadata.
 
bool try_insert_empty_row (self)
 Inserts a temporary empty row for adding a new metadata entry.
 
bool try_delete_row (self, QModelIndex index)
 Deletes the metadata entry at the given table row.
 

Static Public Member Functions

bool shape_matches_type (RtcVectorUInt64 shape, type rtc_type)
 Checks whether a shape is compatible with the specified RTC type.
 

Static Public Attributes

 editError
 

Protected Member Functions

 _key_at (self, QModelIndex index)
 Returns the metadata key for the specified table row.
 

Protected Attributes

dict _data = None
 
 _deleted_keys = set()
 
list _headers = ["Name", "Data Type", "Value"]
 
dict _read_only_entries = {"sequence_id"}
 
dict _fixed_type_entries = {"type", "shape", "symlink_target", "timestamp"}
 

Static Protected Attributes

str _NEW_ROW_KEY
 

Detailed Description

Qt table model for MetadataEdit widget, for displaying and editing metadata entries.

Provides access to metadata key-value pairs, supports adding and removing entries, and reports editing failures through the editError signal.

Constructor & Destructor Documentation

◆ __init__()

gui.metadata_model.MetadataModel.__init__ ( self,
dict | None data = None )

Member Function Documentation

◆ _key_at()

gui.metadata_model.MetadataModel._key_at ( self,
QModelIndex index )
protected

Returns the metadata key for the specified table row.

Returns None if no metadata is available.

◆ columnCount()

gui.metadata_model.MetadataModel.columnCount ( self,
parent = QModelIndex() )

Returns number of columns.

Metadata table has always exactly 3 columns.

◆ data()

gui.metadata_model.MetadataModel.data ( self,
index,
role = ... )

Returns the data for the specified model index and Qt item role.

The returned value depends on both the requested role and the table column:

- DisplayRole
  • Column 0: Metadata key.
  • Column 1: The value's type as a human-readable string.
  • Column 2: Formatted value for display.
- EditRole
  • Column 0: Metadata key.
  • Column 1: Python type of the value.
  • Column 2: Editable value converted to a Qt-friendly representation where necessary (e.g. decoded strings or timezone-aware datetime).
- ToolTipRole
  • Column 2: Full timestamp string for datetime values.

Returns None if no metadata is available or if the requested role/column combination is not supported.

◆ flags()

gui.metadata_model.MetadataModel.flags ( self,
index )

Returns the flags applicable for a particular table cell based on index.

Internal metadata entries such as type, sequence_id, ... are protected and not editable.

◆ get_metadata()

dict | None gui.metadata_model.MetadataModel.get_metadata ( self)

Returns the current metadata.

If no metadata is available, returns None. Otherwise, returns a copy of the current metadata merged with deleted entries (with values set to None).

◆ headerData()

gui.metadata_model.MetadataModel.headerData ( self,
section,
orientation,
role = ... )

Returns the header string for display for a specific column.

Only the horizontal headers are supported. 'None' is returned for all unsupported columns, orientations and roles.

◆ rowCount()

gui.metadata_model.MetadataModel.rowCount ( self,
parent = QModelIndex() )

Returns the number of rows in the metadata table.

Returns 0 if no metadata is available; otherwise returns the number of metadata entries currently in the model.

◆ set_metadata()

gui.metadata_model.MetadataModel.set_metadata ( self,
dict | None new_metadata )

Replaces the current metadata.

If new_metadata is None, the metadata is cleared. Keys with a value of None are tracked as deleted, while all other key-value pairs are stored as valid metadata. The model is reset before and after the update to notify any connected views.

◆ setData()

gui.metadata_model.MetadataModel.setData ( self,
index,
value,
role = ... )

Updates a metadata entry with the provided value.

Only Qt.EditRole updates are supported. Depending on the selected column, this can rename a metadata key, change the metadata type, or update the metadata value. Invalid edits emit the editError signal with the corresponding EditError code.

Returns True if the update was successful, otherwise False.

◆ shape_matches_type()

bool gui.metadata_model.MetadataModel.shape_matches_type ( RtcVectorUInt64 shape,
type rtc_type )
static

Checks whether a shape is compatible with the specified RTC type.

Scalars must have an empty shape, vectors and strings/binary values must have a one-dimensional shape, and matrices must have a two-dimensional shape.

Returns True if the shape matches the expected dimensionality of the type, otherwise False.

◆ try_delete_row()

bool gui.metadata_model.MetadataModel.try_delete_row ( self,
QModelIndex index )

Deletes the metadata entry at the given table row.

Returns True if the row was successfully removed. Returns False if no metadata is available, the index is invalid, or the selected entry cannot be deleted. Deleted entries are tracked so they can be represented as removed (values set to None).

◆ try_insert_empty_row()

bool gui.metadata_model.MetadataModel.try_insert_empty_row ( self)

Inserts a temporary empty row for adding a new metadata entry.

Returns True if the row was successfully inserted. Returns False if no metadata is available or if a temporary new row already exists.

Member Data Documentation

◆ _data

dict gui.metadata_model.MetadataModel._data = None
protected

◆ _deleted_keys

gui.metadata_model.MetadataModel._deleted_keys = set()
protected

◆ _fixed_type_entries

dict gui.metadata_model.MetadataModel._fixed_type_entries = {"type", "shape", "symlink_target", "timestamp"}
protected

◆ _headers

list gui.metadata_model.MetadataModel._headers = ["Name", "Data Type", "Value"]
protected

◆ _NEW_ROW_KEY

str gui.metadata_model.MetadataModel._NEW_ROW_KEY
staticprotected

◆ _read_only_entries

dict gui.metadata_model.MetadataModel._read_only_entries = {"sequence_id"}
protected

◆ editError

gui.metadata_model.MetadataModel.editError
static

The documentation for this class was generated from the following file: