Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
QmitkPropertyItemModel.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 QmitkPropertyItemModel_h
14 #define QmitkPropertyItemModel_h
15 
16 #include <MitkQtWidgetsExports.h>
17 #include <QAbstractItemModel>
18 #include <mitkPropertyList.h>
19 #include <mitkWeakPointer.h>
20 #include <mitkCoreServices.h>
21 
22 class QmitkPropertyItem;
23 
24 namespace berry
25 {
26  struct IBerryPreferences;
27 }
28 
29 namespace mitk
30 {
32  enum
33  {
34  PropertyRole = Qt::UserRole + 1
35  };
36 }
37 
51 class MITKQTWIDGETS_EXPORT QmitkPropertyItemModel : public QAbstractItemModel
52 {
53  Q_OBJECT
54 
55 public:
60  explicit QmitkPropertyItemModel(QObject *parent = nullptr);
62 
68  int columnCount(const QModelIndex &parent = QModelIndex()) const override;
69 
76  QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
77 
83  Qt::ItemFlags flags(const QModelIndex &index) const override;
84 
90 
98  QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
99 
107  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
108 
114  QModelIndex parent(const QModelIndex &child) const override;
115 
121  int rowCount(const QModelIndex &parent = QModelIndex()) const override;
122 
130  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
131 
137  void SetPropertyList(mitk::PropertyList *propertyList, const QString &className = "");
138 
142  void Update();
143 
144 private:
145  void CreateRootItem();
146  QModelIndex FindProperty(const mitk::BaseProperty *property);
147  void OnPropertyListModified();
148  void OnPropertyListDeleted();
149  void OnPropertyModified(const itk::Object *property, const itk::EventObject &event);
150  void SetNewPropertyList(mitk::PropertyList *newPropertyList);
151 
155  QString m_ClassName;
156  std::unique_ptr<QmitkPropertyItem> m_RootItem;
157  std::map<std::string, unsigned long> m_PropertyDeletedTags;
158  std::map<std::string, unsigned long> m_PropertyModifiedTags;
159  unsigned long m_PropertyListDeletedTag;
160  unsigned long m_PropertyListModifiedTag;
161 };
162 
163 #endif
#define MITKQTWIDGETS_EXPORT
A tree model that exposes the properties of a mitk::PropertyList.
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
Sets the property value at the given index.
QModelIndex parent(const QModelIndex &child) const override
Returns the parent index for the given child index.
void Update()
Forces a complete rebuild of the model from the current property list.
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the model index for the given row and column.
Qt::ItemFlags flags(const QModelIndex &index) const override
Returns item flags. The value column is editable for leaf items.
void SetPropertyList(mitk::PropertyList *propertyList, const QString &className="")
Sets the property list and optional class name for filtering.
mitk::PropertyList * GetPropertyList() const
Returns the currently associated property list.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Returns data for the given index and role.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of columns (always 2: name and value).
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Returns the number of rows (child properties) under the given parent.
QmitkPropertyItemModel(QObject *parent=nullptr)
Constructs the property item model.
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
Returns header data for the given section.
~QmitkPropertyItemModel() override
A tree item used by QmitkPropertyItemModel to represent a property row.
Abstract base class for properties.
Key-value list holding instances of BaseProperty.
Find image slices visible on a given plane.
@ PropertyRole
Returns a mitk::BaseProperty* wrapped in QVariant.