Medical Imaging Interaction Toolkit  2026.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 
22 #ifndef QmitkDataStorageTableModel_h
23 #define QmitkDataStorageTableModel_h
24 
25 #include <MitkQtWidgetsExports.h>
26 
28 #include <mitkBaseProperty.h>
29 #include <mitkDataStorage.h>
30 #include <mitkNodePredicateBase.h>
31 #include <mitkWeakPointer.h>
32 
34 #include <QAbstractTableModel>
35 
37 
45 class MITKQTWIDGETS_EXPORT QmitkDataStorageTableModel : public QAbstractTableModel
46 {
47  Q_OBJECT
48 
49  //#Ctors/Dtor
50 public:
56  QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage,
57  mitk::NodePredicateBase *_Predicate = nullptr,
58  QObject *parent = nullptr);
59 
64 
65  //# Public GETTER
66 public:
70  const mitk::DataStorage::Pointer GetDataStorage() const;
74  mitk::NodePredicateBase::Pointer GetPredicate() const;
80  mitk::DataNode::Pointer GetNode(const QModelIndex &index) const;
85  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
90  Qt::ItemFlags flags(const QModelIndex &index) const override;
94  int rowCount(const QModelIndex &parent) const override;
98  int columnCount(const QModelIndex &parent) const override;
102  QVariant data(const QModelIndex &index, int role) const override;
103 
104  //# Public SETTERS
105 public:
109  void SetDataStorage(mitk::DataStorage::Pointer _DataStorage);
121  virtual void AddNode(const mitk::DataNode *node);
125  virtual void RemoveNode(const mitk::DataNode *node);
129  virtual std::vector<mitk::DataNode *> GetNodeSet() const;
136  virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event);
140  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
144  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
145 
146  //#PROTECTED INNER CLASSES
147 protected:
154  {
159  {
160  CompareByName = 0,
162  CompareByVisibility
163  };
164 
169  {
170  Less = 0,
171  Greater
172  };
173 
177  DataNodeCompareFunction(CompareCriteria _CompareCriteria = CompareByName, CompareOperator _CompareOperator = Less);
181  bool operator()(const mitk::DataNode::Pointer &_Left, const mitk::DataNode::Pointer &_Right) const;
182 
183  protected:
186  };
187 
188  //#Protected SETTER
189 protected:
194  virtual void Reset();
195 
196  //#Protected MEMBER VARIABLES
197 protected:
209  mitk::NodePredicateBase::Pointer m_Predicate;
213  std::vector<mitk::DataNode *> m_NodeSet;
217  std::map<mitk::BaseProperty *, unsigned long> m_NamePropertyModifiedObserverTags;
221  std::map<mitk::BaseProperty *, unsigned long> m_VisiblePropertyModifiedObserverTags;
230 };
231 
232 #endif
#define MITKQTWIDGETS_EXPORT
QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage, mitk::NodePredicateBase *_Predicate=nullptr, QObject *parent=nullptr)
mitk::DataNode::Pointer GetNode(const QModelIndex &index) const
QVariant data(const QModelIndex &index, int role) const override
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
virtual void AddNode(const mitk::DataNode *node)
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 mo...
int rowCount(const QModelIndex &parent) const override
void SetDataStorage(mitk::DataStorage::Pointer _DataStorage)
std::map< mitk::BaseProperty *, unsigned long > m_NamePropertyModifiedObserverTags
Maps a property to an observer tag.
bool setData(const QModelIndex &index, const QVariant &value, int role) override
virtual void RemoveNode(const mitk::DataNode *node)
std::map< mitk::BaseProperty *, unsigned long > m_VisiblePropertyModifiedObserverTags
Maps a property to an observer tag.
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
Reimplemented sort function from QAbstractTableModel to enable sorting on the table.
Qt::ItemFlags flags(const QModelIndex &index) const override
~QmitkDataStorageTableModel() override
const mitk::DataStorage::Pointer GetDataStorage() const
int columnCount(const QModelIndex &parent) const override
std::vector< mitk::DataNode * > m_NodeSet
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
bool m_SortDescending
The property is true when the property list is sorted in descending order.
virtual std::vector< mitk::DataNode * > GetNodeSet() const
mitk::NodePredicateBase::Pointer m_Predicate
mitk::NodePredicateBase::Pointer GetPredicate() const
void SetPredicate(mitk::NodePredicateBase *_Predicate)
Central node class of the MITK data tree, associating a data object with properties and mappers.
Definition: mitkDataNode.h:72
Abstract base class for predicates used to filter DataNode objects in DataStorage queries.
A struct that you can use in std::sort algorithm for sorting the node list elements.
CompareCriteria
Specifies field of the property with which it will be sorted.
DataNodeCompareFunction(CompareCriteria _CompareCriteria=CompareByName, CompareOperator _CompareOperator=Less)
Creates a PropertyDataSetCompareFunction. A CompareCriteria and a CompareOperator must be given.
bool operator()(const mitk::DataNode::Pointer &_Left, const mitk::DataNode::Pointer &_Right) const
The reimplemented compare function.
CompareOperator
Specifies Ascending/descending ordering.