Medical Imaging Interaction Toolkit  2025.12.02
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:
47  QmitkDataStorageTableModel(mitk::DataStorage::Pointer _DataStorage,
48  mitk::NodePredicateBase *_Predicate = nullptr,
49  QObject *parent = nullptr);
50 
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);
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:
200  mitk::NodePredicateBase::Pointer m_Predicate;
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
#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)
Class for nodes of the DataTree.
Definition: mitkDataNode.h:64
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
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.