Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
#include <QmitkDataStorageListModel.h>
Public Member Functions | |
QmitkDataStorageListModel (mitk::DataStorage *dataStorage=nullptr, mitk::NodePredicateBase::Pointer pred=nullptr, QObject *parent=nullptr) | |
virtual | ~QmitkDataStorageListModel () |
void | SetDataStorage (mitk::DataStorage::Pointer dataStorage) |
Change the data storage to represent. More... | |
mitk::DataStorage * | GetDataStorage () const |
Get the represented data storage. More... | |
void | SetPredicate (mitk::NodePredicateBase *pred) |
Change the filter predicate. More... | |
mitk::NodePredicateBase * | GetPredicate () 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... | |
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:
Definition at line 45 of file QmitkDataStorageListModel.h.
QmitkDataStorageListModel::QmitkDataStorageListModel | ( | mitk::DataStorage * | dataStorage = nullptr , |
mitk::NodePredicateBase::Pointer | pred = nullptr , |
||
QObject * | parent = nullptr |
||
) |
dataStorage | the data storage to represent |
predicate | the optional predicate to filter filters |
parent | the Qt parent of this Qt object |
Definition at line 27 of file QmitkDataStorageListModel.cpp.
References SetDataStorage(), and SetPredicate().
|
virtual |
Definition at line 36 of file QmitkDataStorageListModel.cpp.
References SetDataStorage().
|
protected |
Internal helper: adds given node to end of list.
Definition at line 175 of file QmitkDataStorageListModel.cpp.
References mitk::DataNode::GetData(), mitk::New(), OnDataModified(), and OnDataNodeModified().
Referenced by OnDataStorageNodeAdded(), and reset().
|
protected |
Internal helper: Clear complete model list.
Definition at line 199 of file QmitkDataStorageListModel.cpp.
Referenced by reset().
|
override |
Implements QAbstractListModel.
Definition at line 92 of file QmitkDataStorageListModel.cpp.
References mitk::DataNode::GetName().
|
override |
Implements QAbstractListModel.
Definition at line 87 of file QmitkDataStorageListModel.cpp.
std::vector< mitk::DataNode * > QmitkDataStorageListModel::GetDataNodes | ( | ) | const |
Get all current data nodes.
Definition at line 115 of file QmitkDataStorageListModel.cpp.
mitk::DataStorage * QmitkDataStorageListModel::GetDataStorage | ( | ) | const |
Get the represented data storage.
Definition at line 126 of file QmitkDataStorageListModel.cpp.
QModelIndex QmitkDataStorageListModel::getIndex | ( | const mitk::DataNode * | node | ) | const |
Return the model index of the given node.
Definition at line 323 of file QmitkDataStorageListModel.cpp.
Referenced by OnDataNodeModified().
mitk::DataNode::Pointer QmitkDataStorageListModel::getNode | ( | const QModelIndex & | index | ) | const |
Return the node for given model index.
Definition at line 311 of file QmitkDataStorageListModel.cpp.
Referenced by QmlMitkDatamanager::deleteNode(), QmlMitkDatamanager::reinitNode(), QmlMitkDatamanager::setIndex(), and QmlMitkDatamanager::toggleVisibility().
mitk::NodePredicateBase * QmitkDataStorageListModel::GetPredicate | ( | ) | const |
Get the filter predicate in use.
Definition at line 142 of file QmitkDataStorageListModel.cpp.
|
override |
Implements QAbstractListModel.
Definition at line 105 of file QmitkDataStorageListModel.cpp.
|
virtual |
Callback entry for observed BaseDatas' ModifiedEvent().
Emits signal dataChanged().
Definition at line 297 of file QmitkDataStorageListModel.cpp.
References OnDataNodeModified().
Referenced by AddNodeToInternalList().
|
virtual |
Callback entry for observed DataNodes' ModifiedEvent().
Emits signal dataChanged().
Definition at line 281 of file QmitkDataStorageListModel.cpp.
References getIndex().
Referenced by AddNodeToInternalList(), and OnDataModified().
|
virtual |
Callback entry for DataStorage's DeleteEvent().
Clears the model.
Definition at line 302 of file QmitkDataStorageListModel.cpp.
References SetDataStorage().
Referenced by SetDataStorage().
|
virtual |
Called when a DataStorage Add Event was thrown. May be reimplemented by deriving classes.
Definition at line 233 of file QmitkDataStorageListModel.cpp.
References AddNodeToInternalList().
Referenced by SetDataStorage().
|
virtual |
Called when a DataStorage Remove Event was thrown. May be reimplemented by deriving classes.
Definition at line 257 of file QmitkDataStorageListModel.cpp.
References RemoveNodeFromInternalList().
Referenced by SetDataStorage().
|
protected |
Internal helper: remove given node.
Definition at line 216 of file QmitkDataStorageListModel.cpp.
References mitk::DataNode::GetData().
Referenced by OnDataStorageNodeRemoved().
|
protected |
Resets the whole model. Get all nodes matching the predicate from the data storage.
Definition at line 147 of file QmitkDataStorageListModel.cpp.
References AddNodeToInternalList(), ClearInternalNodeList(), mitk::DataStorage::GetAll(), and mitk::DataStorage::GetSubset().
Referenced by SetDataStorage(), and SetPredicate().
|
override |
Implements QAbstractListModel.
Definition at line 110 of file QmitkDataStorageListModel.cpp.
void QmitkDataStorageListModel::SetDataStorage | ( | mitk::DataStorage::Pointer | dataStorage | ) |
Change the data storage to represent.
Definition at line 42 of file QmitkDataStorageListModel.cpp.
References mitk::MessageBase< AbstractDelegate >::AddListener(), mitk::DataStorage::AddNodeEvent, mitk::New(), OnDataStorageDeleted(), OnDataStorageNodeAdded(), OnDataStorageNodeRemoved(), mitk::MessageBase< AbstractDelegate >::RemoveListener(), mitk::DataStorage::RemoveNodeEvent, and reset().
Referenced by OnDataStorageDeleted(), QmitkDataStorageListModel(), and ~QmitkDataStorageListModel().
void QmitkDataStorageListModel::SetPredicate | ( | mitk::NodePredicateBase * | pred | ) |
Change the filter predicate.
Definition at line 131 of file QmitkDataStorageListModel.cpp.
References reset().
Referenced by QmitkDataStorageListModel().