Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkModelViewSelectionConnector Class Reference

Bridges the selection between a Qt model-view pair and external MITK node selections. More...

#include <QmitkModelViewSelectionConnector.h>

Inheritance diagram for QmitkModelViewSelectionConnector:
Collaboration diagram for QmitkModelViewSelectionConnector:

Public Slots

void SetSelectOnlyVisibleNodes (bool selectOnlyVisibleNodes)
 Controls whether selections are restricted to visible nodes. More...
 
void SetCurrentSelection (QList< mitk::DataNode::Pointer > selectedNodes)
 Applies the given node list as the view's selection. More...
 

Signals

void CurrentSelectionChanged (QList< mitk::DataNode::Pointer > nodes)
 Emitted when the view's selection changes. More...
 

Public Member Functions

 QmitkModelViewSelectionConnector ()
 
void SetView (QAbstractItemView *view)
 Sets the view whose selection model is used for selection synchronization. More...
 
QList< mitk::DataNode::Pointer > GetSelectedNodes () const
 Returns the currently selected data nodes. More...
 
bool GetSelectOnlyVisibleNodes () const
 Returns whether only visible nodes can be selected. More...
 

Detailed Description

Bridges the selection between a Qt model-view pair and external MITK node selections.

This class accepts a QAbstractItemView (whose model must be a QmitkAbstractDataStorageModel) and translates between the view's QItemSelectionModel and lists of mitk::DataNode::Pointer. It can both propagate selection changes outward (via the CurrentSelectionChanged signal) and accept incoming selections (via the SetCurrentSelection slot).

When selectOnlyVisibleNodes is false, the connector also stores non-visible nodes from an incoming selection so they can be merged into outgoing selection signals, preserving the full original selection even when the view can only display a subset.

See also
QmitkAbstractDataStorageInspector
QmitkAbstractDataStorageModel

Definition at line 39 of file QmitkModelViewSelectionConnector.h.

Constructor & Destructor Documentation

◆ QmitkModelViewSelectionConnector()

QmitkModelViewSelectionConnector::QmitkModelViewSelectionConnector ( )

Member Function Documentation

◆ CurrentSelectionChanged

void QmitkModelViewSelectionConnector::CurrentSelectionChanged ( QList< mitk::DataNode::Pointer >  nodes)
signal

Emitted when the view's selection changes.

The node list includes non-visible nodes from a previous SetCurrentSelection call if selectOnlyVisibleNodes is false.

Parameters
[in]nodesThe newly selected data nodes.

◆ GetSelectedNodes()

QList<mitk::DataNode::Pointer> QmitkModelViewSelectionConnector::GetSelectedNodes ( ) const

Returns the currently selected data nodes.

Returns
A list of currently selected mitk::DataNode::Pointer objects.

◆ GetSelectOnlyVisibleNodes()

bool QmitkModelViewSelectionConnector::GetSelectOnlyVisibleNodes ( ) const

Returns whether only visible nodes can be selected.

Returns
True if only visible nodes are selectable.
See also
SetSelectOnlyVisibleNodes

◆ SetCurrentSelection

void QmitkModelViewSelectionConnector::SetCurrentSelection ( QList< mitk::DataNode::Pointer >  selectedNodes)
slot

Applies the given node list as the view's selection.

The nodes are looked up in the model to find matching indexes. If selectOnlyVisibleNodes is false, nodes not present in the model are stored and merged into subsequent outgoing CurrentSelectionChanged signals.

Parameters
[in]selectedNodesThe data nodes to select.
See also
SetSelectOnlyVisibleNodes

◆ SetSelectOnlyVisibleNodes

void QmitkModelViewSelectionConnector::SetSelectOnlyVisibleNodes ( bool  selectOnlyVisibleNodes)
slot

Controls whether selections are restricted to visible nodes.

If true, incoming selections are filtered to only those nodes matching the model's predicate (i.e., visible in the view). If false, non-visible nodes are stored and included in outgoing selection signals.

Parameters
[in]selectOnlyVisibleNodesTrue to restrict to visible nodes.
See also
GetSelectOnlyVisibleNodes

◆ SetView()

void QmitkModelViewSelectionConnector::SetView ( QAbstractItemView *  view)

Sets the view whose selection model is used for selection synchronization.

The view's data model is extracted and must be a QmitkAbstractDataStorageModel. The model must return mitk::DataNode::Pointer objects for the QmitkDataNodeRole.

Parameters
[in]viewThe view to connect to.
Precondition
The view must be valid and its model must be a QmitkAbstractDataStorageModel.
Exceptions
mitk::Exceptionif the view is invalid or its model is not a QmitkAbstractDataStorageModel.

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