Medical Imaging Interaction Toolkit
2024.06.00
Medical Imaging Interaction Toolkit
|
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>
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::Pointer > | GetSelectedNodes () const |
Retrieve the currently selected nodes (equals the last CurrentSelectionChanged values). More... | |
bool | GetSelectOnlyVisibleNodes () const |
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.
QmitkModelViewSelectionConnector::QmitkModelViewSelectionConnector | ( | ) |
|
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.
nodes | A list of data nodes that are newly selected. |
QList<mitk::DataNode::Pointer> QmitkModelViewSelectionConnector::GetSelectedNodes | ( | ) | const |
Retrieve the currently selected nodes (equals the last CurrentSelectionChanged values).
bool QmitkModelViewSelectionConnector::GetSelectOnlyVisibleNodes | ( | ) | const |
|
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').
selectedNodes | A list of data nodes that should be newly selected. |
|
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.
selectOnlyVisibleNodes | The bool value to define the selection modus. |
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.
mitk::Exception,if | the view is invalid or the view's data model is not a valid 'QmitkAbstractDataStorageModel'. |
view | The view to set. |