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#

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.DropActions[source]#
mimeTypes(self) List[str][source]#
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

flags(self, index: QModelIndex) Qt.ItemFlags[source]#
dropMimeData(self, data: QMimeData | None, action: Qt.DropAction, row: int, column: int, parent: QModelIndex) bool[source]#
headerData(self, section: int, orientation: Qt.Orientation, role: int = Qt.ItemDataRole.DisplayRole) Any[source]#
moveRow(self, sourceParent: QModelIndex, sourceRow: int, destinationParent: QModelIndex, destinationChild: int) bool[source]#
moveRows(self, sourceParent: QModelIndex, sourceRow: int, count: int, destinationParent: QModelIndex, destinationChild: int) bool[source]#
index(self, row: int, column: int, parent: QModelIndex = QModelIndex()) QModelIndex[source]#
data(self, index: QModelIndex, role: int = Qt.ItemDataRole.DisplayRole) Any[source]#
columnCount(self, parent: QModelIndex = QModelIndex()) int[source]#
hasChildren(self, parent: QModelIndex = QModelIndex()) bool[source]#
rowCount(self, parent: QModelIndex = QModelIndex()) int[source]#
parent(self, child: QModelIndex) QModelIndex[source]#
parent(self) QObject | 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:
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