Slicer  4.11
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
[legend]
Collaboration diagram for qMRMLTreeView:
Collaboration graph
[legend]

Public Types

typedef QTreeView Superclass
 

Properties

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)
 

Signals

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
 
bool eventFilter (QObject *object, QEvent *e) override
 
bool fitSizeToVisibleIndexes () const
 
bool isDeleteMenuActionVisible () const
 
bool isEditMenuActionVisible () const
 
bool isRenameMenuActionVisible () const
 
qMRMLSceneModel::NodeTypes listenNodeModifiedEvent () const
 
QSize minimumSizeHint () const override
 
QSize minSizeHint () const
 
vtkMRMLScenemrmlScene () const
 
QStringList nodeTypes () const
 
void prependNodeMenuAction (QAction *action)
 
void prependSceneMenuAction (QAction *action)
 
 qMRMLTreeView (QWidget *parent=nullptr)
 
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...
 
void showEvent (QShowEvent *show) override
 
bool showHidden () const
 
bool showRootNode () const
 
bool showScene () const
 
QSize sizeHint () const override
 
Q_INVOKABLE qMRMLSortFilterProxyModelsortFilterProxyModel () const
 
 ~qMRMLTreeView () override
 

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 onCustomContextMenu (const QPoint &point)
 
void onNumberOfVisibleIndexChanged ()
 
virtual void onSelectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 
void saveTreeExpandState ()
 
void updateRootNode (vtkObject *modifiedRootNode)
 

Protected Member Functions

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

Protected Attributes

QScopedPointer< qMRMLTreeViewPrivate > d_ptr
 

Detailed Description

Todo:
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 119 of file qMRMLTreeView.h.

Property Documentation

◆ deleteMenuActionVisible

bool qMRMLTreeView::deleteMenuActionVisible
readwrite

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

See also
renameMenuActionVisible, editMenuActionVisible, prependNodeMenuAction()

Definition at line 91 of file qMRMLTreeView.h.

◆ editMenuActionVisible

bool qMRMLTreeView::editMenuActionVisible
readwrite

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

See also
renameMenuActionVisible, deleteMenuActionVisible, prependNodeMenuAction()

Definition at line 95 of file qMRMLTreeView.h.

◆ fitSizeToVisibleIndexes

bool qMRMLTreeView::fitSizeToVisibleIndexes
readwrite

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

Definition at line 77 of file qMRMLTreeView.h.

◆ listenNodeModifiedEvent

qMRMLSceneModel::NodeTypes qMRMLTreeView::listenNodeModifiedEvent
readwrite

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
qMRMLSceneModel::listenNodeModifiedEvent

Definition at line 64 of file qMRMLTreeView.h.

◆ minSizeHint

QSize qMRMLTreeView::minSizeHint
readwrite

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
fitSizeToVisibleIndexes

Definition at line 83 of file qMRMLTreeView.h.

◆ nodeTypes

QStringList qMRMLTreeView::nodeTypes
readwrite

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 "qMRMLSceneDisplayableModel", "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
qMRMLSortFilterProxyModel::nodeTypes

Definition at line 74 of file qMRMLTreeView.h.

◆ renameMenuActionVisible

bool qMRMLTreeView::renameMenuActionVisible
readwrite

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

See also
deleteMenuActionVisible, editMenuActionVisible, prependNodeMenuAction()

Definition at line 87 of file qMRMLTreeView.h.

◆ sceneModelType

QString qMRMLTreeView::sceneModelType
readwrite

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 58 of file qMRMLTreeView.h.

◆ showHidden

bool qMRMLTreeView::showHidden
readwrite

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
vtkMRMLNode::GetHideFromEditors()

Definition at line 100 of file qMRMLTreeView.h.

◆ showRootNode

bool qMRMLTreeView::showRootNode
readwrite

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 116 of file qMRMLTreeView.h.

◆ showScene

bool qMRMLTreeView::showScene
readwrite

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 106 of file qMRMLTreeView.h.

Constructor & Destructor Documentation

◆ qMRMLTreeView() [1/2]

qMRMLTreeView::qMRMLTreeView ( QWidget *  parent = nullptr)

◆ ~qMRMLTreeView()

qMRMLTreeView::~qMRMLTreeView ( )
override

◆ qMRMLTreeView() [2/2]

qMRMLTreeView::qMRMLTreeView ( qMRMLTreeViewPrivate *  pimpl,
QWidget *  parent = nullptr 
)
protected

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)
virtual

◆ 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)
signal

◆ currentNodeDeleted

void qMRMLTreeView::currentNodeDeleted ( const QModelIndex &  index)
signal

◆ currentNodeRenamed

void qMRMLTreeView::currentNodeRenamed ( const QString &  newName)
signal

◆ decorationClicked

void qMRMLTreeView::decorationClicked ( const QModelIndex &  )
signal

◆ deleteCurrentNode

void qMRMLTreeView::deleteCurrentNode ( )
slot

◆ editCurrentNode

void qMRMLTreeView::editCurrentNode ( )
slot

◆ editNodeRequested

void qMRMLTreeView::editNodeRequested ( vtkMRMLNode node)
signal

◆ eventFilter()

bool qMRMLTreeView::eventFilter ( QObject *  object,
QEvent *  e 
)
override

◆ findAncestor()

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

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 
)
static

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()

void qMRMLTreeView::keyPressEvent ( QKeyEvent *  event)
overrideprotected

◆ listenNodeModifiedEvent()

qMRMLSceneModel::NodeTypes qMRMLTreeView::listenNodeModifiedEvent ( ) const

Get the node types of the scene model.

See also
qMRMLSceneModel::listenNodeModifiedEvent

◆ loadTreeExpandState

void qMRMLTreeView::loadTreeExpandState ( )
protectedslot

Expand the nodes previously saved by saveTreeExpandState()

See also
saveTreeExpandState()

◆ minimumSizeHint()

QSize qMRMLTreeView::minimumSizeHint ( ) const
override

◆ minSizeHint()

QSize qMRMLTreeView::minSizeHint ( ) const

◆ mousePressEvent()

void qMRMLTreeView::mousePressEvent ( QMouseEvent *  event)
overrideprotected

◆ mouseReleaseEvent()

void qMRMLTreeView::mouseReleaseEvent ( QMouseEvent *  event)
overrideprotected

◆ 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

◆ onCustomContextMenu

void qMRMLTreeView::onCustomContextMenu ( const QPoint &  point)
protectedslot

◆ onNumberOfVisibleIndexChanged

void qMRMLTreeView::onNumberOfVisibleIndexChanged ( )
protectedslot

◆ onSelectionChanged

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

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

See also
currentNodeChanged()

Reimplemented in qMRMLAnnotationTreeView.

◆ prependNodeMenuAction()

void qMRMLTreeView::prependNodeMenuAction ( QAction *  action)

◆ prependSceneMenuAction()

void qMRMLTreeView::prependSceneMenuAction ( QAction *  action)

◆ removeChildren()

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

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 ( )
slot

◆ rootNode()

vtkMRMLNode* qMRMLTreeView::rootNode ( ) const

Return the root node of the tree.

See also
setRootNode(), showRootNode

◆ saveTreeExpandState

void qMRMLTreeView::saveTreeExpandState ( )
protectedslot

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
loadTreeExpandState()

◆ sceneModel()

Q_INVOKABLE qMRMLSceneModel* qMRMLTreeView::sceneModel ( ) const

◆ sceneModelType()

QString qMRMLTreeView::sceneModelType ( ) const

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

See also
setSceneModel()

◆ scrollTo

void qMRMLTreeView::scrollTo ( const QString &  displayName)
slot

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()

◆ scrollToNext

void qMRMLTreeView::scrollToNext ( )
slot

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
scrollTo()

◆ setCurrentNode

void qMRMLTreeView::setCurrentNode ( vtkMRMLNode node)
slot

Change the current view node to node.

See also
currentNode

◆ setDeleteMenuActionVisible()

void qMRMLTreeView::setDeleteMenuActionVisible ( bool  show)

◆ setDontHideAll

void qMRMLTreeView::setDontHideAll ( bool  dontHide)
inlineslot

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

See also
setHideAll()

Definition at line 364 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)
inlineslot

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

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

Definition at line 358 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)
virtualslot

◆ setNodeTypes()

void qMRMLTreeView::setNodeTypes ( const QStringList &  nodeTypes)

◆ setRenameMenuActionVisible()

void qMRMLTreeView::setRenameMenuActionVisible ( bool  show)

◆ setRootNode

void qMRMLTreeView::setRootNode ( vtkMRMLNode root)
slot

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)
slot

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

◆ setShowAll

void qMRMLTreeView::setShowAll ( bool  show)
inlineslot

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

See also
setHideAll(), qMRMLSortFilterProxyModel::FilterType

Definition at line 352 of file qMRMLTreeView.h.

◆ setShowHidden()

void qMRMLTreeView::setShowHidden ( bool  enable)
inline

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

Definition at line 340 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()

void qMRMLTreeView::showEvent ( QShowEvent *  show)
override

◆ showHidden()

bool qMRMLTreeView::showHidden ( ) const
inline

◆ 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()

QSize qMRMLTreeView::sizeHint ( ) const
override

◆ 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)
protectedvirtual

Reimplemented in qMRMLAnnotationTreeView.

◆ updateGeometries()

void qMRMLTreeView::updateGeometries ( )
overrideprotected

◆ updateRootNode

void qMRMLTreeView::updateRootNode ( vtkObject *  modifiedRootNode)
protectedslot

Member Data Documentation

◆ d_ptr

QScopedPointer<qMRMLTreeViewPrivate> qMRMLTreeView::d_ptr
protected

Definition at line 324 of file qMRMLTreeView.h.


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