Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkDataStorageSimpleTreeModel.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkDataStorageSimpleTreeModel_h
14 #define QmitkDataStorageSimpleTreeModel_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 // qt widgets module
20 
22 
42 {
43  Q_OBJECT
44 
45 public:
52 
54  void DataStorageChanged() override;
55 
57  void NodePredicateChanged() override;
58 
63  void NodeAdded(const mitk::DataNode *node) override;
64 
69  void NodeChanged(const mitk::DataNode *node) override;
70 
75  void NodeRemoved(const mitk::DataNode *node) override;
76 
84  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
85 
91  QModelIndex parent(const QModelIndex &child) const override;
92 
98  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
99 
105  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
106 
113  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
114 
122  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
123 
131  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
132 
138  Qt::ItemFlags flags(const QModelIndex &index) const override;
139 
140 protected:
142 
143 private:
144  void UpdateModelData();
145  void AddNodeInternal(const mitk::DataNode *node);
146 
147  mitk::DataNode *GetParentNode(const mitk::DataNode *node) const;
148 
149  TreeItem *TreeItemFromIndex(const QModelIndex &index) const;
150  QModelIndex IndexFromTreeItem(TreeItem *item) const;
151 
152  void ResetTree();
153 
154  TreeItem *m_Root;
155 
158  std::list<const TreeItem*> m_TreeItems;
159 };
160 
161 #endif
#define MITKQTWIDGETS_EXPORT
Abstract base class extending QAbstractItemModel for DataStorage-backed models.
Lightweight tree model for DataStorage contents.
void NodeChanged(const mitk::DataNode *node) override
Called when a node in the data storage has changed.
void NodePredicateChanged() override
Called when the node predicate has changed. Rebuilds the tree.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for the given index and role.
QmitkDataStorageSimpleTreeModel(QObject *parent)
Constructs the tree model.
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
Returns header data for the given section.
void DataStorageChanged() override
Called when the data storage has changed. Rebuilds the tree.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns item flags for the given index.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns (always 1).
void NodeAdded(const mitk::DataNode *node) override
Called when a node is added to the data storage.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets data at the given index (supports renaming nodes).
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of child rows under the given parent.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the given row and column under the given parent.
void NodeRemoved(const mitk::DataNode *node) override
Called when a node is removed from the data storage.
QModelIndex parent(const QModelIndex &child) const override
Returns the parent index for the given child.
Helper class representing a node in a tree structure of DataNodes.
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72