Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
QmitkPropertyItemDelegate.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 QmitkPropertyItemDelegate_h
14 #define QmitkPropertyItemDelegate_h
15 
16 #include <MitkQtWidgetsExports.h>
17 #include <QListView>
18 #include <QStyledItemDelegate>
19 #include <mitkPropertyList.h>
20 #include <mitkWeakPointer.h>
21 
22 class QComboBox;
23 class QLineEdit;
24 class QToolButton;
25 class QResizeEvent;
26 
27 class QmitkColorWidget : public QWidget
28 {
29  Q_OBJECT
30 
31 public:
32  explicit QmitkColorWidget(QWidget *parent = nullptr);
33  ~QmitkColorWidget() override;
34 
35  QColor GetColor() const;
36  void SetColor(QColor color);
37 
38 signals:
39  void ColorPicked();
40 
41 private slots:
42  void OnButtonClicked();
43  void OnLineEditEditingFinished();
44 
45 private:
46  QColor m_Color;
47  QLineEdit *m_LineEdit;
48  QToolButton *m_Button;
49 };
50 
51 class QmitkComboBoxListView : public QListView
52 {
53  Q_OBJECT
54 
55 public:
56  explicit QmitkComboBoxListView(QComboBox *comboBox = nullptr);
57  ~QmitkComboBoxListView() override;
58 
59 protected:
60  void paintEvent(QPaintEvent *event) override;
61  void resizeEvent(QResizeEvent *event) override;
62  void initViewItemOption(QStyleOptionViewItem *option) const override;
63 
64 private:
65  QComboBox *m_ComboBox;
66 };
67 
68 class MITKQTWIDGETS_EXPORT QmitkPropertyItemDelegate : public QStyledItemDelegate
69 {
70  Q_OBJECT
71 
72 public:
73  explicit QmitkPropertyItemDelegate(QObject *parent = nullptr);
74  ~QmitkPropertyItemDelegate() override;
75 
76  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
77  void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
78  void setEditorData(QWidget *editor, const QModelIndex &index) const override;
79  void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override;
80  void SetPropertyList(mitk::PropertyList *propertyList);
81 
82 private slots:
83  void OnComboBoxCurrentIndexChanged(int index);
84  void OnSpinBoxEditingFinished();
85  void OnColorPicked();
86 
87 private:
88  std::string GetPropertyName(const QModelIndex &index) const;
89 
91 };
92 
93 #endif
QmitkPropertyItemDelegate
Definition: QmitkPropertyItemDelegate.h:68
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
QmitkComboBoxListView::resizeEvent
void resizeEvent(QResizeEvent *event) override
QmitkComboBoxListView::QmitkComboBoxListView
QmitkComboBoxListView(QComboBox *comboBox=nullptr)
QmitkColorWidget
Definition: QmitkPropertyItemDelegate.h:27
QmitkComboBoxListView::initViewItemOption
void initViewItemOption(QStyleOptionViewItem *option) const override
QmitkColorWidget::GetColor
QColor GetColor() const
QmitkComboBoxListView
Definition: QmitkPropertyItemDelegate.h:51
QmitkColorWidget::QmitkColorWidget
QmitkColorWidget(QWidget *parent=nullptr)
QmitkColorWidget::~QmitkColorWidget
~QmitkColorWidget() override
MitkQtWidgetsExports.h
mitkPropertyList.h
mitk::PropertyList
Key-value list holding instances of BaseProperty.
Definition: mitkPropertyList.h:56
QmitkColorWidget::SetColor
void SetColor(QColor color)
mitkWeakPointer.h
QmitkComboBoxListView::~QmitkComboBoxListView
~QmitkComboBoxListView() override
QmitkComboBoxListView::paintEvent
void paintEvent(QPaintEvent *event) override
mitk::WeakPointer< mitk::PropertyList >
QmitkColorWidget::ColorPicked
void ColorPicked()