Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkDataStorageTableModel Class Reference

Own includes. More...

#include <QmitkDataStorageTableModel.h>

Inheritance diagram for QmitkDataStorageTableModel:
Collaboration diagram for QmitkDataStorageTableModel:

Classes

struct  DataNodeCompareFunction
 A struct that inherits from std::binary_function. You can use it in std::sort algorithm for sorting the node list elements. More...
 

Public Member Functions

 QmitkDataStorageTableModel (mitk::DataStorage::Pointer _DataStorage, mitk::NodePredicateBase *_Predicate=nullptr, QObject *parent=nullptr)
 
virtual ~QmitkDataStorageTableModel ()
 
const mitk::DataStorage::Pointer GetDataStorage () const
 
mitk::NodePredicateBase::Pointer GetPredicate () const
 
mitk::DataNode::Pointer GetNode (const QModelIndex &index) const
 
virtual QVariant headerData (int section, Qt::Orientation orientation, int role) const override
 
virtual Qt::ItemFlags flags (const QModelIndex &index) const override
 
virtual int rowCount (const QModelIndex &parent) const override
 
virtual int columnCount (const QModelIndex &parent) const override
 
virtual QVariant data (const QModelIndex &index, int role) const override
 
void SetDataStorage (mitk::DataStorage::Pointer _DataStorage)
 
void SetPredicate (mitk::NodePredicateBase *_Predicate)
 
virtual void AddNode (const mitk::DataNode *node)
 
virtual void RemoveNode (const mitk::DataNode *node)
 
virtual std::vector< mitk::DataNode * > GetNodeSet () const
 
virtual void PropertyModified (const itk::Object *caller, const itk::EventObject &event)
 Called when a single property was changed. The function searches through the list of nodes in this model for the changed property. If the property was found a dataChanged signal is emitted forcing all observing views to request the data again. More...
 
bool setData (const QModelIndex &index, const QVariant &value, int role) override
 
void sort (int column, Qt::SortOrder order=Qt::AscendingOrder) override
 Reimplemented sort function from QAbstractTableModel to enable sorting on the table. More...
 

Protected Member Functions

virtual void Reset ()
 

Protected Attributes

mitk::WeakPointer< mitk::DataStoragem_DataStorage
 
mitk::NodePredicateBase::Pointer m_Predicate
 
std::vector< mitk::DataNode * > m_NodeSet
 
std::map< mitk::BaseProperty *, unsigned long > m_NamePropertyModifiedObserverTags
 Maps a property to an observer tag. More...
 
std::map< mitk::BaseProperty *, unsigned long > m_VisiblePropertyModifiedObserverTags
 Maps a property to an observer tag. More...
 
bool m_BlockEvents
 
bool m_SortDescending
 The property is true when the property list is sorted in descending order. More...
 

Detailed Description

Own includes.

Toolkit includes. Forward declarations.

A table model for a set of DataNodes defined by a predicate. make columns interchangeable, select which properties to show as columns

Definition at line 40 of file QmitkDataStorageTableModel.h.

Constructor & Destructor Documentation

QmitkDataStorageTableModel::QmitkDataStorageTableModel ( mitk::DataStorage::Pointer  _DataStorage,
mitk::NodePredicateBase _Predicate = nullptr,
QObject *  parent = nullptr 
)

Constructs a new QmitkDataStorageTableModel and sets a predicate that defines this list.

See also
setPredicate()

Definition at line 33 of file QmitkDataStorageTableModel.cpp.

References SetDataStorage(), and SetPredicate().

QmitkDataStorageTableModel::~QmitkDataStorageTableModel ( )
virtual

Standard dtor. Delete predicate, disconnect from DataStorage.

Definition at line 46 of file QmitkDataStorageTableModel.cpp.

References SetDataStorage().

Member Function Documentation

void QmitkDataStorageTableModel::AddNode ( const mitk::DataNode node)
virtual

Adds a node to this model. There are two constraints for nodes in this model:

  1. If a predicate is set (not null) the node will be checked against it.
  2. The node has to have a data object (no one wants to see empty nodes). Also adds event listeners to the node.

Definition at line 236 of file QmitkDataStorageTableModel.cpp.

References mitk::DataNode::GetData(), mitk::DataNode::GetProperty(), m_BlockEvents, m_NamePropertyModifiedObserverTags, m_NodeSet, m_Predicate, m_VisiblePropertyModifiedObserverTags, mitk::New(), and PropertyModified().

Referenced by Reset(), and SetDataStorage().

int QmitkDataStorageTableModel::columnCount ( const QModelIndex &  parent) const
overridevirtual

Overridden from QAbstractTableModel. Returns the number of features (columns) to display.

Definition at line 124 of file QmitkDataStorageTableModel.cpp.

QVariant QmitkDataStorageTableModel::data ( const QModelIndex &  index,
int  role 
) const
overridevirtual
Qt::ItemFlags QmitkDataStorageTableModel::flags ( const QModelIndex &  index) const
overridevirtual

Overridden from QAbstractTableModel. Returns what can be done with an item.

Definition at line 102 of file QmitkDataStorageTableModel.cpp.

const mitk::DataStorage::Pointer QmitkDataStorageTableModel::GetDataStorage ( ) const

Get the DataStorage.

Definition at line 53 of file QmitkDataStorageTableModel.cpp.

References mitk::WeakPointer< TObjectType >::GetPointer(), and m_DataStorage.

mitk::DataNode::Pointer QmitkDataStorageTableModel::GetNode ( const QModelIndex &  index) const

Get node at a specific model index. Another way to implement this, is by introducing a new role like "DateTreeNode" and capture that in the data function.

Definition at line 63 of file QmitkDataStorageTableModel.cpp.

References m_NodeSet.

std::vector< mitk::DataNode * > QmitkDataStorageTableModel::GetNodeSet ( ) const
virtual

Returns a copy of the node-vector that is shown by this model

Definition at line 469 of file QmitkDataStorageTableModel.cpp.

References m_NodeSet.

mitk::NodePredicateBase::Pointer QmitkDataStorageTableModel::GetPredicate ( ) const

Get the predicate.

Definition at line 58 of file QmitkDataStorageTableModel.cpp.

References m_Predicate.

QVariant QmitkDataStorageTableModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role 
) const
overridevirtual

Overridden from QAbstractTableModel. Returns the header data at section for given orientation and role.

Definition at line 75 of file QmitkDataStorageTableModel.cpp.

void QmitkDataStorageTableModel::PropertyModified ( const itk::Object *  caller,
const itk::EventObject &  event 
)
virtual

Called when a single property was changed. The function searches through the list of nodes in this model for the changed property. If the property was found a dataChanged signal is emitted forcing all observing views to request the data again.

Definition at line 317 of file QmitkDataStorageTableModel.cpp.

References m_BlockEvents, and m_NodeSet.

Referenced by AddNode().

void QmitkDataStorageTableModel::RemoveNode ( const mitk::DataNode node)
virtual

Removes a node from this model. Also removes any event listener from the node.

Definition at line 278 of file QmitkDataStorageTableModel.cpp.

References m_BlockEvents, m_NamePropertyModifiedObserverTags, m_NodeSet, and m_VisiblePropertyModifiedObserverTags.

Referenced by Reset(), and SetDataStorage().

void QmitkDataStorageTableModel::Reset ( void  )
protectedvirtual
int QmitkDataStorageTableModel::rowCount ( const QModelIndex &  parent) const
overridevirtual

Overridden from QAbstractTableModel. Returns the node count.

Definition at line 119 of file QmitkDataStorageTableModel.cpp.

References m_NodeSet.

bool QmitkDataStorageTableModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role 
)
override

Overridden from QAbstractTableModel. Sets data at index for given role.

Definition at line 364 of file QmitkDataStorageTableModel.cpp.

References mitk::RenderingManager::GetInstance(), m_BlockEvents, m_NodeSet, and mitk::RenderingManager::RequestUpdateAll().

void QmitkDataStorageTableModel::SetPredicate ( mitk::NodePredicateBase _Predicate)

Sets the predicate. QmitkDataStorageTableModel is owner of the predicate!

Definition at line 188 of file QmitkDataStorageTableModel.cpp.

References m_Predicate, and Reset().

Referenced by QmitkDataStorageTableModel().

void QmitkDataStorageTableModel::sort ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)
override

Member Data Documentation

bool QmitkDataStorageTableModel::m_BlockEvents
protected

Saves if this model is currently working on events to prevent endless event loops.

Definition at line 220 of file QmitkDataStorageTableModel.h.

Referenced by AddNode(), PropertyModified(), RemoveNode(), and setData().

mitk::WeakPointer<mitk::DataStorage> QmitkDataStorageTableModel::m_DataStorage
protected

Pointer to the DataStorage from which the nodes are selected (remember: in BlueBerry there might be more than one DataStorage). Store it in a weak pointer. This is a GUI class which should not hold a strong reference to any non-GUI Object.

Definition at line 199 of file QmitkDataStorageTableModel.h.

Referenced by GetDataStorage(), Reset(), and SetDataStorage().

std::map<mitk::BaseProperty *, unsigned long> QmitkDataStorageTableModel::m_NamePropertyModifiedObserverTags
protected

Maps a property to an observer tag.

Definition at line 212 of file QmitkDataStorageTableModel.h.

Referenced by AddNode(), RemoveNode(), and Reset().

std::vector<mitk::DataNode *> QmitkDataStorageTableModel::m_NodeSet
protected

Holds all selected Nodes.

Definition at line 208 of file QmitkDataStorageTableModel.h.

Referenced by AddNode(), data(), GetNode(), GetNodeSet(), PropertyModified(), RemoveNode(), Reset(), rowCount(), setData(), and sort().

mitk::NodePredicateBase::Pointer QmitkDataStorageTableModel::m_Predicate
protected

Holds the predicate that defines this SubSet of Nodes. If m_Predicate is NULL all Nodes will be selected.

Definition at line 204 of file QmitkDataStorageTableModel.h.

Referenced by AddNode(), GetPredicate(), Reset(), and SetPredicate().

bool QmitkDataStorageTableModel::m_SortDescending
protected

The property is true when the property list is sorted in descending order.

Definition at line 224 of file QmitkDataStorageTableModel.h.

std::map<mitk::BaseProperty *, unsigned long> QmitkDataStorageTableModel::m_VisiblePropertyModifiedObserverTags
protected

Maps a property to an observer tag.

Definition at line 216 of file QmitkDataStorageTableModel.h.

Referenced by AddNode(), RemoveNode(), and Reset().


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