Hdf5TreeView class

class Hdf5TreeView(parent=None)[source]

Bases: PySide.QtGui.QTreeView

TreeView which allow to browse HDF5 file structure.

../../../_images/Hdf5TreeView.png

It provides columns width auto-resizing and additional signals.

The default model is a NexusSortFilterProxyModel sourcing a Hdf5TreeModel. The Hdf5TreeModel is reachable using findHdf5TreeModel(). The default header is Hdf5HeaderView.

Context menu is managed by the setContextMenuPolicy() with the value Qt.CustomContextMenu. This policy must not be changed, otherwise context menus will not work anymore. You can use addContextMenuCallback() and removeContextMenuCallback() to add your custum actions according to the selected objects.

createDefaultModel()[source]

Creates and returns the default model.

Inherite to custom the default model

addContextMenuCallback(callback)[source]

Register a context menu callback.

The callback will be called when a context menu is requested with the treeview and the list of selected h5py objects in parameters. The callback must return a list of qt.QAction object.

Callbacks are stored as saferef. The object must store a reference by itself.

removeContextMenuCallback(callback)[source]

Unregister a context menu callback

findHdf5TreeModel()[source]

Find the Hdf5TreeModel from the stack of model filters.

Returns:A Hdf5TreeModel, else None
Return type:Hdf5TreeModel
selectedH5Nodes(ignoreBrokenLinks=True)[source]

Returns selected h5py objects like h5py.File, h5py.Group, h5py.Dataset or mimicked objects.

Parameters:bool (ignoreBrokenLinks) – Returns objects which are not not broken links.
Return type:iterator(_utils.H5Node)
mapToModel(index)[source]

Map an index from any model reachable by the view to an index from the very first model connected to the view.

Parameters:index (qt.QModelIndex) – Index from the Hdf5Tree model
Return type:qt.QModelIndex
Returns:Index from the model connected to the view
setSelectedH5Node(h5Object)[source]

Select the specified node of the tree using an h5py node.

  • If the item is found, parent items are expended, and then the item is selected.
  • If the item is not found, the selection do not change.
  • A none argument allow to deselect everything
Parameters:h5Object (h5py.Node) – The node to select
mousePressEvent(event)[source]

Override mousePressEvent to provide a consistante compatible API between Qt4 and Qt5