Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
QmitkDataStorageListModel.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #ifndef QmitkDataStorageListModel_h
18 #define QmitkDataStorageListModel_h
19 
20 #include <MitkQtWidgetsExports.h>
21 
22 // MITK
23 #include "mitkDataStorage.h"
24 #include "mitkNodePredicateBase.h"
25 
26 // Qt
27 #include <QAbstractListModel>
28 
44 
45 class MITKQTWIDGETS_EXPORT QmitkDataStorageListModel : public QAbstractListModel
46 {
47 public:
51  QmitkDataStorageListModel(mitk::DataStorage *dataStorage = nullptr,
52  mitk::NodePredicateBase::Pointer pred = nullptr,
53  QObject *parent = nullptr);
54 
55  virtual ~QmitkDataStorageListModel();
56 
58  void SetDataStorage(mitk::DataStorage::Pointer dataStorage);
59 
62 
64  void SetPredicate(mitk::NodePredicateBase *pred);
65 
67  mitk::NodePredicateBase *GetPredicate() const;
68 
70  std::vector<mitk::DataNode *> GetDataNodes() const;
71 
73  mitk::DataNode::Pointer getNode(const QModelIndex &index) const;
74 
76  QModelIndex getIndex(const mitk::DataNode *node) const;
77 
79  Qt::ItemFlags flags(const QModelIndex &index) const override;
80 
82  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
83 
85  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
86 
88  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
89 
95  virtual void OnDataStorageNodeAdded(const mitk::DataNode *node);
96 
102  virtual void OnDataStorageNodeRemoved(const mitk::DataNode *node);
103 
107  virtual void OnDataNodeModified(const itk::Object *caller, const itk::EventObject &event);
108 
112  virtual void OnDataModified(const itk::Object *caller, const itk::EventObject &event);
113 
117  virtual void OnDataStorageDeleted(const itk::Object *caller, const itk::EventObject &event);
118 
119 protected:
121  void reset();
122 
124  void AddNodeToInternalList(mitk::DataNode *node);
125 
127  void RemoveNodeFromInternalList(mitk::DataNode *node);
128 
130  void ClearInternalNodeList();
131 
132 private:
133  enum OBSERVER_TUPLE_NAMES
134  {
135  NODE = 0,
136  NODE_OBSERVER = 1,
137  DATA_OBSERVER = 2,
138  };
139 
141  mitk::NodePredicateBase::Pointer m_NodePredicate;
142 
146 
148  unsigned long m_DataStorageDeleteObserverTag;
149 
154  std::vector<std::tuple<mitk::DataNode *, unsigned long, unsigned long>> m_NodesAndObserverTags;
155 
157  bool m_BlockEvents;
158 };
159 
160 #endif /* QMITKDATASTORAGELISTMODEL_H_ */
Data management class that handles 'was created by' relations.
static mitk::DataStorage::Pointer GetDataStorage()
#define MITKQTWIDGETS_EXPORT
mitk::DataStorage::Pointer m_DataStorage
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66