Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
QmitkDataStorageListModel Class Reference

#include <QmitkDataStorageListModel.h>

Inheritance diagram for QmitkDataStorageListModel:
Collaboration diagram for QmitkDataStorageListModel:

Public Member Functions

 QmitkDataStorageListModel (mitk::DataStorage *dataStorage=nullptr, mitk::NodePredicateBase::Pointer pred=nullptr, QObject *parent=nullptr)
 
 ~QmitkDataStorageListModel () override
 
void SetDataStorage (mitk::DataStorage::Pointer dataStorage)
 Change the data storage to represent. More...
 
mitk::DataStorageGetDataStorage () const
 Get the represented data storage. More...
 
void SetPredicate (mitk::NodePredicateBase *pred)
 Change the filter predicate. More...
 
mitk::NodePredicateBaseGetPredicate () const
 Get the filter predicate in use. More...
 
std::vector< mitk::DataNode * > GetDataNodes () const
 Get all current data nodes. More...
 
mitk::DataNode::Pointer getNode (const QModelIndex &index) const
 Return the node for given model index. More...
 
QModelIndex getIndex (const mitk::DataNode *node) const
 Return the model index of the given node. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Implements QAbstractListModel. More...
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Implements QAbstractListModel. More...
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 Implements QAbstractListModel. More...
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Implements QAbstractListModel. More...
 
virtual void OnDataStorageNodeAdded (const mitk::DataNode *node)
 
virtual void OnDataStorageNodeRemoved (const mitk::DataNode *node)
 
virtual void OnDataNodeModified (const itk::Object *caller, const itk::EventObject &event)
 
virtual void OnDataModified (const itk::Object *caller, const itk::EventObject &event)
 
virtual void OnDataStorageDeleted (const itk::Object *caller, const itk::EventObject &event)
 

Protected Member Functions

void reset ()
 Resets the whole model. Get all nodes matching the predicate from the data storage. More...
 
void AddNodeToInternalList (mitk::DataNode *node)
 Internal helper: adds given node to end of list. More...
 
void RemoveNodeFromInternalList (mitk::DataNode *node)
 Internal helper: remove given node. More...
 
void ClearInternalNodeList ()
 Internal helper: Clear complete model list. More...
 

Detailed Description

Qt list model for the (optionally filtered) nodes in a DataStorage.

Given a data storage instance, this model will observe the storage for its list of nodes and keep the provided Qt model up to date. When given a NodePredicateBase instance, the Qt model will only contain nodes that satisfy the predicate. This is useful to display lists of a certain data type only, for example.

Developer notes:

  • class should be reviewed by somebody who knows well Qt models
  • The OnSomethingModifedAddedRemoved() methods are declared virtual. They are required to be executed on event reception, though! They should not be virtual.
  • Is there any valid use case for sub-classing? Declare class final?
  • Is GetDataNodes needed? DataStorage or Qt model would yield the same result.

Definition at line 41 of file QmitkDataStorageListModel.h.

Constructor & Destructor Documentation

◆ QmitkDataStorageListModel()

QmitkDataStorageListModel::QmitkDataStorageListModel ( mitk::DataStorage dataStorage = nullptr,
mitk::NodePredicateBase::Pointer  pred = nullptr,
QObject *  parent = nullptr 
)
Parameters
dataStoragethe data storage to represent
predthe optional predicate to filter filters
parentthe Qt parent of this Qt object

◆ ~QmitkDataStorageListModel()

QmitkDataStorageListModel::~QmitkDataStorageListModel ( )
override

Member Function Documentation

◆ AddNodeToInternalList()

void QmitkDataStorageListModel::AddNodeToInternalList ( mitk::DataNode node)
protected

Internal helper: adds given node to end of list.

◆ ClearInternalNodeList()

void QmitkDataStorageListModel::ClearInternalNodeList ( )
protected

Internal helper: Clear complete model list.

◆ data()

QVariant QmitkDataStorageListModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

Implements QAbstractListModel.

◆ flags()

Qt::ItemFlags QmitkDataStorageListModel::flags ( const QModelIndex &  index) const
override

Implements QAbstractListModel.

◆ GetDataNodes()

std::vector<mitk::DataNode *> QmitkDataStorageListModel::GetDataNodes ( ) const

Get all current data nodes.

◆ GetDataStorage()

mitk::DataStorage* QmitkDataStorageListModel::GetDataStorage ( ) const

Get the represented data storage.

◆ getIndex()

QModelIndex QmitkDataStorageListModel::getIndex ( const mitk::DataNode node) const

Return the model index of the given node.

◆ getNode()

mitk::DataNode::Pointer QmitkDataStorageListModel::getNode ( const QModelIndex &  index) const

Return the node for given model index.

◆ GetPredicate()

mitk::NodePredicateBase* QmitkDataStorageListModel::GetPredicate ( ) const

Get the filter predicate in use.

◆ headerData()

QVariant QmitkDataStorageListModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

Implements QAbstractListModel.

◆ OnDataModified()

virtual void QmitkDataStorageListModel::OnDataModified ( const itk::Object *  caller,
const itk::EventObject &  event 
)
virtual

Callback entry for observed BaseDatas' ModifiedEvent().

Emits signal dataChanged().

◆ OnDataNodeModified()

virtual void QmitkDataStorageListModel::OnDataNodeModified ( const itk::Object *  caller,
const itk::EventObject &  event 
)
virtual

Callback entry for observed DataNodes' ModifiedEvent().

Emits signal dataChanged().

◆ OnDataStorageDeleted()

virtual void QmitkDataStorageListModel::OnDataStorageDeleted ( const itk::Object *  caller,
const itk::EventObject &  event 
)
virtual

Callback entry for DataStorage's DeleteEvent().

Clears the model.

◆ OnDataStorageNodeAdded()

virtual void QmitkDataStorageListModel::OnDataStorageNodeAdded ( const mitk::DataNode node)
virtual

Called when a DataStorage Add Event was thrown. May be reimplemented by deriving classes.

Warning
When sub-classing, call this class' method first! Otherwise the node addition will not be reflected in the Qt model!

◆ OnDataStorageNodeRemoved()

virtual void QmitkDataStorageListModel::OnDataStorageNodeRemoved ( const mitk::DataNode node)
virtual

Called when a DataStorage Remove Event was thrown. May be reimplemented by deriving classes.

Warning
When sub-classing, call this class' method first! Otherwise the node removal will not be reflected in the Qt model!

◆ RemoveNodeFromInternalList()

void QmitkDataStorageListModel::RemoveNodeFromInternalList ( mitk::DataNode node)
protected

Internal helper: remove given node.

◆ reset()

void QmitkDataStorageListModel::reset ( )
protected

Resets the whole model. Get all nodes matching the predicate from the data storage.

◆ rowCount()

int QmitkDataStorageListModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Implements QAbstractListModel.

◆ SetDataStorage()

void QmitkDataStorageListModel::SetDataStorage ( mitk::DataStorage::Pointer  dataStorage)

Change the data storage to represent.

◆ SetPredicate()

void QmitkDataStorageListModel::SetPredicate ( mitk::NodePredicateBase pred)

Change the filter predicate.


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