Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkPropertiesTableModel.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 
14 #ifndef QmitkPropertiesTableModel_h
15 #define QmitkPropertiesTableModel_h
16 
17 #include <MitkQtWidgetsExports.h>
18 
19 //# Own includes
20 #include "mitkDataNode.h"
21 #include "mitkWeakPointer.h"
22 
23 //# Toolkit includes
24 #include <QAbstractTableModel>
25 #include <string>
26 #include <vector>
27 
28 //# Forward declarations
29 
36 class MITKQTWIDGETS_EXPORT QmitkPropertiesTableModel : public QAbstractTableModel
37 {
38  //# PUBLIC CTORS,DTOR,TYPEDEFS,CONSTANTS
39 public:
40  static const int PROPERTY_NAME_COLUMN = 0;
41  static const int PROPERTY_VALUE_COLUMN = 1;
46  typedef std::pair<std::string, mitk::BaseProperty::Pointer> PropertyDataSet;
47 
51  QmitkPropertiesTableModel(QObject *parent = nullptr, mitk::PropertyList::Pointer _PropertyList = nullptr);
52 
55  ~QmitkPropertiesTableModel() override;
56 
57  //# PUBLIC GETTER
58 public:
62  mitk::PropertyList::Pointer GetPropertyList() const;
63 
66  Qt::ItemFlags flags(const QModelIndex &index) const override;
67 
70  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
71 
74  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
75 
78  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
79 
83  int columnCount(const QModelIndex &parent) const override;
84 
85  //# PUBLIC SETTER
86 public:
90  void SetPropertyList(mitk::PropertyList *_PropertyList);
91 
95  virtual void PropertyListDelete();
96 
100  virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event);
101 
105  virtual void PropertyDelete(const itk::Object *caller, const itk::EventObject &event);
106 
110  virtual void SetFilterPropertiesKeyWord(std::string _FilterKeyWord);
111 
115  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
116 
120  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
121 
122  //#PROTECTED INNER CLASSES
123 protected:
129  struct PropertyDataSetCompareFunction : public std::binary_function<PropertyDataSet, PropertyDataSet, bool>
130  {
135  {
136  CompareByName = 0,
137  CompareByValue
138  };
139 
144  {
145  Less = 0,
146  Greater
147  };
148 
152  PropertyDataSetCompareFunction(CompareCriteria _CompareCriteria = CompareByName,
153  CompareOperator _CompareOperator = Less);
157  bool operator()(const PropertyDataSet &_Left, const PropertyDataSet &_Right) const;
158 
159  protected:
162  };
163 
167  struct PropertyListElementFilterFunction : public std::unary_function<PropertyDataSet, bool>
168  {
169  PropertyListElementFilterFunction(const std::string &m_FilterKeyWord);
173  bool operator()(const PropertyDataSet &_Elem) const;
174 
175  protected:
176  std::string m_FilterKeyWord;
177  };
178 
179  //# PROTECTED GETTER
180 protected:
185  int FindProperty(const mitk::BaseProperty *_Property) const;
186 
187  //# PROTECTED SETTER
188 protected:
194  void AddSelectedProperty(PropertyDataSet &_PropertyDataSet);
200  void RemoveSelectedProperty(unsigned int _Index);
207  void Reset();
208 
209  //# PROTECTED MEMBERS
210 protected:
215 
218  std::vector<PropertyDataSet> m_SelectedProperties;
219 
223  std::vector<unsigned long> m_PropertyModifiedObserverTags;
224 
228  std::vector<unsigned long> m_PropertyDeleteObserverTags;
229 
231 
237 
242 
246  std::string m_FilterKeyWord;
247 };
248 
249 #endif /* QMITKPROPERTIESTABLEMODEL_H_ */
std::vector< PropertyDataSet > m_SelectedProperties
Store the properties in a vector so that they may be sorted.
#define MITKQTWIDGETS_EXPORT
Key-value list holding instances of BaseProperty.
CompareCriteria
Specifies field of the property with which it will be sorted.
A struct that inherits from std::binary_function. You can use it in std::sort algorithm for sorting t...
mitk::WeakPointer< mitk::PropertyList > m_PropertyList
Abstract base class for properties.
std::pair< std::string, mitk::BaseProperty::Pointer > PropertyDataSet
std::vector< unsigned long > m_PropertyModifiedObserverTags
Holds all tags of Modified Event Listeners. We need it to remove them again.
bool m_SortDescending
The property is true when the property list is sorted in descending order.
bool m_BlockEvents
Indicates if this class should neglect all incoming events because the class itself triggered the eve...
std::string m_FilterKeyWord
If set to any value, only properties containing the specified keyword in their name will be shown...
std::vector< unsigned long > m_PropertyDeleteObserverTags
Holds all tags of Modified Event Listeners. We need it to remove them again.