Medical Imaging Interaction Toolkit  2021.02.99-e55a5d2f
Medical Imaging Interaction Toolkit
QmitkModelViewSelectionConnector Class Reference

The 'QmitkModelViewSelectionConnector' is used to handle the selections of a model-view-pair and to synchornize them with external node selections (e.g. communicated by the application). More...

#include <QmitkModelViewSelectionConnector.h>

Inheritance diagram for QmitkModelViewSelectionConnector:
Collaboration diagram for QmitkModelViewSelectionConnector:

Public Slots

void SetSelectOnlyVisibleNodes (bool selectOnlyVisibleNodes)
 Change the selection mode of the item view's selection model. More...
 
void SetCurrentSelection (QList< mitk::DataNode::Pointer > selectedNodes)
 Transform a list of data nodes into a model selection and set this as a new selection of the selection model of the private member item view. More...
 

Signals

void CurrentSelectionChanged (QList< mitk::DataNode::Pointer > nodes)
 A signal that will be emitted by the 'ChangeModelSelection'-function. This happens if the selection model of the private member item view has changed. More...
 

Public Member Functions

 QmitkModelViewSelectionConnector ()
 
void SetView (QAbstractItemView *view)
 Set the view whose selection model is used to propagate or receive selection changes. Use the view's data model to transform selected nodes into model indexes and vice versa. More...
 
QList< mitk::DataNode::PointerGetSelectedNodes () const
 Retrieve the currently selected nodes (equals the last CurrentSelectionChanged values). More...
 
bool GetSelectOnlyVisibleNodes () const
 

Detailed Description

The 'QmitkModelViewSelectionConnector' is used to handle the selections of a model-view-pair and to synchornize them with external node selections (e.g. communicated by the application).

The class accepts a view and its model, which are used to react to selection changes. This class is able to propagate selection changes to and receive from its surrounding class.

The model-view-pair can be added as a selection listener to a selection service. This should be done by using 'AddPostSelectionListener' with the existing selection service of the surrounding 'QmitkAbstractView'. The model-view-pair can be set as a selection provider. This should be done by using 'SetAsSelectionProvider' with the existing selection provider of the surrounding 'QmitkAbstractView'.

The 'QmitkModelViewSelectionConnector' offers a public slot and signal that can be used to set / propagate the selected nodes in the current view: The 'SetCurrentSelection'-slot finds the indices of the given selected nodes in its internal data storage model and changes the selection of the internal data storage model accordingly. The 'CurrentSelectionChanged'-signal sends a list of selected nodes to its environment. The 'CurrentSelectionChanged'-signal is emitted by the 'ChangeModelSelection'-function, which transforms the internal item view's selection into a data node list. The 'ChangeModelSelection'-function is called whenever the selection of the item view's selection model changes.

Definition at line 45 of file QmitkModelViewSelectionConnector.h.

Constructor & Destructor Documentation

◆ QmitkModelViewSelectionConnector()

QmitkModelViewSelectionConnector::QmitkModelViewSelectionConnector ( )

Member Function Documentation

◆ CurrentSelectionChanged

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

A signal that will be emitted by the 'ChangeModelSelection'-function. This happens if the selection model of the private member item view has changed.

Parameters
nodesA list of data nodes that are newly selected.

◆ GetSelectedNodes()

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

Retrieve the currently selected nodes (equals the last CurrentSelectionChanged values).

◆ GetSelectOnlyVisibleNodes()

bool QmitkModelViewSelectionConnector::GetSelectOnlyVisibleNodes ( ) const

◆ SetCurrentSelection

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

Transform a list of data nodes into a model selection and set this as a new selection of the selection model of the private member item view.

The function filters the given list of nodes according to the 'm_SelectOnlyVisibleNodes' member variable. If necessary, the non-visible nodes are stored. This is done if 'm_SelectOnlyVisibleNodes' is false: In this case the selection may be filtered and only a subset of the selected nodes may be visible and therefore (de-)selectable in the data storage viewer. By storing the non-visible nodes it is possible to send the new, modified selection but also include the selected nodes from the original selection that could not be modified (see 'SetSelectOnlyVisibleNodes').

Parameters
selectedNodesA list of data nodes that should be newly selected.

◆ SetSelectOnlyVisibleNodes

void QmitkModelViewSelectionConnector::SetSelectOnlyVisibleNodes ( bool  selectOnlyVisibleNodes)
slot

Change the selection mode of the item view's selection model.

If true, an incoming selection will be filtered (reduced) to only those nodes that are visible to the current view. An outgoing selection can then at most contain the filtered nodes. If false, the incoming non-visible selection will be stored and later added to the outgoing selection, to include the part of the original selection that was not visible. The part of the original selection, that is non-visible are the nodes that do not met the predicate of the associated QmitkAbstractDataStorageModel.

Parameters
selectOnlyVisibleNodesThe bool value to define the selection modus.

◆ SetView()

void QmitkModelViewSelectionConnector::SetView ( QAbstractItemView *  view)

Set the view whose selection model is used to propagate or receive selection changes. Use the view's data model to transform selected nodes into model indexes and vice versa.

Precondition
The view's data model needs to be a 'QmitkAbstractDataStorageModel'. If so, the data model is received from the view and stored as a private member. The data model must return 'mitk::DataNode::Pointer' objects for model indexes if the role is 'QmitkDataNodeRole'.
Exceptions
mitk::Exception,ifthe view is invalid or the view's data model is not a valid 'QmitkAbstractDataStorageModel'.
Parameters
viewThe view to set.

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