Data Table Model#

DataTableModel(*args, **kwargs)

This model is designed to handle data represented as a dictionary where keys correspond to column labels and values are lists of data points for each column.

class mdaviz.data_table_model.DataTableModel(*args: Any, **kwargs: Any)[source]#

This model is designed to handle data represented as a dictionary where keys correspond to column labels and values are lists of data points for each column.

Args:
  • scanDict (dict): A dictionary where keys are pos/det indexes and values are dictionaries: {index: {‘object’: scanObject, ‘data’: […], ‘unit’: ‘…’, ‘name’: ‘…’,’type’:…}}.

  • parent (QObject, optional): The parent object for this table model, default is None.

Methods:
  • rowCount: Returns the number of rows in the table model.

  • columnCount: Returns the number of columns in the table model.

  • data: Returns the data to be displayed for a given index and role.

  • headerData: Provides the header labels for the table model.

  • columnLabels: Returns a list of column labels.

  • setColumnLabels: Sets the column labels based on keys from the input dictionary.

  • allData: Returns the current data stored in the model.

  • setAllData: Sets the model’s data using the input dictionary.

The model dynamically adjusts to changes in the input data, updating both the data displayed and the column headers as necessary.

allData() → dict[str, list][source]#

Get all data stored in the model.

Returns:

dict[str, list]: Dictionary mapping column names to data lists

columnCount(parent: PyQt6.QtCore.QModelIndex | None = None) → int[source]#

Returns the number of columns in the table model.

Parameters:

parent (Optional[QModelIndex]): Parent index, not used in this implementation

Returns:

int: Number of columns is determined by the number of pos(s) & det(s)

columnLabels() → list[str][source]#

Get the column labels.

Returns:

list[str]: List of column labels

data(index: PyQt6.QtCore.QModelIndex, role: int = 0) → Any[source]#

Returns the data to be displayed for a given index and role.

Parameters:

index (QModelIndex): The index of the item to retrieve data for role (int): The role of the data (DisplayRole, EditRole, etc.)

Returns:

Any: The data for the given index and role, or QVariant() if not found

headerData(section: int, orientation: PyQt6.QtCore.Qt.Orientation, role: int = 0) → Any[source]#

Provide horizontal header labels only, nothing for vertical headers (Index is always the first column).

Parameters:

section (int): Section index orientation (int): Header orientation (Horizontal/Vertical) role (int): Data role

Returns:

Any: Header data or QVariant() if not found

rowCount(parent: PyQt6.QtCore.QModelIndex | None = None) → int[source]#

Returns the number of rows in the table model.

Parameters:

parent (Optional[QModelIndex]): Parent index, not used in this implementation

Returns:

int: The number of rows, or 0 if no data

setAllData(scanDict: dict[str, dict[str, Any]]) → dict[str, list][source]#

Set the model’s data using the input dictionary.

Parameters:

scanDict (dict[str, dict[str, Any]]): Input data dictionary

Returns:

dict[str, list]: Processed data dictionary

setColumnLabels() → list[str][source]#

Set the column labels based on the data keys.

Returns:

list[str]: List of column labels