Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkDataStorageTreeModel Class Reference

#include <QmitkDataStorageTreeModel.h>

Inheritance diagram for QmitkDataStorageTreeModel:
Collaboration diagram for QmitkDataStorageTreeModel:

Signals

void nodeVisibilityChanged ()
 

Public Member Functions

 QmitkDataStorageTreeModel (mitk::DataStorage *_DataStorage, bool _PlaceNewNodesOnTop=false, QObject *parent=nullptr)
 
 ~QmitkDataStorageTreeModel () override
 
mitk::DataNode::Pointer GetNode (const QModelIndex &index) const
 
virtual QList< mitk::DataNode::PointerGetNodeSet () const
 
const mitk::DataStorage::Pointer GetDataStorage () const
 
bool GetPlaceNewNodesOnTopFlag ()
 
void SetPlaceNewNodesOnTop (bool _PlaceNewNodesOnTop)
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex index (int row, int column, const QModelIndex &parent=QModelIndex()) const override
 
QModelIndex parent (const QModelIndex &index) const override
 
bool setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
 
bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override
 
bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 
Qt::DropActions supportedDropActions () const override
 
Qt::DropActions supportedDragActions () const override
 
QStringList mimeTypes () const override
 
QMimeData * mimeData (const QModelIndexList &indexes) const override
 
void SetDataStorage (mitk::DataStorage *_DataStorage)
 
void SetDataStorageDeleted ()
 
virtual void AddNode (const mitk::DataNode *node)
 
virtual void RemoveNode (const mitk::DataNode *node)
 
virtual void SetNodeModified (const mitk::DataNode *node)
 
QModelIndex GetIndex (const mitk::DataNode *) const
 
void SetAllowHierarchyChange (bool allowHierarchyChange)
 Set whether to allow hierarchy changes by dragging and dropping. More...
 

Static Public Member Functions

static QMimeData * mimeDataFromModelIndexList (const QModelIndexList &indexes)
 

Static Public Attributes

static const std::string COLUMN_NAME
 
static const std::string COLUMN_TYPE
 
static const std::string COLUMN_VISIBILITY
 

Protected Types

using TreeItem = QmitkDataStorageTreeModelInternalItem
 

Protected Member Functions

QList< TreeItem * > ToTreeItemPtrList (const QMimeData *mimeData)
 
QList< TreeItem * > ToTreeItemPtrList (const QByteArray &ba)
 
void AdjustLayerProperty ()
 
TreeItemTreeItemFromIndex (const QModelIndex &index) const
 
QModelIndex IndexFromTreeItem (TreeItem *) const
 
mitk::DataNodeGetParentNode (const mitk::DataNode *node) const
 
void TreeToVector (TreeItem *parent, std::vector< TreeItem *> &vec) const
 
void TreeToNodeSet (TreeItem *parent, QList< mitk::DataNode::Pointer > &vec) const
 
void Update ()
 

Protected Attributes

mitk::WeakPointer< mitk::DataStoragem_DataStorage
 
mitk::NodePredicateBase::Pointer m_Predicate
 
bool m_PlaceNewNodesOnTop
 
TreeItemm_Root
 
bool m_BlockDataStorageEvents
 Flag to block the data storage events if nodes are added/removed by this class. More...
 
bool m_AllowHierarchyChange
 

Detailed Description

Warning
This class causes invalid point exception when used with invalid QModelIndex instances. The index validation is not sufficient. This may cause unspecific crashes in situation where this class is used multiple times or with multiple selection models. See https://phabricator.mitk.org/T24348 for more information.

Definition at line 39 of file QmitkDataStorageTreeModel.h.

Member Typedef Documentation

◆ TreeItem

Constructor & Destructor Documentation

◆ QmitkDataStorageTreeModel()

QmitkDataStorageTreeModel::QmitkDataStorageTreeModel ( mitk::DataStorage _DataStorage,
bool  _PlaceNewNodesOnTop = false,
QObject *  parent = nullptr 
)

Definition at line 41 of file QmitkDataStorageTreeModel.cpp.

References SetDataStorage().

◆ ~QmitkDataStorageTreeModel()

QmitkDataStorageTreeModel::~QmitkDataStorageTreeModel ( )
override

Member Function Documentation

◆ AddNode()

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

Adds a node to this model. If a predicate is set (not null) the node will be checked against it.The node has to have a data object (no one wants to see empty nodes).

Definition at line 635 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::Find(), mitk::WeakPointer< T >::IsExpired(), mitk::WeakPointer< T >::Lock(), m_BlockDataStorageEvents, m_DataStorage, and m_Root.

Referenced by SetDataStorage(), and SetDataStorageDeleted().

◆ AdjustLayerProperty()

void QmitkDataStorageTreeModel::AdjustLayerProperty ( )
protected

Adjusts the LayerProperty according to the nodes position

transform the tree into an array and set the layer property descending

Definition at line 762 of file QmitkDataStorageTreeModel.cpp.

References mitk::RenderingManager::GetInstance(), m_Root, mitk::RenderingManager::RequestUpdateAll(), and TreeToVector().

Referenced by dropMimeData(), SetDataStorageDeleted(), SetPlaceNewNodesOnTop(), and Update().

◆ columnCount()

int QmitkDataStorageTreeModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Definition at line 107 of file QmitkDataStorageTreeModel.cpp.

◆ data()

◆ dropMimeData()

◆ flags()

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

Definition at line 94 of file QmitkDataStorageTreeModel.cpp.

◆ GetDataStorage()

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

Get the DataStorage.

Definition at line 67 of file QmitkDataStorageTreeModel.cpp.

References mitk::WeakPointer< T >::Lock(), and m_DataStorage.

◆ GetIndex()

QModelIndex QmitkDataStorageTreeModel::GetIndex ( const mitk::DataNode node) const
Returns
an index for the given datatreenode in the tree. If the node is not found

Definition at line 821 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::Find(), IndexFromTreeItem(), and m_Root.

◆ GetNode()

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

Get node at a specific model index. This function is used to get a node from a QModelIndex

Definition at line 62 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::GetDataNode(), and TreeItemFromIndex().

Referenced by QmitkDataStorageFilterProxyModel::filterAcceptsRow().

◆ GetNodeSet()

QList< mitk::DataNode::Pointer > QmitkDataStorageTreeModel::GetNodeSet ( ) const
virtual

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

Definition at line 801 of file QmitkDataStorageTreeModel.cpp.

References m_Root, and TreeToNodeSet().

Referenced by QmitkDataManagerView::NodeSelectionChanged().

◆ GetParentNode()

mitk::DataNode * QmitkDataStorageTreeModel::GetParentNode ( const mitk::DataNode node) const
protected

Returns the first element in the nodes sources list (if available) or 0

Definition at line 711 of file QmitkDataStorageTreeModel.cpp.

References mitk::WeakPointer< T >::Lock(), and m_DataStorage.

Referenced by SetDataStorageDeleted().

◆ GetPlaceNewNodesOnTopFlag()

bool QmitkDataStorageTreeModel::GetPlaceNewNodesOnTopFlag ( )
inline

Get the top placement flag

Definition at line 73 of file QmitkDataStorageTreeModel.h.

References AddNode.

Referenced by QmitkDataManagerView::OnPreferencesChanged().

◆ headerData()

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

◆ index()

QModelIndex QmitkDataStorageTreeModel::index ( int  row,
int  column,
const QModelIndex &  parent = QModelIndex() 
) const
override

called whenever the model or the view needs to create a QModelIndex for a particular child item (or a top-level item if parent is an invalid QModelIndex)

Definition at line 72 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::GetChild(), and m_Root.

Referenced by SetDataStorageDeleted(), and SetNodeModified().

◆ IndexFromTreeItem()

QModelIndex QmitkDataStorageTreeModel::IndexFromTreeItem ( TreeItem item) const
protected

Gives a ModelIndex for the Tree Item

Definition at line 793 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::GetIndex(), and m_Root.

Referenced by dropMimeData(), GetIndex(), and SetPlaceNewNodesOnTop().

◆ mimeData()

QMimeData * QmitkDataStorageTreeModel::mimeData ( const QModelIndexList &  indexes) const
override

Definition at line 371 of file QmitkDataStorageTreeModel.cpp.

References mimeDataFromModelIndexList().

◆ mimeDataFromModelIndexList()

QMimeData * QmitkDataStorageTreeModel::mimeDataFromModelIndexList ( const QModelIndexList &  indexes)
static

◆ mimeTypes()

QStringList QmitkDataStorageTreeModel::mimeTypes ( ) const
override

Definition at line 363 of file QmitkDataStorageTreeModel.cpp.

◆ nodeVisibilityChanged

void QmitkDataStorageTreeModel::nodeVisibilityChanged ( )
signal

◆ parent()

QModelIndex QmitkDataStorageTreeModel::parent ( const QModelIndex &  index) const
override

◆ RemoveNode()

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

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

Definition at line 687 of file QmitkDataStorageTreeModel.cpp.

References m_BlockDataStorageEvents.

Referenced by SetDataStorage().

◆ rowCount()

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

◆ SetAllowHierarchyChange()

void QmitkDataStorageTreeModel::SetAllowHierarchyChange ( bool  allowHierarchyChange)

Set whether to allow hierarchy changes by dragging and dropping.

Definition at line 877 of file QmitkDataStorageTreeModel.cpp.

References m_AllowHierarchyChange.

Referenced by QmitkDataManagerView::CreateQtPartControl(), and QmitkDataManagerView::OnPreferencesChanged().

◆ setData()

bool QmitkDataStorageTreeModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

◆ SetDataStorage()

◆ SetDataStorageDeleted()

◆ setHeaderData()

bool QmitkDataStorageTreeModel::setHeaderData ( int  section,
Qt::Orientation  orientation,
const QVariant &  value,
int  role = Qt::EditRole 
)
override

Definition at line 754 of file QmitkDataStorageTreeModel.cpp.

◆ SetNodeModified()

void QmitkDataStorageTreeModel::SetNodeModified ( const mitk::DataNode node)
virtual

◆ SetPlaceNewNodesOnTop()

◆ supportedDragActions()

Qt::DropActions QmitkDataStorageTreeModel::supportedDragActions ( ) const
override

Definition at line 138 of file QmitkDataStorageTreeModel.cpp.

◆ supportedDropActions()

Qt::DropActions QmitkDataStorageTreeModel::supportedDropActions ( ) const
override

Definition at line 133 of file QmitkDataStorageTreeModel.cpp.

◆ ToTreeItemPtrList() [1/2]

QList< QmitkDataStorageTreeModel::TreeItem * > QmitkDataStorageTreeModel::ToTreeItemPtrList ( const QMimeData *  mimeData)
protected

Definition at line 832 of file QmitkDataStorageTreeModel.cpp.

References QmitkMimeTypes::DataStorageTreeItemPtrs.

Referenced by dropMimeData().

◆ ToTreeItemPtrList() [2/2]

QList< QmitkDataStorageTreeModel::TreeItem * > QmitkDataStorageTreeModel::ToTreeItemPtrList ( const QByteArray &  ba)
protected

Definition at line 841 of file QmitkDataStorageTreeModel.cpp.

◆ TreeItemFromIndex()

QmitkDataStorageTreeModel::TreeItem * QmitkDataStorageTreeModel::TreeItemFromIndex ( const QModelIndex &  index) const
protected

invoked after m_DataStorage or m_Predicate changed

Definition at line 126 of file QmitkDataStorageTreeModel.cpp.

References m_Root.

Referenced by data(), dropMimeData(), GetNode(), parent(), rowCount(), and setData().

◆ TreeToNodeSet()

void QmitkDataStorageTreeModel::TreeToNodeSet ( TreeItem parent,
QList< mitk::DataNode::Pointer > &  vec 
) const
protected

Adds all Childs in parent to vec. Before a child is added the function is called recursively

Definition at line 810 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::GetChild(), QmitkDataStorageTreeModelInternalItem::GetChildCount(), and QmitkDataStorageTreeModelInternalItem::GetDataNode().

Referenced by GetNodeSet().

◆ TreeToVector()

void QmitkDataStorageTreeModel::TreeToVector ( TreeItem parent,
std::vector< TreeItem *> &  vec 
) const
protected

Adds all Childs in parent to vec. Before a child is added the function is called recursively

Definition at line 782 of file QmitkDataStorageTreeModel.cpp.

References QmitkDataStorageTreeModelInternalItem::GetChild(), and QmitkDataStorageTreeModelInternalItem::GetChildCount().

Referenced by AdjustLayerProperty().

◆ Update()

void QmitkDataStorageTreeModel::Update ( )
protected

Update Tree Model

Regardless the value of this preference, the new nodes must not be inserted at the top now, but at the position according to their layer.

Adjust the layers to ensure that derived nodes are above their sources.

Definition at line 854 of file QmitkDataStorageTreeModel.cpp.

References AdjustLayerProperty(), mitk::WeakPointer< T >::IsExpired(), mitk::WeakPointer< T >::Lock(), m_DataStorage, and m_PlaceNewNodesOnTop.

Referenced by SetDataStorage().

Member Data Documentation

◆ COLUMN_NAME

const std::string QmitkDataStorageTreeModel::COLUMN_NAME
static

Definition at line 45 of file QmitkDataStorageTreeModel.h.

◆ COLUMN_TYPE

const std::string QmitkDataStorageTreeModel::COLUMN_TYPE
static

Definition at line 46 of file QmitkDataStorageTreeModel.h.

◆ COLUMN_VISIBILITY

const std::string QmitkDataStorageTreeModel::COLUMN_VISIBILITY
static

Definition at line 47 of file QmitkDataStorageTreeModel.h.

◆ m_AllowHierarchyChange

bool QmitkDataStorageTreeModel::m_AllowHierarchyChange
protected

This decides whether or not it is allowed to assign a different parent to a node If it is false, it is not possible to change the hierarchy of nodes by dragging and dropping. If it is true, dragging nodes on another node will replace all of their parents with that one.

Definition at line 196 of file QmitkDataStorageTreeModel.h.

Referenced by dropMimeData(), and SetAllowHierarchyChange().

◆ m_BlockDataStorageEvents

bool QmitkDataStorageTreeModel::m_BlockDataStorageEvents
protected

Flag to block the data storage events if nodes are added/removed by this class.

Definition at line 189 of file QmitkDataStorageTreeModel.h.

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

◆ m_DataStorage

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

◆ m_PlaceNewNodesOnTop

bool QmitkDataStorageTreeModel::m_PlaceNewNodesOnTop
protected

◆ m_Predicate

mitk::NodePredicateBase::Pointer QmitkDataStorageTreeModel::m_Predicate
protected

Definition at line 184 of file QmitkDataStorageTreeModel.h.

Referenced by SetDataStorage().

◆ m_Root


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