Hdf5TreeModel class#

class Hdf5TreeModel(parent=None, ownFiles=True)[source]#

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

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 = <PySide6.QtCore.Property object>#

Property to enable/disable file dropping in the model.

datasetDragEnabled = <PySide6.QtCore.Property object>#

Property to enable/disable drag of datasets.

fileMoveEnabled = <PySide6.QtCore.Property object>#

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

mimeData(indexes)[source]#

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

findHdf5Item(url)[source]#

Return the Hdf5Object matching the url if exists in the model. Else None

Parameters:

url (DataUrl)

Return type:

Hdf5Item | None

synchronizeIndex(index)[source]#

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)[source]#

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)[source]#

Remove an item from the model using its index.

Parameters:

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

removeH5pyObject(h5pyObject)[source]#

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)[source]#

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)[source]#

Load a HDF5 file into the data model.

Parameters:

filename – file path.

clear()[source]#

Remove all the content of the model

indexFromH5Object(h5Object)[source]#

Returns a model index from an h5py-like object.

Parameters:

h5Object (object) – An h5py-like object

Return type:

qt.QModelIndex