Medical Imaging Interaction Toolkit  2016.11.0
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,
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 
18 #ifndef QmitkPropertiesTableModel_h
19 #define QmitkPropertiesTableModel_h
20 
21 #include <MitkQtWidgetsExports.h>
22 
23 //# Own includes
24 #include "mitkDataNode.h"
25 #include "mitkWeakPointer.h"
26 
27 //# Toolkit includes
28 #include <QAbstractTableModel>
29 #include <string>
30 #include <vector>
31 
32 //# Forward declarations
33 
40 class MITKQTWIDGETS_EXPORT QmitkPropertiesTableModel : public QAbstractTableModel
41 {
42  //# PUBLIC CTORS,DTOR,TYPEDEFS,CONSTANTS
43 public:
44  static const int PROPERTY_NAME_COLUMN = 0;
45  static const int PROPERTY_VALUE_COLUMN = 1;
50  typedef std::pair<std::string, mitk::BaseProperty::Pointer> PropertyDataSet;
51 
55  QmitkPropertiesTableModel(QObject *parent = nullptr, mitk::PropertyList::Pointer _PropertyList = nullptr);
56 
59  virtual ~QmitkPropertiesTableModel();
60 
61  //# PUBLIC GETTER
62 public:
66  mitk::PropertyList::Pointer GetPropertyList() const;
67 
70  Qt::ItemFlags flags(const QModelIndex &index) const override;
71 
74  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
75 
78  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
79 
82  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
83 
87  int columnCount(const QModelIndex &parent) const override;
88 
89  //# PUBLIC SETTER
90 public:
94  void SetPropertyList(mitk::PropertyList *_PropertyList);
95 
99  virtual void PropertyListDelete(const itk::Object *_PropertyList);
100 
104  virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event);
105 
109  virtual void PropertyDelete(const itk::Object *caller, const itk::EventObject &event);
110 
114  virtual void SetFilterPropertiesKeyWord(std::string _FilterKeyWord);
115 
119  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
120 
124  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
125 
126  //#PROTECTED INNER CLASSES
127 protected:
133  struct PropertyDataSetCompareFunction : public std::binary_function<PropertyDataSet, PropertyDataSet, bool>
134  {
139  {
140  CompareByName = 0,
141  CompareByValue
142  };
143 
148  {
149  Less = 0,
150  Greater
151  };
152 
156  PropertyDataSetCompareFunction(CompareCriteria _CompareCriteria = CompareByName,
157  CompareOperator _CompareOperator = Less);
161  bool operator()(const PropertyDataSet &_Left, const PropertyDataSet &_Right) const;
162 
163  protected:
166  };
167 
171  struct PropertyListElementFilterFunction : public std::unary_function<PropertyDataSet, bool>
172  {
173  PropertyListElementFilterFunction(const std::string &m_FilterKeyWord);
177  bool operator()(const PropertyDataSet &_Elem) const;
178 
179  protected:
180  std::string m_FilterKeyWord;
181  };
182 
183  //# PROTECTED GETTER
184 protected:
189  int FindProperty(const mitk::BaseProperty *_Property) const;
190 
191  //# PROTECTED SETTER
192 protected:
198  void AddSelectedProperty(PropertyDataSet &_PropertyDataSet);
204  void RemoveSelectedProperty(unsigned int _Index);
211  void Reset();
212 
213  //# PROTECTED MEMBERS
214 protected:
219 
222  std::vector<PropertyDataSet> m_SelectedProperties;
223 
227  std::vector<unsigned long> m_PropertyModifiedObserverTags;
228 
232  std::vector<unsigned long> m_PropertyDeleteObserverTags;
233 
239 
244 
248  std::string m_FilterKeyWord;
249 };
250 
251 #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.
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
CompareCriteria
Specifies field of the property with which it will be sorted.
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.