Skip to main content
`Ctrl`+`K`

# `Hdf5TreeModel` class

class Hdf5TreeModel(parent=None, ownFiles=True)

  Bases: `QAbstractItemModel`

  Tree model storing a list of `h5py.File` like objects.

  The main column display the `h5py.File` list and there hierarchy. Other columns display information on node hierarchy.

  H5PY_ITEM_ROLE = 256

    Role to reach h5py item from an item index

  H5PY_OBJECT_ROLE = 257

    Role to reach h5py object from an item index

  USER_ROLE = 258

    Start of range of available user role for derivative models

  NAME_COLUMN = 0

    Column id containing HDF5 node names

  TYPE_COLUMN = 1

    Column id containing HDF5 dataset types

  SHAPE_COLUMN = 2

    Column id containing HDF5 dataset shapes

  VALUE_COLUMN = 3

    Column id containing HDF5 dataset values

  DESCRIPTION_COLUMN = 4

    Column id containing HDF5 node description/title/message

  NODE_COLUMN = 5

    Column id containing HDF5 node type

  LINK_COLUMN = 6

    Column id containing HDF5 link type

  COLUMN_IDS = [0, 1, 2, 3, 4, 5, 6]

    List of logical columns available

  sigH5pyObjectLoaded

    Emitted when a new root item was loaded and inserted to the model.

  sigH5pyObjectRemoved

    Emitted when a root item is removed from the model.

  sigH5pyObjectSynchronized

    Emitted when an item was synchronized.

  fileDropEnabled

    Property to enable/disable file dropping in the model.

  datasetDragEnabled

    Property to enable/disable drag of datasets.

  fileMoveEnabled

    Property to enable/disable drag-and-drop of files to change the ordering in the model.

  supportedDropActions(self) → Qt.DropAction
  mimeTypes(self) → list[str]
  mimeData(indexes)

    Returns an object that contains serialized items of data corresponding to the list of indexes specified.

    Parameters:

      indexes (List[qt.QModelIndex]) – List of indexes

    Return type:

      qt.QMimeData

  flags(self, index: QModelIndex) → Qt.ItemFlag
  dropMimeData(self, data: QMimeData | None, action: Qt.DropAction, row: int, column: int, parent: QModelIndex) → bool
  headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.DisplayRole) → Any
  moveRow(self, sourceParent: QModelIndex, sourceRow: int, destinationParent: QModelIndex, destinationChild: int) → bool
  moveRows(self, sourceParent: QModelIndex, sourceRow: int, count: int, destinationParent: QModelIndex, destinationChild: int) → bool
  index(self, row: int, column: int, parent: QModelIndex = QModelIndex()) → QModelIndex
  data(self, index: QModelIndex, role: int = Qt.DisplayRole) → Any
  columnCount(self, parent: QModelIndex = QModelIndex()) → int
  hasChildren(self, parent: QModelIndex = QModelIndex()) → bool
  rowCount(self, parent: QModelIndex = QModelIndex()) → int
  parent(self, child: QModelIndex) → QModelIndex
  parent(self) → QObject | None
  synchronizeIndex(index)

    Synchronize a file a given its index.

    Basically close it and load it again.

    Parameters:

      index (qt.QModelIndex) – Index of the item to update

  synchronizeH5pyObject(h5pyObject)

    Synchronize a h5py object in all the tree.

    Basically close it and load it again.

    Parameters:

      h5pyObject (h5py.File) – A `h5py.File` object.

  removeIndex(index)

    Remove an item from the model using its index.

    Parameters:

      index (qt.QModelIndex) – Index of the item to remove

  removeH5pyObject(h5pyObject)

    Remove an item from the model using the holding h5py object. It can remove more than one item.

    Parameters:

      h5pyObject (h5py.File) – A `h5py.File` object.

  insertH5pyObject(h5pyObject, text=None, row=-1, filename=None)

    Append an HDF5 object from h5py to the tree.

    Parameters:

      - h5pyObject – File handle/descriptor for a `h5py.File` or any other class of h5py file structure.

      - text (`str` | `None`)

      - row (`int`)

      - filename (`str` | `None`)

  insertFile(filename, row=-1)

    Load a HDF5 file into the data model.

    Parameters:

      filename – file path.

  clear()

    Remove all the content of the model

  indexFromH5Object(h5Object)

    Returns a model index from an h5py-like object.

    Parameters:

      h5Object (object) – An h5py-like object

    Return type:

      qt.QModelIndex