Slicer  4.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Properties | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes
qMRMLTreeView Class Reference

#include <Libs/MRML/Widgets/qMRMLTreeView.h>

Inheritance diagram for qMRMLTreeView:
Inheritance graph
Collaboration diagram for qMRMLTreeView:
Collaboration graph

Public Types

typedef QTreeView Superclass


bool deleteMenuActionVisible
bool editMenuActionVisible
bool fitSizeToVisibleIndexes
qMRMLSceneModel::NodeTypes listenNodeModifiedEvent
QSize minSizeHint
QStringList nodeTypes
bool renameMenuActionVisible
QString sceneModelType
bool showHidden
bool showRootNode
bool showScene

Public Slots

void deleteCurrentNode ()
void editCurrentNode ()
void renameCurrentNode ()
void scrollTo (const QString &displayName)
void scrollToNext ()
void setCurrentNode (vtkMRMLNode *node)
void setDontHideAll (bool)
void setHideAll (bool)
virtual void setMRMLScene (vtkMRMLScene *scene)
void setRootNode (vtkMRMLNode *root)
void setSceneModelType (const QString &modelType)
void setShowAll (bool)


void currentNodeChanged (vtkMRMLNode *node)
void currentNodeDeleted (const QModelIndex &index)
void currentNodeRenamed (const QString &newName)
void decorationClicked (const QModelIndex &)
void editNodeRequested (vtkMRMLNode *node)

Public Member Functions

void appendNodeMenuAction (QAction *action)
void appendSceneMenuAction (QAction *action)
virtual bool clickDecoration (const QModelIndex &index)
vtkMRMLNodecurrentNode () const
virtual bool eventFilter (QObject *object, QEvent *e)
bool fitSizeToVisibleIndexes () const
bool isDeleteMenuActionVisible () const
bool isEditMenuActionVisible () const
bool isRenameMenuActionVisible () const
qMRMLSceneModel::NodeTypes listenNodeModifiedEvent () const
virtual QSize minimumSizeHint () const
QSize minSizeHint () const
vtkMRMLScenemrmlScene () const
QStringList nodeTypes () const
void prependNodeMenuAction (QAction *action)
void prependSceneMenuAction (QAction *action)
 qMRMLTreeView (QWidget *parent=0)
void removeNodeMenuAction (QAction *action)
 Remove action from the "NodeMenu". More...
vtkMRMLNoderootNode () const
Q_INVOKABLE qMRMLSceneModelsceneModel () const
QString sceneModelType () const
void setDeleteMenuActionVisible (bool show)
void setEditMenuActionVisible (bool show)
void setFitSizeToVisibleIndexes (bool)
void setListenNodeModifiedEvent (qMRMLSceneModel::NodeTypes listen)
void setMinSizeHint (QSize min)
void setNodeTypes (const QStringList &nodeTypes)
void setRenameMenuActionVisible (bool show)
void setSceneModel (qMRMLSceneModel *newSceneModel, const QString &modelType)
 Customize the model. More...
void setShowHidden (bool)
void setShowRootNode (bool show)
void setShowScene (bool show)
void setSortFilterProxyModel (qMRMLSortFilterProxyModel *newFilterModel)
 Customize the filter model. More...
virtual void showEvent (QShowEvent *show)
bool showHidden () const
bool showRootNode () const
bool showScene () const
virtual QSize sizeHint () const
Q_INVOKABLE qMRMLSortFilterProxyModelsortFilterProxyModel () const
virtual ~qMRMLTreeView ()

Static Public Member Functions

static QModelIndex findAncestor (const QModelIndex &index, const QModelIndexList &potentialAncestors)
static bool isAncestor (const QModelIndex &index, const QModelIndex &potentialAncestor)
static QModelIndexList removeChildren (const QModelIndexList &indexes)
 Remove indexes that have at least one ancestor in the list. More...

Protected Slots

void loadTreeExpandState ()
void onNumberOfVisibleIndexChanged ()
virtual void onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
void saveTreeExpandState ()
void updateRootNode (vtkObject *modifiedRootNode)

Protected Member Functions

virtual void keyPressEvent (QKeyEvent *event)
virtual void mousePressEvent (QMouseEvent *event)
virtual void mouseReleaseEvent (QMouseEvent *event)
 qMRMLTreeView (qMRMLTreeViewPrivate *pimpl, QWidget *parent=0)
virtual void toggleVisibility (const QModelIndex &index)
virtual void updateGeometries ()

Protected Attributes

QScopedPointer< qMRMLTreeViewPrivate > d_ptr

Detailed Description

Rename to qMRMLSceneTreeView In debug mode, pressing the '!' key on the view switches of qMRMLSortFilterProxyModel::filterType, it can be useful to debug the scene model and filters applied to them.

Definition at line 45 of file qMRMLTreeView.h.

Member Typedef Documentation

◆ Superclass

typedef QTreeView qMRMLTreeView::Superclass

Definition at line 120 of file qMRMLTreeView.h.

Property Documentation

◆ deleteMenuActionVisible

bool qMRMLTreeView::deleteMenuActionVisible

This property controls whether the "Delete" context menu entry is visible Visible by default

See also
renameMenuActionVisible, editMenuActionVisible, prependNodeMenuAction()

Definition at line 92 of file qMRMLTreeView.h.

◆ editMenuActionVisible

bool qMRMLTreeView::editMenuActionVisible

This property controls whether the "Edit properties..." context menu entry is visible Hidden by default

See also
renameMenuActionVisible, deleteMenuActionVisible, prependNodeMenuAction()

Definition at line 96 of file qMRMLTreeView.h.

◆ fitSizeToVisibleIndexes

bool qMRMLTreeView::fitSizeToVisibleIndexes

This property controls whether the list auto resize to fit its size to show the number indexes without scrollbar.

Definition at line 78 of file qMRMLTreeView.h.

◆ listenNodeModifiedEvent

qMRMLSceneModel::NodeTypes qMRMLTreeView::listenNodeModifiedEvent

This property controls whether to actively listen to the nodes to synchronize their representation. As it can be time consuming, you can disable it if you want a lazy update. OnlyVisibleNodes by default.

See also

Definition at line 65 of file qMRMLTreeView.h.

◆ minSizeHint

QSize qMRMLTreeView::minSizeHint

This property controls the minimum size of (minimum)sizeHint. When fitSizeToVisibleIndexes is true, the default size can be small if the contains few nodes. Setting minSizeHint ensures a minimum size of the tree minimumSizeHint and sizeHint properties.

See also

Definition at line 84 of file qMRMLTreeView.h.

◆ nodeTypes

QStringList qMRMLTreeView::nodeTypes

This property controls which node types are visible in the view. This behaves as a filter, the nodes that have a type not included in the list will be hidden. For example, a value of "vtkMRMLModelHierarchyNode", "vtkMRMLModelNode" will show the model nodes. When dealing with hierarchies, please note that the node type of the parents should not be filtered out (should be included in nodeTypes) to ensure the children are visible. All nodes are visible by default (QStringList()).

See also

Definition at line 75 of file qMRMLTreeView.h.

◆ renameMenuActionVisible

bool qMRMLTreeView::renameMenuActionVisible

This property controls whether the "Rename" context menu entry is visible Visible by default

See also
deleteMenuActionVisible, editMenuActionVisible, prependNodeMenuAction()

Definition at line 88 of file qMRMLTreeView.h.

◆ sceneModelType

QString qMRMLTreeView::sceneModelType

This property controls what type of scene representation (which qMRMLSceneModel implementation/subclass)is used to populate the nodes of the scene. Some built-in model types are available :

Definition at line 59 of file qMRMLTreeView.h.

◆ showHidden

bool qMRMLTreeView::showHidden

This property controls whether nodes with the property vtkMRMLNode::HideFromEditors set to true are visible in the view. False by default (only nodes with HideFromEditors = 0 are visible)

See also

Definition at line 101 of file qMRMLTreeView.h.

◆ showRootNode

bool qMRMLTreeView::showRootNode

This property controls whether the root node if any is visible. When the root node is visible, it appears as a top-level item, if it is hidden only its children are top-level items. It doesn't have any effect if rootNode() is null. Hidden by default. Don't use qMRMLSortFilterProxyModel::HideNodesUnaffiliatedWithNodeID if showRootNode is true, it is internally being used.

See also
setShowRootNode(), showRootNode(), showScene, setRootNode(), setRootIndex()

Definition at line 117 of file qMRMLTreeView.h.

◆ showScene

bool qMRMLTreeView::showScene

This property controls whether the scene is visible (is a top-level item). It doesn't have any effect if rootNode() is not null. Visible by default.

See also
setShowScene(), showScene(), showRootNode, setRootNode(), setRootIndex()

Definition at line 107 of file qMRMLTreeView.h.

Constructor & Destructor Documentation

◆ qMRMLTreeView() [1/2]

qMRMLTreeView::qMRMLTreeView ( QWidget *  parent = 0)

◆ ~qMRMLTreeView()

virtual qMRMLTreeView::~qMRMLTreeView ( )

◆ qMRMLTreeView() [2/2]

qMRMLTreeView::qMRMLTreeView ( qMRMLTreeViewPrivate *  pimpl,
QWidget *  parent = 0 

Member Function Documentation

◆ appendNodeMenuAction()

void qMRMLTreeView::appendNodeMenuAction ( QAction *  action)

Add a custom QAction to add into the context menu that opens with a right click on a MRML node.

See also
prependNodeMenuAction(), appendSceneMenuAction()

◆ appendSceneMenuAction()

void qMRMLTreeView::appendSceneMenuAction ( QAction *  action)

Add a custom QAction to add into the context menu that opens with a right click on the MRML scene.

See also
appendNodeMenuAction(), prependSceneMenuAction()

◆ clickDecoration()

virtual bool qMRMLTreeView::clickDecoration ( const QModelIndex &  index)

◆ currentNode()

vtkMRMLNode* qMRMLTreeView::currentNode ( ) const

Return a pointer to the current node (not necessarily selected), 0 if no node is current

See also
QItemSelectionModel::currentIndex(), QItemSelectionModel::selectedIndexes()

◆ currentNodeChanged

void qMRMLTreeView::currentNodeChanged ( vtkMRMLNode node)

◆ currentNodeDeleted

void qMRMLTreeView::currentNodeDeleted ( const QModelIndex &  index)

◆ currentNodeRenamed

void qMRMLTreeView::currentNodeRenamed ( const QString &  newName)

◆ decorationClicked

void qMRMLTreeView::decorationClicked ( const QModelIndex &  )

◆ deleteCurrentNode

void qMRMLTreeView::deleteCurrentNode ( )

◆ editCurrentNode

void qMRMLTreeView::editCurrentNode ( )

◆ editNodeRequested

void qMRMLTreeView::editNodeRequested ( vtkMRMLNode node)

◆ eventFilter()

virtual bool qMRMLTreeView::eventFilter ( QObject *  object,
QEvent *  e 

◆ findAncestor()

static QModelIndex qMRMLTreeView::findAncestor ( const QModelIndex &  index,
const QModelIndexList &  potentialAncestors 

Return an ancestor in the list of potential ancestors if any, otherwise return an invalid QModelIndex

◆ fitSizeToVisibleIndexes()

bool qMRMLTreeView::fitSizeToVisibleIndexes ( ) const

◆ isAncestor()

static bool qMRMLTreeView::isAncestor ( const QModelIndex &  index,
const QModelIndex &  potentialAncestor 

Return true if potentialAncestor is an ancestor of index

◆ isDeleteMenuActionVisible()

bool qMRMLTreeView::isDeleteMenuActionVisible ( ) const

Show/Hide the "Delete" menu item on right context menu Visible by default

◆ isEditMenuActionVisible()

bool qMRMLTreeView::isEditMenuActionVisible ( ) const

Show/Hide the "Edit properties..." menu item on right context menu Hidden by default

◆ isRenameMenuActionVisible()

bool qMRMLTreeView::isRenameMenuActionVisible ( ) const

Show/Hide the "Rename" menu item on right context menu Visible by default

◆ keyPressEvent()

virtual void qMRMLTreeView::keyPressEvent ( QKeyEvent *  event)

◆ listenNodeModifiedEvent()

qMRMLSceneModel::NodeTypes qMRMLTreeView::listenNodeModifiedEvent ( ) const

Get the node types of the scene model.

See also

◆ loadTreeExpandState

void qMRMLTreeView::loadTreeExpandState ( )

Expand the nodes previously saved by saveTreeExpandState()

See also

◆ minimumSizeHint()

virtual QSize qMRMLTreeView::minimumSizeHint ( ) const

◆ minSizeHint()

QSize qMRMLTreeView::minSizeHint ( ) const

◆ mousePressEvent()

virtual void qMRMLTreeView::mousePressEvent ( QMouseEvent *  event)

Reimplemented in qMRMLAnnotationTreeView.

◆ mouseReleaseEvent()

virtual void qMRMLTreeView::mouseReleaseEvent ( QMouseEvent *  event)

◆ mrmlScene()

vtkMRMLScene* qMRMLTreeView::mrmlScene ( ) const

◆ nodeTypes()

QStringList qMRMLTreeView::nodeTypes ( ) const

Set/Get node types to display in the list NodeTypes are the class names, i.e. vtkMRMLViewNode, vtkMRMLTransformNode

◆ onNumberOfVisibleIndexChanged

void qMRMLTreeView::onNumberOfVisibleIndexChanged ( )

◆ onSelectionChanged

virtual void qMRMLTreeView::onSelectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 

This slot is being triggered when the current node has changed.

See also

Reimplemented in qMRMLAnnotationTreeView.

◆ prependNodeMenuAction()

void qMRMLTreeView::prependNodeMenuAction ( QAction *  action)

◆ prependSceneMenuAction()

void qMRMLTreeView::prependSceneMenuAction ( QAction *  action)

◆ removeChildren()

static QModelIndexList qMRMLTreeView::removeChildren ( const QModelIndexList &  indexes)

Remove indexes that have at least one ancestor in the list.

◆ removeNodeMenuAction()

void qMRMLTreeView::removeNodeMenuAction ( QAction *  action)

Remove action from the "NodeMenu".

◆ renameCurrentNode

void qMRMLTreeView::renameCurrentNode ( )

◆ rootNode()

vtkMRMLNode* qMRMLTreeView::rootNode ( ) const

Return the root node of the tree.

See also
setRootNode(), showRootNode

◆ saveTreeExpandState

void qMRMLTreeView::saveTreeExpandState ( )

Save the nodes currently expanded nodes so that their state can later be restored by loadTreeExpandState(). Successive calls to saveTreeExpandState() erase previous tree expand state.

See also

◆ sceneModel()

Q_INVOKABLE qMRMLSceneModel* qMRMLTreeView::sceneModel ( ) const

◆ sceneModelType()

QString qMRMLTreeView::sceneModelType ( ) const

Could be "", "Transform", "Displayable", "ModelHierarchy" or the type associated with the scene model added with qMRMLTreeView::setSceneModel()

See also

◆ scrollTo

void qMRMLTreeView::scrollTo ( const QString &  displayName)

Search the nodes matching displayName; if found, ensure a matching node is visible and current. If the current node matches displayName, then make sure it is visible (by scrolling and expanding as needed). If the current node does not match displayName, then make the first matching node current and visible. This slot can be connected as-is with a QLineEdit or a ctkSearchBox textChanged(QString) signal.

See also

◆ scrollToNext

void qMRMLTreeView::scrollToNext ( )

Repeat the last scrollTo() command, and if more than one node was matching select the next node. This slot can be connected as-is with a QLineEdit or a ctkSearchBox returnPressed() signal.

See also

◆ setCurrentNode

void qMRMLTreeView::setCurrentNode ( vtkMRMLNode node)

Change the current view node to node.

See also

◆ setDeleteMenuActionVisible()

void qMRMLTreeView::setDeleteMenuActionVisible ( bool  show)

◆ setDontHideAll

void qMRMLTreeView::setDontHideAll ( bool  dontHide)

Convenient slot to call hideAll() with the opposite value.

See also

Definition at line 363 of file qMRMLTreeView.h.

◆ setEditMenuActionVisible()

void qMRMLTreeView::setEditMenuActionVisible ( bool  show)

◆ setFitSizeToVisibleIndexes()

void qMRMLTreeView::setFitSizeToVisibleIndexes ( bool  )

When true, the tree widget resize itself so that it's sizeHint is right for the visible indexes

◆ setHideAll

void qMRMLTreeView::setHideAll ( bool  hide)

Bypass all the filters on the view and hide all the nodes.

See also
showAll(), setDontHideAll(), qMRMLSortFilterProxyModel::FilterType

Definition at line 357 of file qMRMLTreeView.h.

◆ setListenNodeModifiedEvent()

void qMRMLTreeView::setListenNodeModifiedEvent ( qMRMLSceneModel::NodeTypes  listen)

Set the node types on the scene model.

See also
listenNodeModifiedEvent qMRMLSceneModel::setListenNodeModifiedEvent

◆ setMinSizeHint()

void qMRMLTreeView::setMinSizeHint ( QSize  min)

◆ setMRMLScene

virtual void qMRMLTreeView::setMRMLScene ( vtkMRMLScene scene)

◆ setNodeTypes()

void qMRMLTreeView::setNodeTypes ( const QStringList &  nodeTypes)

◆ setRenameMenuActionVisible()

void qMRMLTreeView::setRenameMenuActionVisible ( bool  show)

◆ setRootNode

void qMRMLTreeView::setRootNode ( vtkMRMLNode root)

Similar to setRootIndex(QModelIndex) but observe the ModifiedEvent of the node to stay in sync. A null node (default) means QModelIndex() is the root index.

See also
rootNode(), setRootIndex(), showRootNode

◆ setSceneModel()

void qMRMLTreeView::setSceneModel ( qMRMLSceneModel newSceneModel,
const QString &  modelType 

Customize the model.

◆ setSceneModelType

void qMRMLTreeView::setSceneModelType ( const QString &  modelType)

If the modelType doesn't match any known model, nothing will happen

◆ setShowAll

void qMRMLTreeView::setShowAll ( bool  show)

Bypass all the filters on the view and show all the nodes.

See also
setHideAll(), qMRMLSortFilterProxyModel::FilterType

Definition at line 351 of file qMRMLTreeView.h.

◆ setShowHidden()

void qMRMLTreeView::setShowHidden ( bool  enable)

If a vtkMRMLNode has the property HideFromEditors set to true, bypass the property and show the node anyway.

Definition at line 339 of file qMRMLTreeView.h.

◆ setShowRootNode()

void qMRMLTreeView::setShowRootNode ( bool  show)

Set the show root node flag.

See also
showRootNode, showRootNode()

◆ setShowScene()

void qMRMLTreeView::setShowScene ( bool  show)

Set the show scene flag.

See also
showScene, showScene()

◆ setSortFilterProxyModel()

void qMRMLTreeView::setSortFilterProxyModel ( qMRMLSortFilterProxyModel newFilterModel)

Customize the filter model.

◆ showEvent()

virtual void qMRMLTreeView::showEvent ( QShowEvent *  show)

◆ showHidden()

bool qMRMLTreeView::showHidden ( ) const

◆ showRootNode()

bool qMRMLTreeView::showRootNode ( ) const

Return the show root node flag.

See also
showRootNode, setShowRootNode()

◆ showScene()

bool qMRMLTreeView::showScene ( ) const

Return the show scene flag.

See also
showScene, setShowScene()

◆ sizeHint()

virtual QSize qMRMLTreeView::sizeHint ( ) const

◆ sortFilterProxyModel()

Q_INVOKABLE qMRMLSortFilterProxyModel* qMRMLTreeView::sortFilterProxyModel ( ) const

Retrieve the sortFilterProxyModel used to filter/sort the nodes. The returned value can't be null.

◆ toggleVisibility()

virtual void qMRMLTreeView::toggleVisibility ( const QModelIndex &  index)

Reimplemented in qMRMLAnnotationTreeView.

◆ updateGeometries()

virtual void qMRMLTreeView::updateGeometries ( )

◆ updateRootNode

void qMRMLTreeView::updateRootNode ( vtkObject *  modifiedRootNode)

Member Data Documentation

◆ d_ptr

QScopedPointer<qMRMLTreeViewPrivate> qMRMLTreeView::d_ptr

Definition at line 323 of file qMRMLTreeView.h.

The documentation for this class was generated from the following file: