Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
QmitkDataStorageTableModel.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 QmitkDataStorageTableModel_h
14 #define QmitkDataStorageTableModel_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
19 #include "mitkBaseProperty.h"
20 #include "mitkDataStorage.h"
21 #include "mitkNodePredicateBase.h"
22 #include "mitkWeakPointer.h"
23 
25 #include <QAbstractTableModel>
26 
28 
36 class MITKQTWIDGETS_EXPORT QmitkDataStorageTableModel : public QAbstractTableModel
37 {
38  Q_OBJECT
39 
40  //#Ctors/Dtor
41 public:
48  mitk::NodePredicateBase *_Predicate = nullptr,
49  QObject *parent = nullptr);
50 
54  ~QmitkDataStorageTableModel() override;
55 
56  //# Public GETTER
57 public:
61  const mitk::DataStorage::Pointer GetDataStorage() const;
65  mitk::NodePredicateBase::Pointer GetPredicate() const;
71  mitk::DataNode::Pointer GetNode(const QModelIndex &index) const;
76  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
81  Qt::ItemFlags flags(const QModelIndex &index) const override;
85  int rowCount(const QModelIndex &parent) const override;
89  int columnCount(const QModelIndex &parent) const override;
93  QVariant data(const QModelIndex &index, int role) const override;
94 
95  //# Public SETTERS
96 public:
100  void SetDataStorage(mitk::DataStorage::Pointer _DataStorage);
104  void SetPredicate(mitk::NodePredicateBase *_Predicate);
112  virtual void AddNode(const mitk::DataNode *node);
116  virtual void RemoveNode(const mitk::DataNode *node);
120  virtual std::vector<mitk::DataNode *> GetNodeSet() const;
127  virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event);
131  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
135  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
136 
137  //#PROTECTED INNER CLASSES
138 protected:
145  {
150  {
151  CompareByName = 0,
153  CompareByVisibility
154  };
155 
160  {
161  Less = 0,
162  Greater
163  };
164 
168  DataNodeCompareFunction(CompareCriteria _CompareCriteria = CompareByName, CompareOperator _CompareOperator = Less);
172  bool operator()(const mitk::DataNode::Pointer &_Left, const mitk::DataNode::Pointer &_Right) const;
173 
174  protected:
177  };
178 
179  //#Protected SETTER
180 protected:
185  virtual void Reset();
186 
187  //#Protected MEMBER VARIABLES
188 protected:
204  std::vector<mitk::DataNode *> m_NodeSet;
208  std::map<mitk::BaseProperty *, unsigned long> m_NamePropertyModifiedObserverTags;
212  std::map<mitk::BaseProperty *, unsigned long> m_VisiblePropertyModifiedObserverTags;
221 };
222 
223 #endif
QmitkDataStorageTableModel::DataNodeCompareFunction::CompareCriteria
CompareCriteria
Specifies field of the property with which it will be sorted.
Definition: QmitkDataStorageTableModel.h:149
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
QmitkDataStorageTableModel
Own includes.
Definition: QmitkDataStorageTableModel.h:36
QmitkDataStorageTableModel::DataNodeCompareFunction::CompareByClassName
@ CompareByClassName
Definition: QmitkDataStorageTableModel.h:152
mitkDataStorage.h
QmitkDataStorageTableModel::DataNodeCompareFunction::CompareOperator
CompareOperator
Specifies Ascending/descending ordering.
Definition: QmitkDataStorageTableModel.h:159
itk::SmartPointer< Self >
mitk::NodePredicateBase
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
Definition: mitkNodePredicateBase.h:35
QmitkDataStorageTableModel::m_SortDescending
bool m_SortDescending
The property is true when the property list is sorted in descending order.
Definition: QmitkDataStorageTableModel.h:220
QmitkDataStorageTableModel::m_NodeSet
std::vector< mitk::DataNode * > m_NodeSet
Definition: QmitkDataStorageTableModel.h:204
mitkNodePredicateBase.h
QmitkDataStorageTableModel::m_VisiblePropertyModifiedObserverTags
std::map< mitk::BaseProperty *, unsigned long > m_VisiblePropertyModifiedObserverTags
Maps a property to an observer tag.
Definition: QmitkDataStorageTableModel.h:212
QmitkDataStorageTableModel::DataNodeCompareFunction
A struct that you can use in std::sort algorithm for sorting the node list elements.
Definition: QmitkDataStorageTableModel.h:144
QmitkDataStorageTableModel::DataNodeCompareFunction::m_CompareOperator
CompareOperator m_CompareOperator
Definition: QmitkDataStorageTableModel.h:176
QmitkDataStorageTableModel::m_NamePropertyModifiedObserverTags
std::map< mitk::BaseProperty *, unsigned long > m_NamePropertyModifiedObserverTags
Maps a property to an observer tag.
Definition: QmitkDataStorageTableModel.h:208
QmitkDataStorageTableModel::DataNodeCompareFunction::m_CompareCriteria
CompareCriteria m_CompareCriteria
Definition: QmitkDataStorageTableModel.h:175
MitkQtWidgetsExports.h
mitkWeakPointer.h
QmitkDataStorageTableModel::m_DataStorage
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
Definition: QmitkDataStorageTableModel.h:195
QmitkDataStorageTableModel::m_BlockEvents
bool m_BlockEvents
Definition: QmitkDataStorageTableModel.h:216
QmitkDataStorageTableModel::m_Predicate
mitk::NodePredicateBase::Pointer m_Predicate
Definition: QmitkDataStorageTableModel.h:200
mitk::WeakPointer< mitk::DataStorage >
mitkBaseProperty.h
mitk::DataNode
Class for nodes of the DataTree.
Definition: mitkDataNode.h:63