Medical Imaging Interaction Toolkit  2016.11.0
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,
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 QmitkDataStorageTableModel_h
18 #define QmitkDataStorageTableModel_h
19 
20 #include <MitkQtWidgetsExports.h>
21 
23 #include "mitkBaseProperty.h"
24 #include "mitkDataStorage.h"
25 #include "mitkNodePredicateBase.h"
26 #include "mitkWeakPointer.h"
27 
29 #include <QAbstractTableModel>
30 
32 
40 class MITKQTWIDGETS_EXPORT QmitkDataStorageTableModel : public QAbstractTableModel
41 {
42  Q_OBJECT
43 
44  //#Ctors/Dtor
45 public:
52  mitk::NodePredicateBase *_Predicate = nullptr,
53  QObject *parent = nullptr);
54 
58  virtual ~QmitkDataStorageTableModel();
59 
60  //# Public GETTER
61 public:
69  mitk::NodePredicateBase::Pointer GetPredicate() const;
75  mitk::DataNode::Pointer GetNode(const QModelIndex &index) const;
80  virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
85  virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
89  virtual int rowCount(const QModelIndex &parent) const override;
93  virtual int columnCount(const QModelIndex &parent) const override;
97  virtual QVariant data(const QModelIndex &index, int role) const override;
98 
99  //# Public SETTERS
100 public:
104  void SetDataStorage(mitk::DataStorage::Pointer _DataStorage);
108  void SetPredicate(mitk::NodePredicateBase *_Predicate);
116  virtual void AddNode(const mitk::DataNode *node);
120  virtual void RemoveNode(const mitk::DataNode *node);
124  virtual std::vector<mitk::DataNode *> GetNodeSet() const;
131  virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event);
135  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
139  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
140 
141  //#PROTECTED INNER CLASSES
142 protected:
148  struct DataNodeCompareFunction : public std::binary_function<mitk::DataNode::Pointer, mitk::DataNode::Pointer, bool>
149  {
154  {
155  CompareByName = 0,
157  CompareByVisibility
158  };
159 
164  {
165  Less = 0,
166  Greater
167  };
168 
172  DataNodeCompareFunction(CompareCriteria _CompareCriteria = CompareByName, CompareOperator _CompareOperator = Less);
176  bool operator()(const mitk::DataNode::Pointer &_Left, const mitk::DataNode::Pointer &_Right) const;
177 
178  protected:
181  };
182 
183  //#Protected SETTER
184 protected:
189  virtual void Reset();
190 
191  //#Protected MEMBER VARIABLES
192 protected:
208  std::vector<mitk::DataNode *> m_NodeSet;
212  std::map<mitk::BaseProperty *, unsigned long> m_NamePropertyModifiedObserverTags;
216  std::map<mitk::BaseProperty *, unsigned long> m_VisiblePropertyModifiedObserverTags;
225 };
226 
227 #endif
CompareCriteria
Specifies field of the property with which it will be sorted.
static mitk::DataStorage::Pointer GetDataStorage()
#define MITKQTWIDGETS_EXPORT
std::vector< mitk::DataNode * > m_NodeSet
#define AddNode(name)
mitk::WeakPointer< mitk::DataStorage > m_DataStorage
bool m_SortDescending
The property is true when the property list is sorted in descending order.
std::map< mitk::BaseProperty *, unsigned long > m_VisiblePropertyModifiedObserverTags
Maps a property to an observer tag.
A struct that inherits from std::binary_function. You can use it in std::sort algorithm for sorting t...
std::map< mitk::BaseProperty *, unsigned long > m_NamePropertyModifiedObserverTags
Maps a property to an observer tag.
Interface for evaluation conditions used in the DataStorage class GetSubset() method.
mitk::NodePredicateBase::Pointer m_Predicate
Class for nodes of the DataTree.
Definition: mitkDataNode.h:66
CompareOperator
Specifies Ascending/descending ordering.