Medical Imaging Interaction Toolkit  2024.12.00
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
13 #ifndef QmitkPropertiesTableModel_h
14 #define QmitkPropertiesTableModel_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 #include "mitkDataNode.h"
19 #include "mitkWeakPointer.h"
20 
21 #include <QAbstractTableModel>
22 #include <string>
23 #include <vector>
24 
31 class MITKQTWIDGETS_EXPORT QmitkPropertiesTableModel : public QAbstractTableModel
32 {
33 public:
34  static const int PROPERTY_NAME_COLUMN = 0;
35  static const int PROPERTY_VALUE_COLUMN = 1;
40  typedef std::pair<std::string, mitk::BaseProperty::Pointer> PropertyDataSet;
41 
45  QmitkPropertiesTableModel(QObject *parent = nullptr, mitk::PropertyList::Pointer _PropertyList = nullptr);
46 
49  ~QmitkPropertiesTableModel() override;
50 
51 public:
55  mitk::PropertyList::Pointer GetPropertyList() const;
56 
59  Qt::ItemFlags flags(const QModelIndex &index) const override;
60 
63  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
64 
67  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
68 
71  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
72 
76  int columnCount(const QModelIndex &parent) const override;
77 
81  void SetPropertyList(mitk::PropertyList *_PropertyList);
82 
86  virtual void PropertyListDelete();
87 
91  virtual void PropertyModified(const itk::Object *caller, const itk::EventObject &event);
92 
96  virtual void PropertyDelete(const itk::Object *caller, const itk::EventObject &event);
97 
101  virtual void SetFilterPropertiesKeyWord(std::string _FilterKeyWord);
102 
106  bool setData(const QModelIndex &index, const QVariant &value, int role) override;
107 
111  void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
112 
113 protected:
120  {
125  {
126  CompareByName = 0,
127  CompareByValue
128  };
129 
134  {
135  Less = 0,
136  Greater
137  };
138 
142  PropertyDataSetCompareFunction(CompareCriteria _CompareCriteria = CompareByName,
143  CompareOperator _CompareOperator = Less);
147  bool operator()(const PropertyDataSet &_Left, const PropertyDataSet &_Right) const;
148 
149  protected:
152  };
153 
158  {
159  PropertyListElementFilterFunction(const std::string &m_FilterKeyWord);
163  bool operator()(const PropertyDataSet &_Elem) const;
164 
165  protected:
166  std::string m_FilterKeyWord;
167  };
168 
173  int FindProperty(const mitk::BaseProperty *_Property) const;
174 
180  void AddSelectedProperty(PropertyDataSet &_PropertyDataSet);
186  void RemoveSelectedProperty(unsigned int _Index);
193  void Reset();
194 
199 
202  std::vector<PropertyDataSet> m_SelectedProperties;
203 
207  std::vector<unsigned long> m_PropertyModifiedObserverTags;
208 
212  std::vector<unsigned long> m_PropertyDeleteObserverTags;
213 
215 
221 
226 
230  std::string m_FilterKeyWord;
231 };
232 
233 #endif
QmitkPropertiesTableModel
A table model for showing and editing mitk::Properties.
Definition: QmitkPropertiesTableModel.h:31
mitk::BaseProperty
Abstract base class for properties.
Definition: mitkBaseProperty.h:36
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
QmitkPropertiesTableModel::m_PropertyDeleteObserverTags
std::vector< unsigned long > m_PropertyDeleteObserverTags
Holds all tags of Modified Event Listeners. We need it to remove them again.
Definition: QmitkPropertiesTableModel.h:212
QmitkPropertiesTableModel::m_BlockEvents
bool m_BlockEvents
Indicates if this class should neglect all incoming events because the class itself triggered the eve...
Definition: QmitkPropertiesTableModel.h:220
itk::SmartPointer< Self >
QmitkPropertiesTableModel::m_PropertyList
mitk::WeakPointer< mitk::PropertyList > m_PropertyList
Definition: QmitkPropertiesTableModel.h:198
QmitkPropertiesTableModel::PropertyListElementFilterFunction
Definition: QmitkPropertiesTableModel.h:157
QmitkPropertiesTableModel::m_PropertyModifiedObserverTags
std::vector< unsigned long > m_PropertyModifiedObserverTags
Holds all tags of Modified Event Listeners. We need it to remove them again.
Definition: QmitkPropertiesTableModel.h:207
QmitkPropertiesTableModel::PropertyDataSetCompareFunction::CompareCriteria
CompareCriteria
Specifies field of the property with which it will be sorted.
Definition: QmitkPropertiesTableModel.h:124
QmitkPropertiesTableModel::PropertyDataSet
std::pair< std::string, mitk::BaseProperty::Pointer > PropertyDataSet
Definition: QmitkPropertiesTableModel.h:40
QmitkPropertiesTableModel::m_SortDescending
bool m_SortDescending
The property is true when the property list is sorted in descending order.
Definition: QmitkPropertiesTableModel.h:225
MitkQtWidgetsExports.h
QmitkPropertiesTableModel::PropertyDataSetCompareFunction::m_CompareOperator
CompareOperator m_CompareOperator
Definition: QmitkPropertiesTableModel.h:151
QmitkPropertiesTableModel::PropertyDataSetCompareFunction
A struct that you can use in std::sort algorithm for sorting the property list elements.
Definition: QmitkPropertiesTableModel.h:119
mitk::PropertyList
Key-value list holding instances of BaseProperty.
Definition: mitkPropertyList.h:56
QmitkPropertiesTableModel::m_FilterKeyWord
std::string m_FilterKeyWord
If set to any value, only properties containing the specified keyword in their name will be shown.
Definition: QmitkPropertiesTableModel.h:230
QmitkPropertiesTableModel::m_PropertyListDeleteObserverTag
unsigned long m_PropertyListDeleteObserverTag
Definition: QmitkPropertiesTableModel.h:214
QmitkPropertiesTableModel::PropertyListElementFilterFunction::m_FilterKeyWord
std::string m_FilterKeyWord
Definition: QmitkPropertiesTableModel.h:166
mitkDataNode.h
mitkWeakPointer.h
QmitkPropertiesTableModel::m_SelectedProperties
std::vector< PropertyDataSet > m_SelectedProperties
Store the properties in a vector so that they may be sorted.
Definition: QmitkPropertiesTableModel.h:202
QmitkPropertiesTableModel::PropertyDataSetCompareFunction::m_CompareCriteria
CompareCriteria m_CompareCriteria
Definition: QmitkPropertiesTableModel.h:150
QmitkPropertiesTableModel::PropertyDataSetCompareFunction::CompareOperator
CompareOperator
Specifies Ascending/descending ordering.
Definition: QmitkPropertiesTableModel.h:133
mitk::WeakPointer< mitk::PropertyList >